mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix migration samples (#5015)
* Fix migration samples * Fix migration samples 2 * Fix formatting * Comments
This commit is contained in:
committed by
GitHub
Unverified
parent
d992febe9b
commit
e43fc8ccec
+4
-1
@@ -22,10 +22,13 @@ async def run_semantic_kernel() -> None:
|
||||
from semantic_kernel.agents import OpenAIResponsesAgent
|
||||
from semantic_kernel.connectors.ai.open_ai import OpenAISettings
|
||||
|
||||
openai_settings = OpenAISettings()
|
||||
assert openai_settings.responses_model_id is not None, "Responses model ID must be set in OpenAISettings"
|
||||
|
||||
client = OpenAIResponsesAgent.create_client()
|
||||
# SK response agents wrap OpenAI's hosted Responses API.
|
||||
agent = OpenAIResponsesAgent(
|
||||
ai_model=OpenAISettings().responses_model_id,
|
||||
ai_model_id=openai_settings.responses_model_id,
|
||||
client=client,
|
||||
instructions="Answer in one concise sentence.",
|
||||
name="Expert",
|
||||
|
||||
+4
-1
@@ -28,10 +28,13 @@ async def run_semantic_kernel() -> None:
|
||||
def add(self, a: float, b: float) -> float:
|
||||
return a + b
|
||||
|
||||
openai_settings = OpenAISettings()
|
||||
assert openai_settings.responses_model_id is not None, "Responses model ID must be set in OpenAISettings"
|
||||
|
||||
client = OpenAIResponsesAgent.create_client()
|
||||
# Plugins advertise callable tools to the Responses agent.
|
||||
agent = OpenAIResponsesAgent(
|
||||
ai_model=OpenAISettings().responses_model_id,
|
||||
ai_model_id=openai_settings.responses_model_id,
|
||||
client=client,
|
||||
instructions="Use the add tool when math is required.",
|
||||
name="MathExpert",
|
||||
|
||||
+5
-2
@@ -29,14 +29,17 @@ async def run_semantic_kernel() -> None:
|
||||
from semantic_kernel.agents import OpenAIResponsesAgent
|
||||
from semantic_kernel.connectors.ai.open_ai import OpenAISettings
|
||||
|
||||
openai_settings = OpenAISettings()
|
||||
assert openai_settings.responses_model_id is not None, "Responses model ID must be set in OpenAISettings"
|
||||
|
||||
client = OpenAIResponsesAgent.create_client()
|
||||
# response_format requests schema-constrained output from the model.
|
||||
agent = OpenAIResponsesAgent(
|
||||
ai_model=OpenAISettings().responses_model_id,
|
||||
ai_model_id=openai_settings.responses_model_id,
|
||||
client=client,
|
||||
instructions="Return launch briefs as structured JSON.",
|
||||
name="ProductMarketer",
|
||||
text=OpenAIResponsesAgent.configure_response_format(ReleaseBrief),
|
||||
text=OpenAIResponsesAgent.configure_response_format(ReleaseBrief), # type: ignore
|
||||
)
|
||||
response = await agent.get_response(
|
||||
"Draft a launch brief for the Contoso Note app.",
|
||||
|
||||
Reference in New Issue
Block a user