Python: Fixed SK migration samples (#4046)

* Fixed sk migration provider samples

* Fixes to SK migration samples
This commit is contained in:
Dmytro Struk
2026-02-18 12:20:21 -08:00
committed by GitHub
Unverified
parent aab80d9ed9
commit c23bc1371c
17 changed files with 96 additions and 101 deletions
@@ -14,24 +14,19 @@ import asyncio
async def run_semantic_kernel() -> None:
from azure.identity import AzureCliCredential
from semantic_kernel.agents import AzureResponsesAgent
from semantic_kernel.connectors.ai.open_ai import AzureOpenAISettings
from semantic_kernel.agents import OpenAIResponsesAgent
from semantic_kernel.connectors.ai.open_ai import OpenAISettings
credential = AzureCliCredential()
try:
client = AzureResponsesAgent.create_client(credential=credential)
# SK response agents wrap Azure OpenAI's hosted Responses API.
agent = AzureResponsesAgent(
ai_model_id=AzureOpenAISettings().responses_deployment_name,
client=client,
instructions="Answer in one concise sentence.",
name="Expert",
)
response = await agent.get_response("Why is the sky blue?")
print("[SK]", response.message.content)
finally:
await credential.close()
client = OpenAIResponsesAgent.create_client()
# SK response agents wrap OpenAI's hosted Responses API.
agent = OpenAIResponsesAgent(
ai_model_id=OpenAISettings().responses_model_id,
client=client,
instructions="Answer in one concise sentence.",
name="Expert",
)
response = await agent.get_response("Why is the sky blue?")
print("[SK]", response.message.content)
async def run_agent_framework() -> None:
@@ -14,9 +14,8 @@ import asyncio
async def run_semantic_kernel() -> None:
from azure.identity import AzureCliCredential
from semantic_kernel.agents import AzureResponsesAgent
from semantic_kernel.connectors.ai.open_ai import AzureOpenAISettings
from semantic_kernel.agents import OpenAIResponsesAgent
from semantic_kernel.connectors.ai.open_ai import OpenAISettings
from semantic_kernel.functions import kernel_function
class MathPlugin:
@@ -24,26 +23,22 @@ async def run_semantic_kernel() -> None:
def add(self, a: float, b: float) -> float:
return a + b
credential = AzureCliCredential()
try:
client = AzureResponsesAgent.create_client(credential=credential)
# Plugins advertise callable tools to the Responses agent.
agent = AzureResponsesAgent(
ai_model_id=AzureOpenAISettings().responses_deployment_name,
client=client,
instructions="Use the add tool when math is required.",
name="MathExpert",
plugins=[MathPlugin()],
)
response = await agent.get_response("Use add(41, 1) and explain the result.")
print("[SK]", response.message.content)
finally:
await credential.close()
client = OpenAIResponsesAgent.create_client()
# Plugins advertise callable tools to the Responses agent.
agent = OpenAIResponsesAgent(
ai_model_id=OpenAISettings().responses_model_id,
client=client,
instructions="Use the add tool when math is required.",
name="MathExpert",
plugins=[MathPlugin()],
)
response = await agent.get_response("Use add(41, 1) and explain the result.")
print("[SK]", response.message.content)
async def run_agent_framework() -> None:
from agent_framework import Agent
from agent_framework._tools import tool
from agent_framework import tool
from agent_framework.openai import OpenAIResponsesClient
@tool(name="add", description="Add two numbers")
@@ -22,28 +22,22 @@ class ReleaseBrief(BaseModel):
async def run_semantic_kernel() -> None:
from azure.identity import AzureCliCredential
from semantic_kernel.agents import AzureResponsesAgent
from semantic_kernel.connectors.ai.open_ai import AzureOpenAISettings
from semantic_kernel.agents import OpenAIResponsesAgent
from semantic_kernel.connectors.ai.open_ai import OpenAISettings
credential = AzureCliCredential()
try:
client = AzureResponsesAgent.create_client(credential=credential)
# response_format requests schema-constrained output from the model.
agent = AzureResponsesAgent(
ai_model_id=AzureOpenAISettings().responses_deployment_name,
client=client,
instructions="Return launch briefs as structured JSON.",
name="ProductMarketer",
text=AzureResponsesAgent.configure_response_format(ReleaseBrief),
)
response = await agent.get_response(
"Draft a launch brief for the Contoso Note app.",
response_format=ReleaseBrief,
)
print("[SK]", response.message.content)
finally:
await credential.close()
client = OpenAIResponsesAgent.create_client()
# response_format requests schema-constrained output from the model.
agent = OpenAIResponsesAgent(
ai_model_id=OpenAISettings().responses_model_id,
client=client,
instructions="Return launch briefs as structured JSON.",
name="ProductMarketer",
text=OpenAIResponsesAgent.configure_response_format(ReleaseBrief),
)
response = await agent.get_response(
"Draft a launch brief for the Contoso Note app.",
)
print("[SK]", response.message.content)
async def run_agent_framework() -> None: