Skip to content

Commit 8e1fab2

Browse files
committed
Upgrade ChatAgent to Agent
1 parent 2ff6645 commit 8e1fab2

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

examples/agent_otel_appinsights.py

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

8-
from agent_framework import ChatAgent
8+
from agent_framework import Agent, tool
99
from agent_framework.observability import create_resource, enable_instrumentation
1010
from agent_framework.openai import OpenAIChatClient
1111
from azure.identity.aio import DefaultAzureCredential, get_bearer_token_provider
@@ -55,6 +55,7 @@
5555
)
5656

5757

58+
@tool
5859
def get_weather(
5960
city: Annotated[str, Field(description="City name, spelled out fully")],
6061
) -> dict:
@@ -69,6 +70,7 @@ def get_weather(
6970
return random.choice(weather_options)
7071

7172

73+
@tool
7274
def get_current_time(
7375
timezone_name: Annotated[str, Field(description="Timezone name, e.g. 'US/Eastern', 'Asia/Tokyo', 'UTC'")],
7476
) -> str:
@@ -78,9 +80,9 @@ def get_current_time(
7880
return f"The current time in {timezone_name} is approximately {now.strftime('%Y-%m-%d %H:%M:%S')} UTC"
7981

8082

81-
agent = ChatAgent(
83+
agent = Agent(
8284
name="weather-time-agent",
83-
chat_client=client,
85+
client=client,
8486
instructions="You are a helpful assistant that can look up weather and time information.",
8587
tools=[get_weather, get_current_time],
8688
)

examples/spanish/agent_otel_appinsights.py

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

8-
from agent_framework import ChatAgent
8+
from agent_framework import Agent, tool
99
from agent_framework.observability import create_resource, enable_instrumentation
1010
from agent_framework.openai import OpenAIChatClient
1111
from azure.identity.aio import DefaultAzureCredential, get_bearer_token_provider
@@ -55,6 +55,7 @@
5555
)
5656

5757

58+
@tool
5859
def get_weather(
5960
city: Annotated[str, Field(description="City name, spelled out fully")],
6061
) -> dict:
@@ -69,6 +70,7 @@ def get_weather(
6970
return random.choice(weather_options)
7071

7172

73+
@tool
7274
def get_current_time(
7375
timezone_name: Annotated[str, Field(description="Timezone name, e.g. 'US/Eastern', 'Asia/Tokyo', 'UTC'")],
7476
) -> str:
@@ -78,9 +80,9 @@ def get_current_time(
7880
return f"La hora actual en {timezone_name} es aproximadamente {now.strftime('%Y-%m-%d %H:%M:%S')} UTC"
7981

8082

81-
agent = ChatAgent(
83+
agent = Agent(
8284
name="weather-time-agent",
83-
chat_client=client,
85+
client=client,
8486
instructions="Eres un asistente útil que puede consultar información del clima y la hora.",
8587
tools=[get_weather, get_current_time],
8688
)

0 commit comments

Comments
 (0)