@aurite-ai/kai 0.2.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -0
- package/dist/kai-mcp.cjs +1652 -0
- package/dist/kai-mcp.cjs.map +7 -0
- package/dist/templates/copilot-configs/claude-code/.claude/CLAUDE.md +272 -0
- package/dist/templates/copilot-configs/claude-code/.claude/agents/architect.md +133 -0
- package/dist/templates/copilot-configs/claude-code/.claude/agents/implementer.md +88 -0
- package/dist/templates/copilot-configs/claude-code/.claude/settings.json +87 -0
- package/dist/templates/copilot-configs/claude-code/.claude/skills/documentation/SKILL.md +54 -0
- package/dist/templates/copilot-configs/claude-code/.claude/skills/verification/SKILL.md +125 -0
- package/dist/templates/frameworks/langgraph/README.md +118 -0
- package/dist/templates/frameworks/langgraph/main.py +97 -0
- package/dist/templates/frameworks/langgraph/pyproject.toml +29 -0
- package/dist/templates/frameworks/langgraph/src/agent/__init__.py +31 -0
- package/dist/templates/frameworks/langgraph/src/agent/graph.py +257 -0
- package/dist/templates/frameworks/langgraph/src/agent/state.py +65 -0
- package/dist/templates/frameworks/langgraph/src/agent/tools.py +30 -0
- package/dist/templates/frameworks/openai/README.md +131 -0
- package/dist/templates/frameworks/openai/main.py +80 -0
- package/dist/templates/frameworks/openai/pyproject.toml +28 -0
- package/dist/templates/frameworks/openai/src/agent/__init__.py +18 -0
- package/dist/templates/frameworks/openai/src/agent/agents.py +122 -0
- package/dist/templates/frameworks/openai/src/agent/tools.py +100 -0
- package/dist/templates/index.d.ts +85 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +270 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/knowledge-base/langgraph-best-practices.mdc +277 -0
- package/dist/templates/knowledge-base/openai-agents-overview.mdc +602 -0
- package/dist/templates/project-env +7 -0
- package/dist/templates/project-gitignore +26 -0
- package/package.json +66 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent State Definition
|
|
3
|
+
|
|
4
|
+
This module defines the state schema for the LangGraph agent using TypedDict.
|
|
5
|
+
State is the shared data structure that flows through the graph, representing
|
|
6
|
+
the current snapshot of your application at any point.
|
|
7
|
+
|
|
8
|
+
Key Concepts:
|
|
9
|
+
- TypedDict provides type hints for state keys
|
|
10
|
+
- Annotated types with reducers control how updates are applied
|
|
11
|
+
- Default reducer overwrites; operator.add appends to lists
|
|
12
|
+
- MessagesState is a common pattern for chat-based agents
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import operator
|
|
16
|
+
from typing import Annotated
|
|
17
|
+
|
|
18
|
+
from langchain_core.messages import AnyMessage
|
|
19
|
+
from typing_extensions import TypedDict
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AgentState(TypedDict):
|
|
23
|
+
"""
|
|
24
|
+
State schema for the agent.
|
|
25
|
+
|
|
26
|
+
This TypedDict defines all the data that flows through the graph.
|
|
27
|
+
Each key can have a reducer function that determines how updates
|
|
28
|
+
are merged with existing state.
|
|
29
|
+
|
|
30
|
+
Attributes:
|
|
31
|
+
messages: List of conversation messages. Uses operator.add as reducer,
|
|
32
|
+
meaning new messages are appended to the existing list rather
|
|
33
|
+
than replacing it. This is essential for maintaining conversation
|
|
34
|
+
history across multiple turns.
|
|
35
|
+
|
|
36
|
+
tool_call_count: Tracks how many tool calls have been made. Uses default
|
|
37
|
+
reducer (overwrite), so each update replaces the previous
|
|
38
|
+
value. Useful for limiting tool call loops.
|
|
39
|
+
|
|
40
|
+
Example state flow:
|
|
41
|
+
Initial: {"messages": [HumanMessage("Hi")], "tool_call_count": 0}
|
|
42
|
+
After LLM: {"messages": [HumanMessage("Hi"), AIMessage("Hello!")], "tool_call_count": 0}
|
|
43
|
+
After tool: {"messages": [..., ToolMessage("result")], "tool_call_count": 1}
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
# Messages use operator.add as a reducer, which appends new messages
|
|
47
|
+
# to the existing list rather than replacing it entirely.
|
|
48
|
+
# This is critical for maintaining conversation history.
|
|
49
|
+
messages: Annotated[list[AnyMessage], operator.add]
|
|
50
|
+
|
|
51
|
+
# Tool call count uses the default reducer (overwrite).
|
|
52
|
+
# Each update replaces the previous value.
|
|
53
|
+
tool_call_count: int
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# Alternative: You could also use the built-in MessagesState for simpler cases:
|
|
57
|
+
#
|
|
58
|
+
# from langgraph.graph import MessagesState
|
|
59
|
+
#
|
|
60
|
+
# class AgentState(MessagesState):
|
|
61
|
+
# """Extends MessagesState with additional fields."""
|
|
62
|
+
# tool_call_count: int
|
|
63
|
+
#
|
|
64
|
+
# MessagesState already includes 'messages' with the add_messages reducer,
|
|
65
|
+
# which handles message ID tracking and deduplication.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tool Definitions
|
|
3
|
+
|
|
4
|
+
Tools are functions the LLM can call. Use the @tool decorator.
|
|
5
|
+
See pattern below - implement your scenario-specific tools here.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from langchain_core.tools import tool
|
|
9
|
+
|
|
10
|
+
# Example tool pattern (implement your own for your scenario):
|
|
11
|
+
#
|
|
12
|
+
# @tool
|
|
13
|
+
# def my_tool(param: str) -> str:
|
|
14
|
+
# """Brief description for the LLM.
|
|
15
|
+
#
|
|
16
|
+
# Args:
|
|
17
|
+
# param: Description of the parameter
|
|
18
|
+
#
|
|
19
|
+
# Returns:
|
|
20
|
+
# Description of what is returned
|
|
21
|
+
# """
|
|
22
|
+
# # Implementation
|
|
23
|
+
# return result
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Add your tools to this list
|
|
27
|
+
tools = []
|
|
28
|
+
|
|
29
|
+
# Dictionary for quick tool lookup by name
|
|
30
|
+
tools_by_name = {tool.name: tool for tool in tools}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# OpenAI Agents Framework
|
|
2
|
+
|
|
3
|
+
A minimal but functional OpenAI Agents SDK project demonstrating core agent patterns.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This scaffold provides a working OpenAI agent with:
|
|
8
|
+
- Basic agent setup with instructions
|
|
9
|
+
- Tool calling with function decorators
|
|
10
|
+
- Multi-agent handoffs for routing
|
|
11
|
+
- Conversation management patterns
|
|
12
|
+
- Well-commented code for learning
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- Python 3.11+
|
|
17
|
+
- `uv` (recommended) or `pip`
|
|
18
|
+
|
|
19
|
+
## Setup
|
|
20
|
+
|
|
21
|
+
### Using uv (Recommended)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Create and activate virtual environment
|
|
25
|
+
uv venv
|
|
26
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
27
|
+
|
|
28
|
+
# Install dependencies
|
|
29
|
+
uv pip install -e .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Using pip
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Create and activate virtual environment
|
|
36
|
+
python -m venv .venv
|
|
37
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
38
|
+
|
|
39
|
+
# Install dependencies
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
Set your OpenAI API key as an environment variable:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export OPENAI_API_KEY="your-key-here"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Running the Agent
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Run with default example
|
|
55
|
+
python main.py
|
|
56
|
+
|
|
57
|
+
# Or import and use programmatically
|
|
58
|
+
python -c "from src.agent import run_agent; import asyncio; asyncio.run(run_agent('Your prompt here'))"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Project Structure
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
openai/
|
|
65
|
+
├── README.md # This file
|
|
66
|
+
├── pyproject.toml # Project configuration
|
|
67
|
+
├── main.py # Entry point
|
|
68
|
+
└── src/
|
|
69
|
+
└── agent/
|
|
70
|
+
├── __init__.py # Package exports
|
|
71
|
+
├── tools.py # Tool definitions (implement your scenario tools here)
|
|
72
|
+
└── agents.py # Agent definitions and runner
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Extending the Agent
|
|
76
|
+
|
|
77
|
+
### Adding New Tools
|
|
78
|
+
|
|
79
|
+
1. Define your tool in `src/agent/tools.py`:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from typing import Annotated
|
|
83
|
+
from pydantic import BaseModel, Field
|
|
84
|
+
from agents import function_tool
|
|
85
|
+
|
|
86
|
+
class MyResult(BaseModel):
|
|
87
|
+
value: str = Field(description="The result value")
|
|
88
|
+
|
|
89
|
+
@function_tool
|
|
90
|
+
def my_new_tool(param: Annotated[str, "Description of the parameter"]) -> MyResult:
|
|
91
|
+
"""Description of what the tool does."""
|
|
92
|
+
return MyResult(value="result")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
2. Add it to the agent's `tools` list in `src/agent/agents.py`.
|
|
96
|
+
|
|
97
|
+
### Adding New Agents
|
|
98
|
+
|
|
99
|
+
Edit `src/agent/agents.py` to add specialist agents:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
specialist_agent = Agent(
|
|
103
|
+
name="Specialist Agent",
|
|
104
|
+
handoff_description="Handles specific domain tasks",
|
|
105
|
+
instructions="You are an expert in...",
|
|
106
|
+
tools=[my_tool],
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# Add to triage agent's handoffs
|
|
110
|
+
triage_agent = Agent(
|
|
111
|
+
name="Triage Agent",
|
|
112
|
+
instructions="Route requests to specialists.",
|
|
113
|
+
handoffs=[specialist_agent],
|
|
114
|
+
)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Conversation Management
|
|
118
|
+
|
|
119
|
+
The example uses manual history management with `result.to_input_list()`. For persistent conversations, consider:
|
|
120
|
+
|
|
121
|
+
- **SQLiteSession**: Local session storage
|
|
122
|
+
- **conversation_id**: Server-managed conversations
|
|
123
|
+
- **previous_response_id**: Lightweight continuation
|
|
124
|
+
|
|
125
|
+
See the OpenAI Agents documentation for details.
|
|
126
|
+
|
|
127
|
+
## Learning Resources
|
|
128
|
+
|
|
129
|
+
- [OpenAI Agents SDK Documentation](https://github.com/openai/openai-agents-python)
|
|
130
|
+
- [OpenAI API Reference](https://platform.openai.com/docs/api-reference)
|
|
131
|
+
- See `.claude/rules/openai-agents.md` for patterns and best practices
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
OpenAI Agents SDK Entry Point
|
|
4
|
+
|
|
5
|
+
This script demonstrates how to run the OpenAI agent with example queries.
|
|
6
|
+
It shows both simple execution and multi-turn conversation patterns.
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
# Run with default examples
|
|
10
|
+
python main.py
|
|
11
|
+
|
|
12
|
+
# Import and use programmatically
|
|
13
|
+
from src.agent import run_agent
|
|
14
|
+
import asyncio
|
|
15
|
+
result = asyncio.run(run_agent("What is 10 + 5?"))
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import asyncio
|
|
19
|
+
import sys
|
|
20
|
+
from agents import Runner
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
async def main():
|
|
24
|
+
"""Run the agent with example queries."""
|
|
25
|
+
# Import here to catch any configuration errors early
|
|
26
|
+
try:
|
|
27
|
+
from src.agent import create_agent, run_agent
|
|
28
|
+
except ValueError as e:
|
|
29
|
+
print(f"Configuration error: {e}")
|
|
30
|
+
print("\nPlease set your API key:")
|
|
31
|
+
print(" export OPENAI_API_KEY='your-key-here'")
|
|
32
|
+
sys.exit(1)
|
|
33
|
+
|
|
34
|
+
print("=" * 50)
|
|
35
|
+
print("OpenAI Agents SDK Demo")
|
|
36
|
+
print("=" * 50)
|
|
37
|
+
|
|
38
|
+
# Example queries that demonstrate tool usage
|
|
39
|
+
example_queries = [
|
|
40
|
+
"What is 15 + 27?",
|
|
41
|
+
"Calculate 8 * 12",
|
|
42
|
+
"What is 100 divided by 4?",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
print("\nRunning example queries...\n")
|
|
46
|
+
|
|
47
|
+
for query in example_queries:
|
|
48
|
+
print(f"User: {query}")
|
|
49
|
+
try:
|
|
50
|
+
response = await run_agent(query)
|
|
51
|
+
print(f"Agent: {response}\n")
|
|
52
|
+
except Exception as e:
|
|
53
|
+
print(f"Error: {e}\n")
|
|
54
|
+
|
|
55
|
+
# Demonstrate multi-turn conversation
|
|
56
|
+
print("-" * 50)
|
|
57
|
+
print("Multi-turn conversation example:")
|
|
58
|
+
print("-" * 50)
|
|
59
|
+
|
|
60
|
+
agent = create_agent()
|
|
61
|
+
|
|
62
|
+
# First turn
|
|
63
|
+
print("\nUser: What city is the Golden Gate Bridge in?")
|
|
64
|
+
result = await Runner.run(agent, "What city is the Golden Gate Bridge in?")
|
|
65
|
+
print(f"Agent: {result.final_output}")
|
|
66
|
+
|
|
67
|
+
# Second turn - using conversation history
|
|
68
|
+
print("\nUser: What state is it in?")
|
|
69
|
+
inputs = result.to_input_list() + [
|
|
70
|
+
{"role": "user", "content": "What state is it in?"}
|
|
71
|
+
]
|
|
72
|
+
result = await Runner.run(agent, inputs)
|
|
73
|
+
print(f"Agent: {result.final_output}")
|
|
74
|
+
|
|
75
|
+
# Show conversation summary
|
|
76
|
+
print(f"\nTotal messages in conversation: {len(result.to_input_list())}")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if __name__ == "__main__":
|
|
80
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "openai-agent"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A minimal OpenAI Agents SDK scaffold for learning and testing"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"openai-agents>=0.1.0",
|
|
9
|
+
"openai>=1.0.0",
|
|
10
|
+
"pydantic>=2.0.0",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[project.optional-dependencies]
|
|
14
|
+
dev = [
|
|
15
|
+
"pytest>=8.0.0",
|
|
16
|
+
"pytest-asyncio>=0.24.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["hatchling"]
|
|
21
|
+
build-backend = "hatchling.build"
|
|
22
|
+
|
|
23
|
+
[tool.hatch.build.targets.wheel]
|
|
24
|
+
packages = ["src/agent"]
|
|
25
|
+
|
|
26
|
+
[tool.pytest.ini_options]
|
|
27
|
+
asyncio_mode = "auto"
|
|
28
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
OpenAI Agents SDK Package
|
|
3
|
+
|
|
4
|
+
This package provides a simple agent setup with tools and multi-agent routing.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .agents import create_agent, run_agent, triage_agent
|
|
8
|
+
from .tools import add, divide, multiply, subtract
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"create_agent",
|
|
12
|
+
"run_agent",
|
|
13
|
+
"triage_agent",
|
|
14
|
+
"add",
|
|
15
|
+
"subtract",
|
|
16
|
+
"multiply",
|
|
17
|
+
"divide",
|
|
18
|
+
]
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent Definitions and Runner
|
|
3
|
+
|
|
4
|
+
This module defines the agents and provides convenience functions for running them.
|
|
5
|
+
|
|
6
|
+
The OpenAI Agents SDK uses:
|
|
7
|
+
- Agent: Defines an agent with name, instructions, tools, and handoffs
|
|
8
|
+
- Runner: Executes agents with the agent loop (LLM calls, tool execution, handoffs)
|
|
9
|
+
|
|
10
|
+
Agent Patterns:
|
|
11
|
+
1. Single Agent: One agent with tools
|
|
12
|
+
2. Handoffs: Specialist agents that take over the conversation
|
|
13
|
+
3. Agents as Tools: Orchestrator calls specialists as tools (not shown here)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import os
|
|
17
|
+
|
|
18
|
+
from agents import Agent, Runner
|
|
19
|
+
|
|
20
|
+
from .tools import add, divide, multiply, subtract
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _check_api_key():
|
|
24
|
+
"""Verify that the OpenAI API key is set."""
|
|
25
|
+
if not os.getenv("OPENAI_API_KEY"):
|
|
26
|
+
raise ValueError(
|
|
27
|
+
"OPENAI_API_KEY environment variable is not set. "
|
|
28
|
+
"Please set it with: export OPENAI_API_KEY='your-key-here'"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Define specialist agents for multi-agent routing
|
|
33
|
+
# These agents handle specific types of requests
|
|
34
|
+
|
|
35
|
+
math_agent = Agent(
|
|
36
|
+
name="Math Agent",
|
|
37
|
+
handoff_description="Specialist agent for mathematical calculations and problems",
|
|
38
|
+
instructions=(
|
|
39
|
+
"You are a math expert. Solve mathematical problems step by step. "
|
|
40
|
+
"Use the available tools to perform calculations. "
|
|
41
|
+
"Explain your reasoning clearly."
|
|
42
|
+
),
|
|
43
|
+
tools=[add, subtract, multiply, divide],
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
general_agent = Agent(
|
|
47
|
+
name="General Agent",
|
|
48
|
+
handoff_description="General purpose agent for non-mathematical questions",
|
|
49
|
+
instructions=(
|
|
50
|
+
"You are a helpful general assistant. "
|
|
51
|
+
"Answer questions clearly and concisely. "
|
|
52
|
+
"If a question requires mathematical calculation, "
|
|
53
|
+
"explain that you've been handed off from the triage agent."
|
|
54
|
+
),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Define the main triage agent that routes to specialists
|
|
58
|
+
# This demonstrates the handoff pattern
|
|
59
|
+
|
|
60
|
+
triage_agent = Agent(
|
|
61
|
+
name="Triage Agent",
|
|
62
|
+
instructions=(
|
|
63
|
+
"You are a routing agent. Analyze each user request and hand off to the "
|
|
64
|
+
"appropriate specialist agent:\n"
|
|
65
|
+
"- Math Agent: For calculations, equations, and mathematical problems\n"
|
|
66
|
+
"- General Agent: For all other questions\n\n"
|
|
67
|
+
"Always hand off to a specialist - do not answer directly."
|
|
68
|
+
),
|
|
69
|
+
handoffs=[math_agent, general_agent],
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def create_agent() -> Agent:
|
|
74
|
+
"""Create and return the main agent.
|
|
75
|
+
|
|
76
|
+
This is a convenience function that checks configuration and returns
|
|
77
|
+
the triage agent. Modify this to return a different agent if needed.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
The configured agent ready to run
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
ValueError: If OPENAI_API_KEY is not set
|
|
84
|
+
"""
|
|
85
|
+
_check_api_key()
|
|
86
|
+
return triage_agent
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
async def run_agent(user_input: str | list[dict]) -> str:
|
|
90
|
+
"""Run the agent with the given input and return the final output.
|
|
91
|
+
|
|
92
|
+
This is a convenience function for simple agent execution. For more control,
|
|
93
|
+
use Runner.run() directly with the agent.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
user_input: Either a string message or a list of message dicts
|
|
97
|
+
(for multi-turn conversations)
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
The agent's final output as a string
|
|
101
|
+
|
|
102
|
+
Raises:
|
|
103
|
+
ValueError: If OPENAI_API_KEY is not set
|
|
104
|
+
Exception: If the agent execution fails
|
|
105
|
+
"""
|
|
106
|
+
agent = create_agent()
|
|
107
|
+
result = await Runner.run(agent, user_input)
|
|
108
|
+
return result.final_output
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# Example: Creating a simple single-agent setup (alternative to triage)
|
|
112
|
+
# Uncomment and modify create_agent() to use this instead
|
|
113
|
+
|
|
114
|
+
# simple_agent = Agent(
|
|
115
|
+
# name="Calculator Agent",
|
|
116
|
+
# instructions=(
|
|
117
|
+
# "You are a helpful calculator assistant. "
|
|
118
|
+
# "Use the available tools to perform calculations. "
|
|
119
|
+
# "Show your work step by step."
|
|
120
|
+
# ),
|
|
121
|
+
# tools=[add, subtract, multiply, divide],
|
|
122
|
+
# )
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tool Definitions
|
|
3
|
+
|
|
4
|
+
This module defines the tools available to the agent. Tools are Python functions
|
|
5
|
+
decorated with @function_tool that the agent can call to perform actions.
|
|
6
|
+
|
|
7
|
+
The OpenAI Agents SDK automatically:
|
|
8
|
+
- Converts function signatures to tool schemas
|
|
9
|
+
- Handles tool calling and result passing
|
|
10
|
+
- Validates inputs using type hints and Pydantic models
|
|
11
|
+
|
|
12
|
+
To add a new tool:
|
|
13
|
+
1. Define a function with clear type hints
|
|
14
|
+
2. Add a descriptive docstring (becomes tool description)
|
|
15
|
+
3. Decorate with @function_tool
|
|
16
|
+
4. Add to the agent's tools list in agents.py
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from typing import Annotated
|
|
20
|
+
|
|
21
|
+
from agents import function_tool
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Example: Simple function tool with primitive return type
|
|
25
|
+
@function_tool
|
|
26
|
+
def add(
|
|
27
|
+
a: Annotated[float, "The first number"],
|
|
28
|
+
b: Annotated[float, "The second number"],
|
|
29
|
+
) -> float:
|
|
30
|
+
"""Add two numbers together.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
a: The first number to add
|
|
34
|
+
b: The second number to add
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
The sum of a and b
|
|
38
|
+
"""
|
|
39
|
+
return a + b
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@function_tool
|
|
43
|
+
def subtract(
|
|
44
|
+
a: Annotated[float, "The first number"],
|
|
45
|
+
b: Annotated[float, "The second number"],
|
|
46
|
+
) -> float:
|
|
47
|
+
"""Subtract the second number from the first.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
a: The number to subtract from
|
|
51
|
+
b: The number to subtract
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
The difference (a - b)
|
|
55
|
+
"""
|
|
56
|
+
return a - b
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@function_tool
|
|
60
|
+
def multiply(
|
|
61
|
+
a: Annotated[float, "The first number"],
|
|
62
|
+
b: Annotated[float, "The second number"],
|
|
63
|
+
) -> float:
|
|
64
|
+
"""Multiply two numbers together.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
a: The first number to multiply
|
|
68
|
+
b: The second number to multiply
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
The product of a and b
|
|
72
|
+
"""
|
|
73
|
+
return a * b
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@function_tool
|
|
77
|
+
def divide(
|
|
78
|
+
a: Annotated[float, "The numerator"],
|
|
79
|
+
b: Annotated[float, "The denominator"],
|
|
80
|
+
) -> float:
|
|
81
|
+
"""Divide the first number by the second.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
a: The number to divide (numerator)
|
|
85
|
+
b: The number to divide by (denominator)
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
The quotient (a / b)
|
|
89
|
+
|
|
90
|
+
Raises:
|
|
91
|
+
ValueError: If b is zero
|
|
92
|
+
"""
|
|
93
|
+
if b == 0:
|
|
94
|
+
raise ValueError("Cannot divide by zero")
|
|
95
|
+
return a / b
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# List of all tools to export
|
|
99
|
+
# Add new tools here to make them available for import
|
|
100
|
+
tools = [add, subtract, multiply, divide]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template access utilities for file-based templates.
|
|
3
|
+
*
|
|
4
|
+
* Templates are stored as files in the templates/ directory and are
|
|
5
|
+
* read from the filesystem at runtime. This makes templates easier
|
|
6
|
+
* to maintain and edit compared to embedding them as strings.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A template file with its relative path and content.
|
|
10
|
+
*/
|
|
11
|
+
export interface TemplateFile {
|
|
12
|
+
path: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Framework template metadata.
|
|
17
|
+
*/
|
|
18
|
+
export interface FrameworkTemplate {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
path: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Copilot config template metadata.
|
|
26
|
+
*/
|
|
27
|
+
export interface CopilotConfigTemplate {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
path: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Available framework templates.
|
|
35
|
+
*/
|
|
36
|
+
export declare const FRAMEWORK_TEMPLATES: FrameworkTemplate[];
|
|
37
|
+
/**
|
|
38
|
+
* Available copilot configuration templates.
|
|
39
|
+
*/
|
|
40
|
+
export declare const COPILOT_CONFIG_TEMPLATES: CopilotConfigTemplate[];
|
|
41
|
+
/**
|
|
42
|
+
* Get a framework template by ID.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getFrameworkTemplate(id: string): FrameworkTemplate | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Get a copilot config template by ID.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getCopilotConfigTemplate(id: string): CopilotConfigTemplate | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* List all available frameworks.
|
|
51
|
+
*/
|
|
52
|
+
export declare function listFrameworks(): FrameworkTemplate[];
|
|
53
|
+
/**
|
|
54
|
+
* List all available copilot configs.
|
|
55
|
+
*/
|
|
56
|
+
export declare function listCopilotConfigs(): CopilotConfigTemplate[];
|
|
57
|
+
/**
|
|
58
|
+
* Get project-level template files (.env template, .gitignore).
|
|
59
|
+
*/
|
|
60
|
+
export declare function getProjectFiles(): Promise<TemplateFile[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Get LangGraph framework files.
|
|
63
|
+
*/
|
|
64
|
+
export declare function getLangGraphFiles(): Promise<TemplateFile[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Get OpenAI framework files.
|
|
67
|
+
*/
|
|
68
|
+
export declare function getOpenAIFiles(): Promise<TemplateFile[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get Claude Code configuration files.
|
|
71
|
+
*/
|
|
72
|
+
export declare function getClaudeCodeFiles(): Promise<TemplateFile[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Get knowledge base seed files.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getKnowledgeBaseFiles(): Promise<TemplateFile[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Get template files for a framework.
|
|
79
|
+
*/
|
|
80
|
+
export declare function getFrameworkFiles(frameworkId: string): Promise<TemplateFile[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Get config files for a copilot.
|
|
83
|
+
*/
|
|
84
|
+
export declare function getCopilotConfigFiles(copilotId: string): Promise<TemplateFile[]>;
|
|
85
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AA8FD;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,EAclD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,qBAAqB,EAO3D,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAE9E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAEtF;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,iBAAiB,EAAE,CAEpD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,qBAAqB,EAAE,CAE5D;AAkED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAc/D;AAED;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAIjE;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAI9D;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAIlE;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAIrE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CASpF;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAOtF"}
|