AIAgent
Overview
The AIAgent operator provides a way for interacting with an LLM.
When defining an AIAgent graph, the edge roles of “prompt”, “tool”, and “llm” are used to connect these features.
Once the AIAgent has started, an AIAgentOperator will perform initialization steps:
- if existing conversation, retrieve it
- gather up any special prompts
- wait for response from the prompts
And then enter a loop:
- prepare the llm message which includes the tool schemas()
- send to operator (role = llm)
- wait for response
- determine any tool calls (role = tool) and call it
- if the cycle has finished, end the loop
After loop is finished, pass conversation to operator (role = storage) and return response.
Examples
Calling ChatGPT
Config
name: ai-agent
nodes:
- id: start
operator: HTTPIn
method: GET
routes:
- /ai/agent
- id: user_prompt
operator: MessageTranslator
in_temp: false
template: |
{
"prompt": temp.http_in.query.prompt
}
- id: agent
operator: AIAgent
- id: system_prompt
operator: Stub
data:
content: |
You are a tenant assistant. Use these functions:
1. search_tenants: When user wants to find tenants (e.g., 'show me active tenants')
2. get_tenant_details: When user asks about a specific tenant ID (e.g., 'tell me about tenant p1')
3. clarify_request: When user's request is unclear
- id: tool_get_details
operator: Callout
graph_name: ai-function-get-details
- id: tool_clarify
operator: Callout
graph_name: ai-function-clarify
- id: tool_search
operator: Callout
graph_name: ai-function-search
- id: chatgpt
operator: APICall
url: https://api.openai.com/v1/chat/completions
method: POST
- id: b2j
operator: BufferToJSON
edges:
- { from: start, to: user_prompt }
- { from: user_prompt, to: agent }
- { from: agent, to: b2j }
- { from: agent, to: system_prompt, role: "prompt" }
- { from: agent, to: tool_get_details, role: "tool" }
- { from: agent, to: tool_clarify, role: "tool" }
- { from: agent, to: tool_search, role: "tool" }
- { from: agent, to: chatgpt, role: "llm" }Request
curl "http://localhost:2243/ai/agent?prompt=find me tenants"Configuration Reference
name
Must be 'AIAgent'
Stringrequired