Skip to content

Commit 78593b6

Browse files
committed
format
1 parent 2fa8a79 commit 78593b6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=line-too-long,useless-suppression
12
# ------------------------------------
23
# Copyright (c) Microsoft Corporation.
34
# Licensed under the MIT License.
@@ -34,17 +35,23 @@
3435
from dotenv import load_dotenv
3536
from azure.identity import DefaultAzureCredential
3637
from azure.ai.projects import AIProjectClient
37-
from azure.ai.projects.models import PromptAgentDefinition, PromptAgentDefinitionText, ResponseTextFormatConfigurationJsonSchema
38+
from azure.ai.projects.models import (
39+
PromptAgentDefinition,
40+
PromptAgentDefinitionText,
41+
ResponseTextFormatConfigurationJsonSchema,
42+
)
3843
from pydantic import BaseModel
3944

4045
load_dotenv()
4146

47+
4248
class CalendarEvent(BaseModel):
4349
model_config = {"extra": "forbid"}
4450
name: str
4551
date: str
4652
participants: list[str]
4753

54+
4855
project_client = AIProjectClient(
4956
endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
5057
credential=DefaultAzureCredential(),
@@ -58,8 +65,10 @@ class CalendarEvent(BaseModel):
5865
agent_name="MyAgent",
5966
definition=PromptAgentDefinition(
6067
model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
61-
#BUG? text=PromptAgentDefinitionText(format=ResponseTextFormatConfigurationJsonSchema(name="CalendarEvent", schema=CalendarEvent.model_json_schema())),
62-
text=PromptAgentDefinitionText(format={"type": "json_schema", "name": "CalendarEvent", "schema": CalendarEvent.model_json_schema()}),
68+
# BUG? text=PromptAgentDefinitionText(format=ResponseTextFormatConfigurationJsonSchema(name="CalendarEvent", schema=CalendarEvent.model_json_schema())),
69+
text=PromptAgentDefinitionText(
70+
format={"type": "json_schema", "name": "CalendarEvent", "schema": CalendarEvent.model_json_schema()}
71+
),
6372
instructions="""
6473
You are a helpful assistant that extracts calendar event information from the input user messages,
6574
and returns it in the desired structured output format.

0 commit comments

Comments
 (0)