andrewyng--aisuite
9eb22989ba
Introduce a high-level Agent abstraction for aisuite. An Agent pairs a model with instructions, tools, and run settings, and a Runner drives the multi-step tool-calling loop over any aisuite-supported provider. - aisuite/agents: Runner (run_sync / continue_sync) plus typed Agent, RunResult, RunState, and RunStep - Tool policies (ToolPolicyContext / ToolPolicyDecision) to gate which tools a run may invoke - Continuation API to resume a finished run with new input - aisuite/utils/tools: tool schema generation and execution helpers - examples/agents/simple_agent.py: minimal end-to-end example - tests/agents: runner, tool-policy, continuation, and OpenAI integration coverage Co-authored-by: Rohit <rohit.prasad15@gmail.com>
39 行
1.0 KiB
Python
39 行
1.0 KiB
Python
from aisuite import Agent
|
|
|
|
|
|
def test_agent_stores_definition_fields():
|
|
def tool(city: str) -> str:
|
|
"""Lookup city."""
|
|
return city
|
|
|
|
agent = Agent(
|
|
name="weather",
|
|
model="openai:gpt-4o",
|
|
instructions="Answer briefly.",
|
|
tools=[tool],
|
|
model_settings={"temperature": 0.2},
|
|
tags=["prod"],
|
|
metadata={"team": "growth"},
|
|
)
|
|
|
|
assert agent.name == "weather"
|
|
assert agent.model == "openai:gpt-4o"
|
|
assert agent.instructions == "Answer briefly."
|
|
assert agent.tools == [tool]
|
|
assert agent.model_settings == {"temperature": 0.2}
|
|
assert agent.tags == ["prod"]
|
|
assert agent.metadata == {"team": "growth"}
|
|
|
|
|
|
def test_agent_mutable_defaults_are_independent():
|
|
first = Agent(name="first", model="openai:gpt-4o")
|
|
second = Agent(name="second", model="openai:gpt-4o")
|
|
|
|
first.tools.append(lambda value: value)
|
|
first.tags.append("one")
|
|
first.metadata["team"] = "one"
|
|
|
|
assert second.tools == []
|
|
assert second.tags == []
|
|
assert second.metadata == {}
|