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:
committed by
GitHub
Unverified
parent
a151f10cc2
commit
5687e13221
+1
-1
@@ -213,7 +213,7 @@ async def conclude_workflow(
|
||||
|
||||
def create_email_writer_agent() -> ChatAgent:
|
||||
"""Create the Email Writer agent with tools that require approval."""
|
||||
return OpenAIChatClient().create_agent(
|
||||
return OpenAIChatClient().as_agent(
|
||||
name="Email Writer",
|
||||
instructions=("You are an excellent email assistant. You respond to incoming emails."),
|
||||
# tools with `approval_mode="always_require"` will trigger approval requests
|
||||
|
||||
+3
-3
@@ -99,7 +99,7 @@ async def main() -> None:
|
||||
_chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
|
||||
|
||||
# Create agents that analyze from different perspectives
|
||||
technical_analyst = _chat_client.create_agent(
|
||||
technical_analyst = _chat_client.as_agent(
|
||||
name="technical_analyst",
|
||||
instructions=(
|
||||
"You are a technical analyst. When given a topic, provide a technical "
|
||||
@@ -108,7 +108,7 @@ async def main() -> None:
|
||||
),
|
||||
)
|
||||
|
||||
business_analyst = _chat_client.create_agent(
|
||||
business_analyst = _chat_client.as_agent(
|
||||
name="business_analyst",
|
||||
instructions=(
|
||||
"You are a business analyst. When given a topic, provide a business "
|
||||
@@ -117,7 +117,7 @@ async def main() -> None:
|
||||
),
|
||||
)
|
||||
|
||||
user_experience_analyst = _chat_client.create_agent(
|
||||
user_experience_analyst = _chat_client.as_agent(
|
||||
name="ux_analyst",
|
||||
instructions=(
|
||||
"You are a UX analyst. When given a topic, provide a user experience "
|
||||
|
||||
+4
-4
@@ -44,7 +44,7 @@ async def main() -> None:
|
||||
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
|
||||
|
||||
# Create agents for a group discussion
|
||||
optimist = chat_client.create_agent(
|
||||
optimist = chat_client.as_agent(
|
||||
name="optimist",
|
||||
instructions=(
|
||||
"You are an optimistic team member. You see opportunities and potential "
|
||||
@@ -53,7 +53,7 @@ async def main() -> None:
|
||||
),
|
||||
)
|
||||
|
||||
pragmatist = chat_client.create_agent(
|
||||
pragmatist = chat_client.as_agent(
|
||||
name="pragmatist",
|
||||
instructions=(
|
||||
"You are a pragmatic team member. You focus on practical implementation "
|
||||
@@ -62,7 +62,7 @@ async def main() -> None:
|
||||
),
|
||||
)
|
||||
|
||||
creative = chat_client.create_agent(
|
||||
creative = chat_client.as_agent(
|
||||
name="creative",
|
||||
instructions=(
|
||||
"You are a creative team member. You propose innovative solutions and "
|
||||
@@ -72,7 +72,7 @@ async def main() -> None:
|
||||
)
|
||||
|
||||
# Orchestrator coordinates the discussion
|
||||
orchestrator = chat_client.create_agent(
|
||||
orchestrator = chat_client.as_agent(
|
||||
name="orchestrator",
|
||||
instructions=(
|
||||
"You are a discussion manager coordinating a team conversation between participants. "
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ class TurnManager(Executor):
|
||||
|
||||
def create_guessing_agent() -> ChatAgent:
|
||||
"""Create the guessing agent with instructions to guess a number between 1 and 10."""
|
||||
return AzureOpenAIChatClient(credential=AzureCliCredential()).create_agent(
|
||||
return AzureOpenAIChatClient(credential=AzureCliCredential()).as_agent(
|
||||
name="GuessingAgent",
|
||||
instructions=(
|
||||
"You guess a number between 1 and 10. "
|
||||
|
||||
+3
-3
@@ -41,12 +41,12 @@ async def main() -> None:
|
||||
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
|
||||
|
||||
# Create agents for a sequential document review workflow
|
||||
drafter = chat_client.create_agent(
|
||||
drafter = chat_client.as_agent(
|
||||
name="drafter",
|
||||
instructions=("You are a document drafter. When given a topic, create a brief draft (2-3 sentences)."),
|
||||
)
|
||||
|
||||
editor = chat_client.create_agent(
|
||||
editor = chat_client.as_agent(
|
||||
name="editor",
|
||||
instructions=(
|
||||
"You are an editor. Review the draft and make improvements. "
|
||||
@@ -54,7 +54,7 @@ async def main() -> None:
|
||||
),
|
||||
)
|
||||
|
||||
finalizer = chat_client.create_agent(
|
||||
finalizer = chat_client.as_agent(
|
||||
name="finalizer",
|
||||
instructions=(
|
||||
"You are a finalizer. Take the edited content and create a polished final version. "
|
||||
|
||||
Reference in New Issue
Block a user