Skip to content

Commit 96ca2ba

Browse files
committed
Port to ChatAgent, devcontainer tweaks
1 parent 1c4fba3 commit 96ca2ba

File tree

9 files changed

+46
-19
lines changed

9 files changed

+46
-19
lines changed

.devcontainer/devcontainer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
},
1010
"customizations": {
1111
"vscode": {
12+
"settings": {
13+
"python.defaultInterpreterPath": "/usr/local/bin/python",
14+
"remote.autoForwardPorts": false,
15+
"python.createEnvironment.trigger": "off",
16+
"python.analysis.typeCheckingMode": "off"
17+
},
1218
"extensions": [
1319
"ms-python.python",
1420
"ms-azuretools.vscode-bicep"
15-
],
16-
"python.defaultInterpreterPath": "/usr/local/bin/python"
21+
]
1722
}
1823
},
19-
"remoteUser": "vscode",
20-
"hostRequirements": {
21-
"memory": "8gb"
22-
}
24+
"remoteUser": "vscode"
2325
}

examples/agentframework_basic.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import os
33

4+
from agent_framework import ChatAgent
45
from agent_framework.azure import AzureOpenAIChatClient
56
from agent_framework.openai import OpenAIChatClient
67
from azure.identity import DefaultAzureCredential
@@ -34,7 +35,10 @@
3435
api_key=os.environ.get("OPENAI_API_KEY"), model_id=os.environ.get("OPENAI_MODEL", "gpt-4o")
3536
)
3637

37-
agent = client.create_agent(instructions="You're an informational agent. Answer questions cheerfully.")
38+
agent = ChatAgent(
39+
chat_client=client,
40+
instructions="You're an informational agent. Answer questions cheerfully."
41+
)
3842

3943

4044
async def main():

examples/agentframework_supervisor.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from datetime import datetime
66
from typing import Annotated
77

8+
from agent_framework import ChatAgent
89
from agent_framework.azure import AzureOpenAIChatClient
910
from agent_framework.openai import OpenAIChatClient
1011
from azure.identity import DefaultAzureCredential
@@ -80,7 +81,8 @@ def get_current_date() -> str:
8081
return datetime.now().strftime("%Y-%m-%d")
8182

8283

83-
weekend_agent = client.create_agent(
84+
weekend_agent = ChatAgent(
85+
chat_client=client,
8486
instructions=(
8587
"You help users plan their weekends and choose the best activities for the given weather. "
8688
"If an activity would be unpleasant in the weather, don't suggest it. "
@@ -144,7 +146,8 @@ def check_fridge() -> list[str]:
144146
return items
145147

146148

147-
meal_agent = client.create_agent(
149+
meal_agent = ChatAgent(
150+
chat_client=client,
148151
instructions=(
149152
"You help users plan meals and choose the best recipes. "
150153
"Include the ingredients and cooking instructions in your response. "
@@ -165,7 +168,8 @@ async def plan_meal(query: str) -> str:
165168
# Supervisor agent orchestrating sub-agents
166169
# ----------------------------------------------------------------------------------
167170

168-
supervisor_agent = client.create_agent(
171+
supervisor_agent = ChatAgent(
172+
chat_client=client,
169173
instructions=(
170174
"You are a supervisor managing two specialist agents: a weekend planning agent and a meal planning agent. "
171175
"Break down the user's request, decide which specialist (or both) to call via the available tools, "

examples/agentframework_tool.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import random
55
from typing import Annotated
66

7+
from agent_framework import ChatAgent
78
from agent_framework.azure import AzureOpenAIChatClient
89
from agent_framework.openai import OpenAIChatClient
910
from azure.identity import DefaultAzureCredential
@@ -61,8 +62,10 @@ def get_weather(
6162
}
6263

6364

64-
agent = client.create_agent(
65-
instructions="You're an informational agent. Answer questions cheerfully.", tools=[get_weather]
65+
agent = ChatAgent(
66+
chat_client=client,
67+
instructions="You're an informational agent. Answer questions cheerfully.",
68+
tools=[get_weather]
6669
)
6770

6871

examples/agentframework_tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from datetime import datetime
66
from typing import Annotated
77

8+
from agent_framework import ChatAgent
89
from agent_framework.azure import AzureOpenAIChatClient
910
from agent_framework.openai import OpenAIChatClient
1011
from azure.identity import DefaultAzureCredential
@@ -81,7 +82,8 @@ def get_current_date() -> str:
8182
return datetime.now().strftime("%Y-%m-%d")
8283

8384

84-
agent = client.create_agent(
85+
agent = ChatAgent(
86+
chat_client=client,
8587
instructions=(
8688
"You help users plan their weekends and choose the best activities for the given weather. "
8789
"If an activity would be unpleasant in weather, don't suggest it. Include date of the weekend in response."

examples/spanish/agentframework_basic.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import os
33

4+
from agent_framework import ChatAgent
45
from agent_framework.azure import AzureOpenAIChatClient
56
from agent_framework.openai import OpenAIChatClient
67
from azure.identity import DefaultAzureCredential
@@ -34,7 +35,10 @@
3435
api_key=os.environ.get("OPENAI_API_KEY"), model_id=os.environ.get("OPENAI_MODEL", "gpt-4o")
3536
)
3637

37-
agent = client.create_agent(instructions="Eres un agente informativo. Responde a las preguntas con alegría.")
38+
agent = ChatAgent(
39+
chat_client=client,
40+
instructions="Eres un agente informativo. Responde a las preguntas con alegría."
41+
)
3842

3943

4044
async def main():

examples/spanish/agentframework_supervisor.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from datetime import datetime
66
from typing import Annotated
77

8+
from agent_framework import ChatAgent
89
from agent_framework.azure import AzureOpenAIChatClient
910
from agent_framework.openai import OpenAIChatClient
1011
from azure.identity import DefaultAzureCredential
@@ -80,7 +81,8 @@ def get_current_date() -> str:
8081
return datetime.now().strftime("%Y-%m-%d")
8182

8283

83-
weekend_agent = client.create_agent(
84+
weekend_agent = ChatAgent(
85+
chat_client=client,
8486
instructions=(
8587
"Ayudas a las personas a planear su fin de semana y elegir las mejores actividades según el clima. "
8688
"Si una actividad sería desagradable con el clima previsto, no la sugieras. "
@@ -148,7 +150,8 @@ def check_fridge() -> list[str]:
148150
return items
149151

150152

151-
meal_agent = client.create_agent(
153+
meal_agent = ChatAgent(
154+
chat_client=client,
152155
instructions=(
153156
"Ayudas a las personas a planear comidas y elegir las mejores recetas. "
154157
"Incluye los ingredientes e instrucciones de cocina en tu respuesta. "
@@ -169,7 +172,8 @@ async def plan_meal(query: str) -> str:
169172
# Agente supervisor orquestando subagentes
170173
# ----------------------------------------------------------------------------------
171174

172-
supervisor_agent = client.create_agent(
175+
supervisor_agent = ChatAgent(
176+
chat_client=client,
173177
instructions=(
174178
"Eres un supervisor que gestiona dos agentes especialistas: uno de "
175179
"planificación de fin de semana y otro de planificación de comidas. "

examples/spanish/agentframework_tool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import random
55
from typing import Annotated
66

7+
from agent_framework import ChatAgent
78
from agent_framework.azure import AzureOpenAIChatClient
89
from agent_framework.openai import OpenAIChatClient
910
from azure.identity import DefaultAzureCredential
@@ -61,7 +62,8 @@ def get_weather(
6162
}
6263

6364

64-
agent = client.create_agent(
65+
agent = ChatAgent(
66+
chat_client=client,
6567
instructions="Eres un agente informativo. Responde a las preguntas con alegría.",
6668
tools=[get_weather],
6769
)

examples/spanish/agentframework_tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from datetime import datetime
66
from typing import Annotated
77

8+
from agent_framework import ChatAgent
89
from agent_framework.azure import AzureOpenAIChatClient
910
from agent_framework.openai import OpenAIChatClient
1011
from azure.identity import DefaultAzureCredential
@@ -81,7 +82,8 @@ def get_current_date() -> str:
8182
return datetime.now().strftime("%Y-%m-%d")
8283

8384

84-
agent = client.create_agent(
85+
agent = ChatAgent(
86+
chat_client=client,
8587
instructions=(
8688
"Ayudas a las personas a planear su fin de semana y elegir las mejores actividades según el clima. "
8789
"Si una actividad sería desagradable con el clima previsto, no la sugieras. "

0 commit comments

Comments
 (0)