Skip to content

Commit 8d8b6e8

Browse files
alliscodeCopilot
andcommitted
Fix eval samples: use FoundryChatClient for Agent()
The upstream provider-leading client refactor (#4818) made client= a required parameter on Agent(). Update the three getting-started eval samples to use FoundryChatClient with FOUNDRY_PROJECT_ENDPOINT, matching the standard pattern from 01-get-started samples. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f439746 commit 8d8b6e8

3 files changed

Lines changed: 43 additions & 4 deletions

File tree

python/samples/02-agents/evaluation/evaluate_agent.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"""
1313

1414
import asyncio
15+
import os
1516

1617
from agent_framework import (
1718
Agent,
@@ -20,6 +21,11 @@
2021
evaluator,
2122
keyword_check,
2223
)
24+
from agent_framework.foundry import FoundryChatClient
25+
from azure.identity import AzureCliCredential
26+
from dotenv import load_dotenv
27+
28+
load_dotenv()
2329

2430

2531
# A custom check — parameter names determine what data you receive
@@ -31,8 +37,15 @@ def is_helpful(response: str) -> bool:
3137

3238

3339
async def main() -> None:
40+
client = FoundryChatClient(
41+
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
42+
model=os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME", "gpt-4o"),
43+
credential=AzureCliCredential(),
44+
)
45+
3446
agent = Agent(
35-
model="gpt-4o-mini",
47+
client=client,
48+
name="weather-assistant",
3649
instructions="You are a helpful weather assistant.",
3750
)
3851

python/samples/02-agents/evaluation/evaluate_with_expected.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"""
1313

1414
import asyncio
15+
import os
1516

1617
from agent_framework import (
1718
Agent,
@@ -20,6 +21,11 @@
2021
evaluator,
2122
tool_calls_present,
2223
)
24+
from agent_framework.foundry import FoundryChatClient
25+
from azure.identity import AzureCliCredential
26+
from dotenv import load_dotenv
27+
28+
load_dotenv()
2329

2430

2531
@evaluator
@@ -33,8 +39,15 @@ def response_matches_expected(response: str, expected_output: str) -> float:
3339

3440

3541
async def main() -> None:
42+
client = FoundryChatClient(
43+
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
44+
model=os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME", "gpt-4o"),
45+
credential=AzureCliCredential(),
46+
)
47+
3648
agent = Agent(
37-
model="gpt-4o-mini",
49+
client=client,
50+
name="math-tutor",
3851
instructions="You are a math tutor. Answer concisely.",
3952
)
4053

python/samples/03-workflows/evaluation/evaluate_workflow.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"""
1313

1414
import asyncio
15+
import os
1516

1617
from agent_framework import (
1718
Agent,
@@ -21,6 +22,11 @@
2122
evaluator,
2223
keyword_check,
2324
)
25+
from agent_framework.foundry import FoundryChatClient
26+
from azure.identity import AzureCliCredential
27+
from dotenv import load_dotenv
28+
29+
load_dotenv()
2430

2531

2632
@evaluator
@@ -31,8 +37,15 @@ def is_nonempty(response: str) -> bool:
3137

3238
async def main() -> None:
3339
# Build a simple planner → executor workflow
34-
planner = Agent(model="gpt-4o-mini", instructions="You plan trips. Output a bullet-point plan.")
35-
executor_agent = Agent(model="gpt-4o-mini", instructions="You execute travel plans. Book the items listed.")
40+
client = FoundryChatClient(
41+
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
42+
model=os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME", "gpt-4o"),
43+
credential=AzureCliCredential(),
44+
)
45+
planner = Agent(client=client, name="planner", instructions="You plan trips. Output a bullet-point plan.")
46+
executor_agent = Agent(
47+
client=client, name="executor", instructions="You execute travel plans. Book the items listed."
48+
)
3649

3750
workflow = WorkflowBuilder(start_executor=planner).add_edge(planner, executor_agent).build()
3851

0 commit comments

Comments
 (0)