mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: [BREAKING] Renamed create_agent to as_agent (#3249)
* Renamed create_agent to as_agent * Override for as_agent * Added override
This commit is contained in:
@@ -33,7 +33,7 @@ async def run_agent_framework() -> None:
|
||||
|
||||
# AF constructs a lightweight ChatAgent backed by OpenAIChatClient
|
||||
client = OpenAIChatClient(model_id="gpt-4.1-mini")
|
||||
agent = client.create_agent(
|
||||
agent = client.as_agent(
|
||||
name="assistant",
|
||||
instructions="You are a helpful assistant. Answer in one sentence.",
|
||||
)
|
||||
|
||||
@@ -65,7 +65,7 @@ async def run_agent_framework() -> None:
|
||||
|
||||
# Create agent with tool
|
||||
client = OpenAIChatClient(model_id="gpt-4.1-mini")
|
||||
agent = client.create_agent(
|
||||
agent = client.as_agent(
|
||||
name="assistant",
|
||||
instructions="You are a helpful assistant. Use available tools to answer questions.",
|
||||
tools=[get_weather],
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ async def run_agent_framework() -> None:
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
|
||||
client = OpenAIChatClient(model_id="gpt-4.1-mini")
|
||||
agent = client.create_agent(
|
||||
agent = client.as_agent(
|
||||
name="assistant",
|
||||
instructions="You are a helpful math tutor.",
|
||||
)
|
||||
|
||||
@@ -54,7 +54,7 @@ async def run_agent_framework() -> None:
|
||||
client = OpenAIChatClient(model_id="gpt-4.1-mini")
|
||||
|
||||
# Create specialized writer agent
|
||||
writer = client.create_agent(
|
||||
writer = client.as_agent(
|
||||
name="writer",
|
||||
instructions="You are a creative writer. Write short, engaging content.",
|
||||
)
|
||||
@@ -68,7 +68,7 @@ async def run_agent_framework() -> None:
|
||||
)
|
||||
|
||||
# Create coordinator agent with writer tool
|
||||
coordinator = client.create_agent(
|
||||
coordinator = client.as_agent(
|
||||
name="coordinator",
|
||||
instructions="You coordinate with specialized agents. Delegate writing tasks to the writer agent.",
|
||||
tools=[writer_tool],
|
||||
|
||||
Reference in New Issue
Block a user