Built-in Module

ai.generate

Generate text using AI models. Supports Ollama, OpenAI, and custom endpoints.

Configuration

ParameterTypeRequiredDescription
promptstringYesThe prompt to send to the AI model
modelstringNoModel name (default: from config.yaml)
system_promptstringNoSystem instructions for the model
max_tokensnumberNoMax tokens in response

Provider Configuration

Configure your AI provider in .shiro/config.yaml:

Ollama (Local)

yaml
ai:
  provider: ollama
  model: llama3.2
  endpoint: http://localhost:11434

OpenAI

yaml
ai:
  provider: openai
  model: gpt-4o
  api_key: "{{env.OPENAI_API_KEY}}"

Custom Endpoint

yaml
ai:
  provider: custom
  model: my-model
  endpoint: https://my-ai-api.example.com
  api_key: "{{env.CUSTOM_API_KEY}}"

Examples

Code Review

json
{
  "id": "review",
  "type": "ai.generate",
  "config": {
    "system_prompt": "You are an expert code reviewer. Be concise and actionable.",
    "prompt": "Review this diff and identify issues:\n{{steps.get_diff.diff}}",
    "model": "gpt-4o"
  },
  "depends_on": ["get_diff"]
}

Commit Message Generation

json
{
  "id": "gen_commit_msg",
  "type": "ai.generate",
  "config": {
    "prompt": "Write a conventional commit message for:\n{{steps.get_diff.diff}}",
    "max_tokens": 100
  },
  "depends_on": ["get_diff"]
}

Output

  • text - Generated text response
  • model - Model used
  • tokens_used - Token count (if available)