# 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** ```json { "name": "{{ name }}", "connector": "gpt-4o", "description": "{{ description }}", "placeholder": { "title": "{{ chat.title }}", "prompts": ["{{ chat.prompts.0 }}"] } } ``` **prompts.yml** ```yaml - role: system content: | You are a helpful assistant. ``` **locales/en-us.yml** ```yaml 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: ```typescript 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) ```bash # Run tests yao agent test -i "Hello, how are you?" # Run tests from JSONL file yao agent test -i tests/inputs.jsonl -v # Extract results for review yao agent extract output-*.jsonl ``` ### 4. Run ```bash yao start ``` Access via API: `POST /v1/chat/completions` ## Examples ### Hook: Route to Specialist ```typescript // src/index.ts function Create(ctx: agent.Context, messages: agent.Message[]): agent.Create { const last = messages[messages.length - 1]?.content || ""; if (last.includes("refund")) { return { delegate: { agent_id: "refund-specialist", messages } }; } return null; } ``` ### Database Query ```json // package.yao - Enable auto DB search { "db": { "models": ["orders", "products"] } } ``` ```bash # Test: Agent auto-generates QueryDSL and searches database yao agent test -i "Find orders over $1000 from last month" ``` ### MCP Tools (Process Transport) ```json // mcps/tools.mcp.yao - Define MCP server with Yao Processes { "label": "Tools", "transport": "process", "tools": { "search_orders": "models.order.Paginate", "create_order": "models.order.Create" } } ``` ```json // mcps/mapping/tools/schemes/search_orders.in.yao - Input schema { "type": "object", "properties": { "keyword": { "type": "string" }, "page": { "type": "integer" } }, "x-process-args": [":arguments"] } ``` ```json // package.yao { "mcp": { "servers": [{ "server_id": "tools" }] } } ``` ### Sidebar Page (Display Data) Pages render in the right sidebar during conversation to display structured data: ```html
| {{ row.name }} | {{ row.value }} |