- Updated the Agent API documentation to reflect a new structure, emphasizing quick start instructions and reorganizing content for better readability. - Renamed the main documentation title to "Yao Agent" and streamlined sections, including API endpoints and file management. - Adjusted the SUI documentation to align with the Yao App Engine license, ensuring consistency across project documentation. |
||
|---|---|---|
| .. | ||
| assistant | ||
| caller | ||
| content | ||
| context | ||
| docs | ||
| i18n | ||
| llm | ||
| memory | ||
| output | ||
| search | ||
| store | ||
| test | ||
| testutils | ||
| types | ||
| agent_test.go | ||
| load.go | ||
| load_test.go | ||
| README.md | ||
Yao Agent
A powerful AI assistant framework for building intelligent conversational agents with tool integration, knowledge base search, and multi-agent orchestration.
Quick Start
1. Create an Assistant
assistants/
└── my-assistant/
├── package.yao # Configuration
├── prompts.yml # System prompts
└── locales/
└── en-us.yml # Translations
package.yao
{
"name": "{{ name }}",
"connector": "gpt-4o",
"description": "{{ description }}",
"placeholder": {
"title": "{{ chat.title }}",
"prompts": ["{{ chat.prompts.0 }}"]
}
}
prompts.yml
- role: system
content: |
You are a helpful assistant.
locales/en-us.yml
name: My Assistant
description: A helpful AI assistant
chat:
title: New Chat
prompts:
- How can I help you today?
2. Add Hooks (Optional)
Create src/index.ts for custom logic:
import { agent } from "@yao/runtime";
function Create(ctx: agent.Context, messages: agent.Message[]): agent.Create {
// Preprocess messages before LLM call
return { messages };
}
function Next(ctx: agent.Context, payload: agent.Payload): agent.Next {
// Post-process LLM response
return null;
}
3. Test (Optional)
yao agent test -i "Hello, how are you?"
4. Run
yao start
Access via API: POST /api/__yao/agent
Documentation
- Configuration - Assistant settings, connectors, options
- Prompts - System prompts and prompt presets
- Hooks - Create/Next hooks and agent lifecycle
- Context API - Messaging, memory, trace, MCP
- MCP Integration - Tool servers and resources
- Search - Web, knowledge base, and database search
- Internationalization - Multi-language support
- Testing - Agent testing framework
Architecture
flowchart LR
subgraph Request
A[User Request]
end
subgraph Create["Create Hook"]
B1[Preprocess Messages]
B2[Configure LLM]
B3[Delegate to Agent]
end
subgraph LLM["LLM Call"]
C1[Load Prompts]
C2[Generate Response]
end
subgraph Tools["Tool Execution"]
D1[MCP Tools]
D2[Search]
D3[Memory]
end
subgraph Next["Next Hook"]
E1[Process Results]
E2[Transform Output]
E3[Delegate to Agent]
end
subgraph Response
F[Stream Response]
end
A --> Create
Create --> LLM
LLM --> Tools
Tools --> Next
Next --> Response
Next -.->|Continue| LLM
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/__yao/agent |
POST | Chat with assistant |
/api/__yao/agent/history |
GET | Get chat history |
/api/__yao/agent/chats |
GET | List chat sessions |
/api/__yao/agent/assistants |
GET | List assistants |
/api/__yao/agent/upload/:type |
POST | Upload files |
License
This project is part of the Yao App Engine and follows the Yao Open Source License.