mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: [BREAKING] Remove deprecated Python OpenAI/Azure AI surfaces (#4990)
* [BREAKING] Remove deprecated Python OpenAI/Azure AI surfaces Also clean up follow-on docs, environment guidance, package metadata, and lab test stability. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix deleted semantic-kernel sample links Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * improve foundry language * Fix A2A Foundry sample regression Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
a5eacbbe65
commit
3a49b1d6dd
@@ -9,6 +9,13 @@ concepts of **Agent Framework** one step at a time.
|
||||
pip install agent-framework --pre
|
||||
```
|
||||
|
||||
Set the required environment variables:
|
||||
|
||||
```bash
|
||||
export FOUNDRY_PROJECT_ENDPOINT="https://your-project-endpoint"
|
||||
export FOUNDRY_MODEL="gpt-4o" # optional, defaults to gpt-4o
|
||||
```
|
||||
|
||||
## Samples
|
||||
|
||||
| # | File | What you'll learn |
|
||||
|
||||
@@ -15,22 +15,19 @@ This folder contains examples for direct chat client usage patterns.
|
||||
`built_in_chat_clients.py` starts with:
|
||||
|
||||
```python
|
||||
asyncio.run(main("openai_chat"))
|
||||
asyncio.run(main("openai_responses"))
|
||||
```
|
||||
|
||||
Change the argument to pick a client:
|
||||
|
||||
- `openai_chat`
|
||||
- `openai_responses`
|
||||
- `openai_assistants`
|
||||
- `openai_chat_completion`
|
||||
- `anthropic`
|
||||
- `ollama`
|
||||
- `bedrock`
|
||||
- `azure_openai_chat`
|
||||
- `azure_openai_responses`
|
||||
- `azure_openai_responses_foundry`
|
||||
- `azure_openai_assistants`
|
||||
- `azure_ai_agent`
|
||||
- `azure_openai_chat_completion`
|
||||
- `foundry_chat`
|
||||
|
||||
Example:
|
||||
|
||||
@@ -42,22 +39,19 @@ uv run samples/02-agents/chat_client/built_in_chat_clients.py
|
||||
|
||||
Depending on the selected client, set the appropriate environment variables:
|
||||
|
||||
**For Azure clients:**
|
||||
**For Azure OpenAI clients (`azure_openai_responses` and `azure_openai_chat_completion`):**
|
||||
- `AZURE_OPENAI_ENDPOINT`: Your Azure OpenAI endpoint
|
||||
- `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME`: The name of your Azure OpenAI chat deployment
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME`: The name of your Azure OpenAI responses deployment
|
||||
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The Azure OpenAI deployment used by the sample
|
||||
- `AZURE_OPENAI_API_VERSION` (optional): Azure OpenAI API version override
|
||||
- `AZURE_OPENAI_API_KEY` (optional): Azure OpenAI API key if you are not using `AzureCliCredential`
|
||||
|
||||
**For Azure OpenAI Foundry responses client (`azure_openai_responses_foundry`):**
|
||||
- `AZURE_AI_PROJECT_ENDPOINT`: Your Azure AI project endpoint
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME`: The name of your Azure OpenAI responses deployment
|
||||
|
||||
**For Azure AI agent client (`azure_ai_agent`):**
|
||||
- `AZURE_AI_PROJECT_ENDPOINT`: Your Azure AI project endpoint
|
||||
- `AZURE_AI_MODEL_DEPLOYMENT_NAME`: The name of your model deployment (used by `azure_ai_agent`)
|
||||
**For Foundry client (`foundry_chat`):**
|
||||
- `FOUNDRY_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
|
||||
- `FOUNDRY_MODEL`: The Foundry deployment used by the sample
|
||||
|
||||
**For OpenAI clients:**
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key
|
||||
- `OPENAI_CHAT_MODEL`: The OpenAI model for `openai_chat` and `openai_assistants`
|
||||
- `OPENAI_CHAT_MODEL`: The OpenAI model for `openai_chat_completion`
|
||||
- `OPENAI_RESPONSES_MODEL`: The OpenAI model for `openai_responses`
|
||||
|
||||
**For Anthropic client (`anthropic`):**
|
||||
|
||||
@@ -6,13 +6,9 @@ from random import randint
|
||||
from typing import Annotated, Any, Literal
|
||||
|
||||
from agent_framework import Message, SupportsChatGetResponse, tool
|
||||
from agent_framework.azure import (
|
||||
AzureOpenAIAssistantsClient,
|
||||
)
|
||||
from agent_framework.foundry import FoundryChatClient
|
||||
from agent_framework.openai import OpenAIAssistantsClient
|
||||
from agent_framework.openai import OpenAIChatClient, OpenAIChatCompletionClient
|
||||
from azure.identity import AzureCliCredential
|
||||
from azure.identity.aio import AzureCliCredential as AsyncAzureCliCredential
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import Field
|
||||
|
||||
@@ -26,31 +22,25 @@ This sample demonstrates how to run the same prompt flow against different built
|
||||
chat clients using a single `get_client` factory.
|
||||
|
||||
Select one of these client names:
|
||||
- openai_chat
|
||||
- openai_responses
|
||||
- openai_assistants
|
||||
- openai_chat_completion
|
||||
- anthropic
|
||||
- ollama
|
||||
- bedrock
|
||||
- azure_openai_chat
|
||||
- azure_openai_responses
|
||||
- azure_openai_responses_foundry
|
||||
- azure_openai_assistants
|
||||
- azure_ai_agent
|
||||
- azure_openai_chat_completion
|
||||
- foundry_chat
|
||||
"""
|
||||
|
||||
ClientName = Literal[
|
||||
"openai_chat",
|
||||
"openai_responses",
|
||||
"openai_assistants",
|
||||
"openai_chat_completion",
|
||||
"anthropic",
|
||||
"ollama",
|
||||
"bedrock",
|
||||
"azure_openai_chat",
|
||||
"azure_openai_responses",
|
||||
"azure_openai_responses_foundry",
|
||||
"azure_openai_assistants",
|
||||
"azure_ai_agent",
|
||||
"azure_openai_chat_completion",
|
||||
"foundry_chat",
|
||||
]
|
||||
|
||||
|
||||
@@ -71,55 +61,41 @@ def get_client(client_name: ClientName) -> SupportsChatGetResponse[Any]:
|
||||
from agent_framework.amazon import BedrockChatClient
|
||||
from agent_framework.anthropic import AnthropicClient
|
||||
from agent_framework.ollama import OllamaChatClient
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
|
||||
# 1. Create OpenAI clients.
|
||||
if client_name == "openai_chat":
|
||||
return FoundryChatClient()
|
||||
if client_name == "openai_responses":
|
||||
return OpenAIResponsesClient()
|
||||
if client_name == "openai_assistants":
|
||||
return OpenAIAssistantsClient()
|
||||
return OpenAIChatClient()
|
||||
if client_name == "openai_chat_completion":
|
||||
return OpenAIChatCompletionClient()
|
||||
if client_name == "anthropic":
|
||||
return AnthropicClient()
|
||||
if client_name == "ollama":
|
||||
return OllamaChatClient()
|
||||
if client_name == "bedrock":
|
||||
return BedrockChatClient()
|
||||
|
||||
# 2. Create Azure OpenAI clients.
|
||||
if client_name == "azure_openai_chat":
|
||||
return FoundryChatClient(credential=AzureCliCredential())
|
||||
if client_name == "azure_openai_responses":
|
||||
return FoundryChatClient(credential=AzureCliCredential(), api_version="preview")
|
||||
if client_name == "azure_openai_responses_foundry":
|
||||
return OpenAIChatClient(credential=AzureCliCredential())
|
||||
if client_name == "azure_openai_chat_completion":
|
||||
return OpenAIChatCompletionClient(credential=AzureCliCredential())
|
||||
if client_name == "foundry_chat":
|
||||
return FoundryChatClient(
|
||||
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
|
||||
model=os.environ["FOUNDRY_MODEL"],
|
||||
credential=AzureCliCredential(),
|
||||
)
|
||||
if client_name == "azure_openai_assistants":
|
||||
return AzureOpenAIAssistantsClient(credential=AzureCliCredential())
|
||||
|
||||
# 3. Create Azure AI client.
|
||||
if client_name == "azure_ai_agent":
|
||||
return FoundryChatClient(credential=AsyncAzureCliCredential())
|
||||
|
||||
raise ValueError(f"Unsupported client name: {client_name}")
|
||||
|
||||
|
||||
async def main(client_name: ClientName = "openai_chat") -> None:
|
||||
async def main(client_name: ClientName = "openai_responses") -> None:
|
||||
"""Run a basic prompt using a selected built-in client."""
|
||||
client = get_client(client_name)
|
||||
|
||||
# 1. Configure prompt and streaming mode.
|
||||
message = Message("user", text="What's the weather in Amsterdam and in Paris?")
|
||||
stream = os.getenv("STREAM", "false").lower() == "true"
|
||||
print(f"Client: {client_name}")
|
||||
print(f"User: {message.text}")
|
||||
|
||||
# 2. Run with context-managed clients.
|
||||
if isinstance(client, OpenAIAssistantsClient | AzureOpenAIAssistantsClient | FoundryChatClient):
|
||||
if isinstance(client, FoundryChatClient):
|
||||
async with client:
|
||||
if stream:
|
||||
response_stream = client.get_response([message], stream=True, options={"tools": get_weather})
|
||||
@@ -134,7 +110,6 @@ async def main(client_name: ClientName = "openai_chat") -> None:
|
||||
)
|
||||
return
|
||||
|
||||
# 3. Run with non-context-managed clients.
|
||||
if stream:
|
||||
response_stream = client.get_response([message], stream=True, options={"tools": get_weather})
|
||||
print("Assistant: ", end="")
|
||||
@@ -147,7 +122,7 @@ async def main(client_name: ClientName = "openai_chat") -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main("openai_chat"))
|
||||
asyncio.run(main("openai_responses"))
|
||||
|
||||
|
||||
"""
|
||||
|
||||
@@ -49,14 +49,14 @@ Run `az login` if using Entra ID authentication.
|
||||
**Common (both modes):**
|
||||
- `AZURE_SEARCH_ENDPOINT`: Your Azure AI Search endpoint (e.g., `https://myservice.search.windows.net`)
|
||||
- `AZURE_SEARCH_INDEX_NAME`: Name of your search index
|
||||
- `AZURE_AI_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
|
||||
- `AZURE_AI_MODEL_DEPLOYMENT_NAME`: Model deployment name (e.g., `gpt-4o`, defaults to `gpt-4o`)
|
||||
- `FOUNDRY_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
|
||||
- `FOUNDRY_MODEL`: Model deployment name (e.g., `gpt-4o`, defaults to `gpt-4o`)
|
||||
- `AZURE_SEARCH_API_KEY`: _(Optional)_ Your search API key - if not provided, uses DefaultAzureCredential
|
||||
|
||||
**Agentic mode only:**
|
||||
- `AZURE_SEARCH_KNOWLEDGE_BASE_NAME`: Name of your Knowledge Base in Azure AI Search
|
||||
- `AZURE_OPENAI_RESOURCE_URL`: Your Azure OpenAI resource URL (e.g., `https://myresource.openai.azure.com`)
|
||||
- **Important**: This is different from `AZURE_AI_PROJECT_ENDPOINT` - Knowledge Base needs the OpenAI endpoint for model calls
|
||||
- **Important**: This is different from `FOUNDRY_PROJECT_ENDPOINT` - Knowledge Base needs the OpenAI endpoint for model calls
|
||||
|
||||
### Example .env file
|
||||
|
||||
@@ -64,8 +64,8 @@ Run `az login` if using Entra ID authentication.
|
||||
```env
|
||||
AZURE_SEARCH_ENDPOINT=https://myservice.search.windows.net
|
||||
AZURE_SEARCH_INDEX_NAME=my-index
|
||||
AZURE_AI_PROJECT_ENDPOINT=https://<resource-name>.services.ai.azure.com/api/projects/<project-name>
|
||||
AZURE_AI_MODEL_DEPLOYMENT_NAME=gpt-4o
|
||||
FOUNDRY_PROJECT_ENDPOINT=https://<resource-name>.services.ai.azure.com/api/projects/<project-name>
|
||||
FOUNDRY_MODEL=gpt-4o
|
||||
# Optional - omit to use Entra ID
|
||||
AZURE_SEARCH_API_KEY=your-search-key
|
||||
```
|
||||
@@ -127,7 +127,8 @@ AZURE_OPENAI_RESOURCE_URL=https://myresource.openai.azure.com
|
||||
|
||||
```python
|
||||
from agent_framework import Agent
|
||||
from agent_framework.azure import AzureAIAgentClient, AzureAISearchContextProvider
|
||||
from agent_framework.azure import AzureAISearchContextProvider
|
||||
from agent_framework.foundry import FoundryChatClient
|
||||
from azure.identity.aio import DefaultAzureCredential
|
||||
|
||||
# Create search provider with semantic mode (default)
|
||||
@@ -140,10 +141,13 @@ search_provider = AzureAISearchContextProvider(
|
||||
)
|
||||
|
||||
# Create agent with search context
|
||||
async with AzureAIAgentClient(credential=DefaultAzureCredential()) as client:
|
||||
async with FoundryChatClient(
|
||||
project_endpoint=project_endpoint,
|
||||
model=model_deployment,
|
||||
credential=DefaultAzureCredential(),
|
||||
) as client:
|
||||
async with Agent(
|
||||
client=client,
|
||||
model=model_deployment,
|
||||
context_providers=[search_provider],
|
||||
) as agent:
|
||||
response = await agent.run("What information is in the knowledge base?")
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ Environment variables:
|
||||
- AZURE_SEARCH_ENDPOINT: Your Azure AI Search endpoint
|
||||
- AZURE_SEARCH_API_KEY: (Optional) API key - if not provided, uses AzureCliCredential
|
||||
- FOUNDRY_PROJECT_ENDPOINT: Your Azure AI Foundry project endpoint
|
||||
- AZURE_AI_MODEL_DEPLOYMENT_NAME: Your model deployment name (e.g., "gpt-4o")
|
||||
- FOUNDRY_MODEL: Your model deployment name (e.g., "gpt-4o")
|
||||
|
||||
For using an existing Knowledge Base (recommended):
|
||||
- AZURE_SEARCH_KNOWLEDGE_BASE_NAME: Your Knowledge Base name
|
||||
@@ -59,7 +59,7 @@ async def main() -> None:
|
||||
search_endpoint = os.environ["AZURE_SEARCH_ENDPOINT"]
|
||||
search_key = os.environ.get("AZURE_SEARCH_API_KEY")
|
||||
project_endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]
|
||||
model_deployment = os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME", "gpt-4o")
|
||||
model_deployment = os.environ.get("FOUNDRY_MODEL", "gpt-4o")
|
||||
|
||||
# Agentic mode requires exactly ONE of: knowledge_base_name OR index_name
|
||||
# Option 1: Use existing Knowledge Base (recommended)
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ Prerequisites:
|
||||
- AZURE_SEARCH_API_KEY: (Optional) Your search API key - if not provided, uses AzureCliCredential for Entra ID
|
||||
- AZURE_SEARCH_INDEX_NAME: Your search index name
|
||||
- FOUNDRY_PROJECT_ENDPOINT: Your Azure AI Foundry project endpoint
|
||||
- AZURE_AI_MODEL_DEPLOYMENT_NAME: Your model deployment name (e.g., "gpt-4o")
|
||||
- FOUNDRY_MODEL: Your model deployment name (e.g., "gpt-4o")
|
||||
- AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME: (Optional) Your Azure OpenAI embedding deployment for hybrid search
|
||||
- AZURE_OPENAI_ENDPOINT: (Optional) Your Azure OpenAI resource URL, required if using Azure OpenAI embeddings
|
||||
"""
|
||||
@@ -54,7 +54,7 @@ async def main() -> None:
|
||||
search_key = os.environ.get("AZURE_SEARCH_API_KEY")
|
||||
index_name = os.environ["AZURE_SEARCH_INDEX_NAME"]
|
||||
project_endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]
|
||||
model_deployment = os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME", "gpt-4o")
|
||||
model_deployment = os.environ.get("FOUNDRY_MODEL", "gpt-4o")
|
||||
openai_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
|
||||
embedding_deployment = os.environ.get("AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME")
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ Set the following environment variables:
|
||||
- `OPENAI_API_KEY`: Your OpenAI API key (used by Mem0 OSS for embedding generation and automatic memory extraction)
|
||||
|
||||
**For Azure AI:**
|
||||
- `AZURE_AI_PROJECT_ENDPOINT`: Your Azure AI project endpoint
|
||||
- `AZURE_AI_MODEL_DEPLOYMENT_NAME`: The name of your model deployment
|
||||
- `FOUNDRY_PROJECT_ENDPOINT`: Your Azure AI project endpoint
|
||||
- `FOUNDRY_MODEL`: The name of your model deployment
|
||||
|
||||
## Key Concepts
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ See quickstart: `https://learn.microsoft.com/azure/redis/quickstart-create-manag
|
||||
|
||||
### Environment variables
|
||||
|
||||
- `AZURE_AI_PROJECT_ENDPOINT` (required): Azure AI Foundry project endpoint for `AzureOpenAIResponsesClient`
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME` (required): Azure OpenAI Responses deployment name
|
||||
- `FOUNDRY_PROJECT_ENDPOINT` (required): Azure AI Foundry project endpoint for `FoundryChatClient`
|
||||
- `FOUNDRY_MODEL` (required): Foundry model deployment name
|
||||
- `OPENAI_API_KEY` (optional): Required only if you set `vectorizer_choice="openai"` to enable hybrid search.
|
||||
|
||||
### Provider configuration highlights
|
||||
@@ -73,7 +73,7 @@ The provider supports both full‑text only and hybrid vector search:
|
||||
2. Agent integration: teaches the agent a preference and verifies it is remembered across turns.
|
||||
3. Agent + tool: calls a sample tool (flight search) and then asks the agent to recall details remembered from the tool output.
|
||||
|
||||
It uses `AzureOpenAIResponsesClient` (Foundry project endpoint setup) for chat and, in some steps, optional OpenAI embeddings for hybrid search.
|
||||
It uses `FoundryChatClient` for chat and, in some steps, optional OpenAI embeddings for hybrid search.
|
||||
|
||||
## How to run
|
||||
|
||||
@@ -82,8 +82,8 @@ It uses `AzureOpenAIResponsesClient` (Foundry project endpoint setup) for chat a
|
||||
2) Set Azure Foundry/OpenAI responses environment variables:
|
||||
|
||||
```bash
|
||||
export AZURE_AI_PROJECT_ENDPOINT="https://<resource>.services.ai.azure.com/api/projects/<project>"
|
||||
export AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME="<deployment-name>"
|
||||
export FOUNDRY_PROJECT_ENDPOINT="https://<resource>.services.ai.azure.com/api/projects/<project>"
|
||||
export FOUNDRY_MODEL="<deployment-name>"
|
||||
```
|
||||
|
||||
3) (Optional) Set your OpenAI key if using embeddings:
|
||||
@@ -119,6 +119,6 @@ You should see the agent responses and, when using embeddings, context retrieved
|
||||
## Troubleshooting
|
||||
|
||||
- Ensure at least one of `application_id`, `agent_id`, `user_id`, or `thread_id` is set; the provider requires a scope.
|
||||
- Verify `AZURE_AI_PROJECT_ENDPOINT` and `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME` are set for the chat client.
|
||||
- Verify `FOUNDRY_PROJECT_ENDPOINT` and `FOUNDRY_MODEL` are set for the chat client.
|
||||
- If using embeddings, verify `OPENAI_API_KEY` is set and reachable.
|
||||
- Make sure Redis exposes RediSearch (Redis Stack image or managed service with search enabled).
|
||||
|
||||
@@ -10,11 +10,11 @@ Key Features Demonstrated:
|
||||
1. Loading agent definitions from YAML using AgentFactory
|
||||
2. Configuring MCP tools with different authentication methods:
|
||||
- API key authentication (OpenAI.Responses provider)
|
||||
- Azure AI Foundry connection references (AzureAI.ProjectProvider)
|
||||
- Azure AI Foundry connection references (Foundry provider)
|
||||
|
||||
Authentication Options:
|
||||
- OpenAI.Responses: Supports inline API key auth via headers
|
||||
- AzureAI.ProjectProvider: Uses Foundry connections for secure credential storage
|
||||
- Foundry: Uses project-backed chat with Foundry connections for secure credential storage
|
||||
(no secrets passed in API calls - connection name references pre-configured auth)
|
||||
|
||||
Prerequisites:
|
||||
@@ -79,7 +79,7 @@ instructions: |
|
||||
|
||||
model:
|
||||
id: gpt-4o
|
||||
provider: AzureAI.ProjectProvider
|
||||
provider: Foundry
|
||||
|
||||
tools:
|
||||
- kind: mcp
|
||||
|
||||
@@ -55,15 +55,15 @@ agent_name/
|
||||
|
||||
| Sample | Description | Features | Required Environment Variables |
|
||||
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
||||
| [**weather_agent_azure/**](weather_agent_azure/) | Weather agent using Azure OpenAI with API key authentication | Azure OpenAI integration, function calling, mock weather tools | `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME`, `AZURE_OPENAI_ENDPOINT` |
|
||||
| [**foundry_agent/**](foundry_agent/) | Weather agent using Azure AI Agent (Foundry) with Azure CLI authentication (run `az login` first) | Azure AI Agent integration, Azure CLI authentication, mock weather tools | `AZURE_AI_PROJECT_ENDPOINT`, `FOUNDRY_MODEL_DEPLOYMENT_NAME` |
|
||||
| [**weather_agent_azure/**](weather_agent_azure/) | Weather agent using Azure OpenAI with API key authentication | Azure OpenAI integration, function calling, mock weather tools | `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_DEPLOYMENT_NAME`, `AZURE_OPENAI_ENDPOINT` |
|
||||
| [**foundry_agent/**](foundry_agent/) | Weather agent using Azure AI Agent (Foundry) with Azure CLI authentication (run `az login` first) | Azure AI Agent integration, Azure CLI authentication, mock weather tools | `FOUNDRY_PROJECT_ENDPOINT`, `FOUNDRY_MODEL` |
|
||||
|
||||
### Workflows
|
||||
|
||||
| Sample | Description | Features | Required Environment Variables |
|
||||
| -------------------------------------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
||||
| [**declarative/**](declarative/) | Declarative YAML workflow with conditional branching | YAML-based workflow definition, conditional logic, no Python code required | None - uses mock data |
|
||||
| [**workflow_agents/**](workflow_agents/) | Content review workflow with agents as executors | Agents as workflow nodes, conditional routing based on structured outputs, quality-based paths (Writer -> Reviewer -> Editor/Publisher) | `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME`, `AZURE_OPENAI_ENDPOINT` |
|
||||
| [**workflow_agents/**](workflow_agents/) | Content review workflow with agents as executors | Agents as workflow nodes, conditional routing based on structured outputs, quality-based paths (Writer -> Reviewer -> Editor/Publisher) | `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_DEPLOYMENT_NAME`, `AZURE_OPENAI_ENDPOINT` |
|
||||
| [**spam_workflow/**](spam_workflow/) | 5-step email spam detection workflow with branching logic | Sequential execution, conditional branching (spam vs. legitimate), multiple executors, mock spam detection | None - uses mock data |
|
||||
| [**fanout_workflow/**](fanout_workflow/) | Advanced data processing workflow with parallel execution | Fan-out/fan-in patterns, complex state management, multi-stage processing (validation -> transformation -> quality assurance) | None - uses mock data |
|
||||
|
||||
|
||||
@@ -12,4 +12,4 @@ AZURE_OPENAI_API_KEY=your-azure-openai-api-key-here
|
||||
AZURE_OPENAI_ENDPOINT=https://your-resource.cognitiveservices.azure.com/
|
||||
|
||||
# Required: Deployment name (must support Responses API)
|
||||
AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME=gpt-4.1-mini
|
||||
FOUNDRY_MODEL=gpt-4.1-mini
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# Get your credentials from Azure AI Foundry portal
|
||||
# Make sure to run 'az login' before starting devui
|
||||
|
||||
AZURE_AI_PROJECT_ENDPOINT=https://your-project.api.azureml.ms
|
||||
FOUNDRY_MODEL_DEPLOYMENT_NAME=gpt-4o
|
||||
FOUNDRY_PROJECT_ENDPOINT=https://your-project.api.azureml.ms
|
||||
FOUNDRY_MODEL=gpt-4o
|
||||
|
||||
@@ -53,7 +53,7 @@ agent = Agent(
|
||||
name="FoundryWeatherAgent",
|
||||
client=FoundryChatClient(
|
||||
project_endpoint=os.environ.get("FOUNDRY_PROJECT_ENDPOINT"),
|
||||
model_model=os.environ.get("FOUNDRY_MODEL_DEPLOYMENT_NAME"),
|
||||
model_model=os.environ.get("FOUNDRY_MODEL"),
|
||||
credential=AzureCliCredential(),
|
||||
),
|
||||
instructions="""
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# Get your credentials from Azure Portal
|
||||
|
||||
AZURE_OPENAI_API_KEY=your-azure-openai-api-key-here
|
||||
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4o
|
||||
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o
|
||||
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
# Get your credentials from Azure Portal
|
||||
|
||||
AZURE_OPENAI_API_KEY=your-azure-openai-api-key-here
|
||||
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4o
|
||||
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o
|
||||
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
|
||||
AZURE_OPENAI_API_VERSION=2024-10-21
|
||||
|
||||
@@ -22,7 +22,6 @@ from agent_framework import (
|
||||
evaluator,
|
||||
)
|
||||
|
||||
|
||||
# -- Custom evaluators that inspect multimodal content --
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ This folder contains focused middleware samples for `Agent`, chat clients, tools
|
||||
|
||||
## Running the usage tracking sample
|
||||
|
||||
The new usage tracking sample uses `OpenAIResponsesClient`, so set the usual OpenAI responses environment variables first:
|
||||
The new usage tracking sample uses `OpenAIChatClient`, so set the usual OpenAI responses environment variables first:
|
||||
|
||||
```bash
|
||||
export OPENAI_API_KEY="your-openai-api-key"
|
||||
|
||||
@@ -19,7 +19,7 @@ from agent_framework import (
|
||||
ResponseStream,
|
||||
tool,
|
||||
)
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import Field
|
||||
|
||||
@@ -190,7 +190,7 @@ async def main() -> None:
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = Agent(
|
||||
client=OpenAIResponsesClient(
|
||||
client=OpenAIChatClient(
|
||||
middleware=[validate_weather_middleware, weather_override_middleware],
|
||||
),
|
||||
name="WeatherAgent",
|
||||
|
||||
@@ -19,7 +19,7 @@ from agent_framework import (
|
||||
chat_middleware,
|
||||
tool,
|
||||
)
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import Field
|
||||
|
||||
@@ -53,7 +53,7 @@ def _reset_usage_counters() -> None:
|
||||
def _create_agent() -> Agent:
|
||||
"""Create the shared agent used by both demonstrations."""
|
||||
return Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
instructions=(
|
||||
"You are a weather assistant. Always call the weather tool before answering weather questions, "
|
||||
"then summarize the tool result in one short paragraph."
|
||||
|
||||
@@ -32,8 +32,8 @@ Set the following environment variables before running the examples:
|
||||
**For Azure OpenAI:**
|
||||
|
||||
- `AZURE_OPENAI_ENDPOINT`: Your Azure OpenAI endpoint
|
||||
- `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME`: The name of your Azure OpenAI chat model deployment
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME`: The name of your Azure OpenAI responses model deployment
|
||||
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The name of your Azure OpenAI chat model deployment
|
||||
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The name of your Azure OpenAI responses model deployment
|
||||
|
||||
Optionally for Azure OpenAI:
|
||||
- `AZURE_OPENAI_API_VERSION`: The API version to use (default is `2024-10-21`)
|
||||
@@ -41,11 +41,11 @@ Optionally for Azure OpenAI:
|
||||
|
||||
**Note:** You can also provide configuration directly in code instead of using environment variables:
|
||||
```python
|
||||
# Example: Pass deployment_name directly
|
||||
client = AzureOpenAIChatClient(
|
||||
# Example: Pass the Foundry project endpoint directly
|
||||
client = FoundryChatClient(
|
||||
credential=AzureCliCredential(),
|
||||
deployment_name="your-deployment-name",
|
||||
endpoint="https://your-resource.openai.azure.com"
|
||||
project_endpoint="https://your-project.services.ai.azure.com",
|
||||
model="your-deployment-name",
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -45,5 +45,5 @@ OPENAI_CHAT_MODEL="gpt-4o-2024-08-06"
|
||||
|
||||
# Azure AI Foundry specific variables
|
||||
# ====================================
|
||||
AZURE_AI_PROJECT_ENDPOINT="..."
|
||||
AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-4o-mini"
|
||||
FOUNDRY_PROJECT_ENDPOINT="..."
|
||||
FOUNDRY_MODEL="gpt-4o-mini"
|
||||
|
||||
@@ -33,7 +33,8 @@ This folder contains examples demonstrating how to use Anthropic's Claude models
|
||||
### Foundry
|
||||
|
||||
- `ANTHROPIC_FOUNDRY_API_KEY`: Your Foundry Anthropic API key
|
||||
- `ANTHROPIC_FOUNDRY_ENDPOINT`: The endpoint URL for your Foundry Anthropic resource
|
||||
- `ANTHROPIC_FOUNDRY_RESOURCE`: Your Foundry resource name (for example `my-foundry-resource`)
|
||||
- `ANTHROPIC_FOUNDRY_BASE_URL`: Optional full Foundry Anthropic base URL alternative to `ANTHROPIC_FOUNDRY_RESOURCE`
|
||||
- `ANTHROPIC_CHAT_MODEL_ID`: The Claude model to use in Foundry (e.g., `claude-haiku-4-5`)
|
||||
|
||||
### Claude Agent
|
||||
|
||||
@@ -22,8 +22,11 @@ This example requires `anthropic>=0.74.0` and an endpoint in Foundry for Anthrop
|
||||
To use the Foundry integration ensure you have the following environment variables set:
|
||||
- ANTHROPIC_FOUNDRY_API_KEY
|
||||
Alternatively you can pass in a azure_ad_token_provider function to the AsyncAnthropicFoundry constructor.
|
||||
- ANTHROPIC_FOUNDRY_ENDPOINT
|
||||
Should be something like https://<your-resource-name>.services.ai.azure.com/anthropic/
|
||||
- ANTHROPIC_FOUNDRY_RESOURCE
|
||||
Should be the resource name portion of your Foundry Anthropic URL, such as <your-resource-name>.
|
||||
- ANTHROPIC_FOUNDRY_BASE_URL
|
||||
Optional alternative to ANTHROPIC_FOUNDRY_RESOURCE. Should be something like
|
||||
https://<your-resource-name>.services.ai.azure.com/anthropic/
|
||||
- ANTHROPIC_CHAT_MODEL_ID
|
||||
Should be something like claude-haiku-4-5
|
||||
"""
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ async def main() -> None:
|
||||
# authentication option.
|
||||
agent = Agent(
|
||||
client=OpenAIChatCompletionClient(
|
||||
model=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"],
|
||||
model=os.environ["AZURE_OPENAI_DEPLOYMENT_NAME"],
|
||||
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
|
||||
credential=AzureCliCredential(),
|
||||
),
|
||||
|
||||
@@ -27,7 +27,7 @@ Both approaches allow you to extend the framework for your specific use cases wh
|
||||
|
||||
## Understanding Raw Client Classes
|
||||
|
||||
The framework provides `Raw...Client` classes (e.g., `RawOpenAIChatClient`, `RawOpenAIChatCompletionClient`, `RawAzureAIClient`) that are intermediate implementations without middleware, telemetry, or function invocation support.
|
||||
The framework provides `Raw...Client` classes (e.g., `RawOpenAIChatClient`, `RawOpenAIChatCompletionClient`, `RawFoundryChatClient`) that are intermediate implementations without middleware, telemetry, or function invocation support.
|
||||
|
||||
### Warning: Raw Clients Should Not Normally Be Used Directly
|
||||
|
||||
@@ -62,8 +62,8 @@ For most use cases, use the fully-featured public client classes which already h
|
||||
|
||||
- `OpenAIChatCompletionClient` - OpenAI Chat Completions API with all layers
|
||||
- `OpenAIChatClient` - OpenAI Responses API with all layers
|
||||
- `AzureOpenAIChatClient` - Azure OpenAI Chat with all layers
|
||||
- `AzureOpenAIResponsesClient` - Azure OpenAI Responses with all layers
|
||||
- `AzureAIClient` - Azure AI Project with all layers
|
||||
- `OpenAIChatCompletionClient` - Azure OpenAI Chat Completions with all layers
|
||||
- `OpenAIChatClient` - Azure OpenAI Responses with all layers
|
||||
- `FoundryChatClient` - Azure AI Foundry project-backed chat with all layers
|
||||
|
||||
These clients handle the layer composition correctly and provide the full feature set out of the box.
|
||||
|
||||
@@ -27,8 +27,8 @@ code_defined_skill/
|
||||
|
||||
Set the required environment variables in a `.env` file (see `python/.env.example`):
|
||||
|
||||
- `AZURE_AI_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME`: The name of your model deployment (defaults to `gpt-4o-mini`)
|
||||
- `FOUNDRY_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
|
||||
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The name of your model deployment (defaults to `gpt-4o-mini`)
|
||||
|
||||
### Authentication
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ file_based_skill/
|
||||
|
||||
Set the required environment variables in a `.env` file (see `python/.env.example`):
|
||||
|
||||
- `AZURE_AI_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME`: The name of your model deployment (defaults to `gpt-4o-mini`)
|
||||
- `FOUNDRY_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
|
||||
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The name of your model deployment (defaults to `gpt-4o-mini`)
|
||||
|
||||
### Authentication
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ File scripts are executed as **local Python subprocesses** via the
|
||||
Set environment variables (or create a `.env` file):
|
||||
|
||||
```
|
||||
AZURE_AI_PROJECT_ENDPOINT=https://your-project.openai.azure.com/
|
||||
AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME=gpt-4o-mini
|
||||
FOUNDRY_PROJECT_ENDPOINT=https://your-project.openai.azure.com/
|
||||
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o-mini
|
||||
```
|
||||
|
||||
Authenticate with Azure CLI:
|
||||
|
||||
@@ -28,8 +28,8 @@ When `require_script_approval=True` is set, the agent pauses before executing an
|
||||
|
||||
Set the required environment variables in a `.env` file (see `python/.env.example`):
|
||||
|
||||
- `AZURE_AI_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME`: The name of your model deployment (defaults to `gpt-4o-mini`)
|
||||
- `FOUNDRY_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
|
||||
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The name of your model deployment (defaults to `gpt-4o-mini`)
|
||||
|
||||
### Authentication
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import asyncio
|
||||
from typing import Annotated
|
||||
|
||||
from agent_framework import Agent, tool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
@@ -28,7 +28,7 @@ def add(
|
||||
|
||||
|
||||
async def main():
|
||||
client = OpenAIResponsesClient()
|
||||
client = OpenAIChatClient()
|
||||
client.function_invocation_configuration["include_detailed_errors"] = True
|
||||
client.function_invocation_configuration["max_iterations"] = 40
|
||||
print(f"Function invocation configured as: \n{client.function_invocation_configuration}")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import asyncio
|
||||
|
||||
from agent_framework import Agent, FunctionTool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
@@ -26,7 +26,7 @@ async def main():
|
||||
)
|
||||
|
||||
agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
name="DeclarationOnlyToolAgent",
|
||||
instructions="You are a helpful agent that uses tools.",
|
||||
tools=function_declaration,
|
||||
|
||||
@@ -22,7 +22,7 @@ Usage:
|
||||
import asyncio
|
||||
|
||||
from agent_framework import Agent, FunctionTool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
@@ -62,7 +62,7 @@ async def main() -> None:
|
||||
tool = FunctionTool.from_dict(definition, dependencies={"function_tool": {"name:add_numbers": {"func": func}}})
|
||||
|
||||
agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
name="FunctionToolAgent",
|
||||
instructions="You are a helpful assistant.",
|
||||
tools=tool,
|
||||
|
||||
@@ -18,7 +18,7 @@ import asyncio
|
||||
from typing import Annotated
|
||||
|
||||
from agent_framework import Agent, tool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
@@ -70,7 +70,7 @@ def get_current_time(timezone: str = "UTC") -> str:
|
||||
|
||||
async def main():
|
||||
agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
name="AssistantAgent",
|
||||
instructions="You are a helpful assistant. Use the available tools to answer questions.",
|
||||
tools=[get_weather, get_current_time],
|
||||
|
||||
@@ -4,7 +4,7 @@ import asyncio
|
||||
from typing import Annotated
|
||||
|
||||
from agent_framework import Agent, FunctionInvocationContext, tool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import Field
|
||||
|
||||
@@ -44,7 +44,7 @@ def get_weather(
|
||||
|
||||
async def main() -> None:
|
||||
agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
name="WeatherAgent",
|
||||
instructions="You are a helpful weather assistant.",
|
||||
tools=[get_weather],
|
||||
|
||||
@@ -4,7 +4,7 @@ import asyncio
|
||||
from typing import Annotated
|
||||
|
||||
from agent_framework import Agent, tool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
@@ -36,7 +36,7 @@ def safe_divide(
|
||||
async def main():
|
||||
# tools = Tools()
|
||||
agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
name="ToolAgent",
|
||||
instructions="Use the provided tools.",
|
||||
tools=[safe_divide],
|
||||
|
||||
@@ -4,7 +4,7 @@ import asyncio
|
||||
from typing import Annotated
|
||||
|
||||
from agent_framework import Agent, tool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
@@ -25,7 +25,7 @@ def unicorn_function(times: Annotated[int, "The number of unicorns to return."])
|
||||
async def main():
|
||||
# tools = Tools()
|
||||
agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
name="ToolAgent",
|
||||
instructions="Use the provided tools.",
|
||||
tools=[unicorn_function],
|
||||
|
||||
@@ -4,7 +4,7 @@ import asyncio
|
||||
from typing import Annotated
|
||||
|
||||
from agent_framework import Agent, AgentSession, FunctionInvocationContext, tool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import Field
|
||||
|
||||
@@ -37,7 +37,7 @@ async def get_weather(
|
||||
|
||||
async def main() -> None:
|
||||
agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
name="WeatherAgent",
|
||||
instructions="You are a helpful weather assistant.",
|
||||
tools=[get_weather],
|
||||
|
||||
@@ -4,7 +4,7 @@ import asyncio
|
||||
from typing import Annotated
|
||||
|
||||
from agent_framework import Agent, tool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
@@ -50,7 +50,7 @@ async def main():
|
||||
add_function = tool(description="Add two numbers.")(tools.add)
|
||||
|
||||
agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
name="ToolAgent",
|
||||
instructions="Use the provided tools.",
|
||||
)
|
||||
|
||||
@@ -160,17 +160,17 @@ Sequential orchestration uses a few small adapter nodes for plumbing:
|
||||
These may appear in event streams (executor_invoked/executor_completed). They're analogous to
|
||||
concurrent’s dispatcher and aggregator and can be ignored if you only care about agent activity.
|
||||
|
||||
### AzureOpenAIResponsesClient vs AzureAIAgent
|
||||
### Why FoundryChatClient?
|
||||
|
||||
Workflow and orchestration samples use `AzureOpenAIResponsesClient` rather than the CRUD-style `AzureAIAgent` client. The key difference:
|
||||
Workflow and orchestration samples use `FoundryChatClient` because they create agents locally and do not need
|
||||
server-managed agent resources. This lightweight, project-backed chat client is a good fit for orchestration
|
||||
patterns such as Sequential, Concurrent, Handoff, GroupChat, and Magentic.
|
||||
|
||||
- **`AzureOpenAIResponsesClient`** — A lightweight client that uses the underlying Agent Service V2 (Responses API) for non-CRUD-style agents. Orchestrations use this client because agents are created locally and do not require server-side lifecycle management (create/update/delete). This is the recommended client for orchestration patterns (Sequential, Concurrent, Handoff, GroupChat, Magentic).
|
||||
|
||||
- **`AzureAIAgent`** — A CRUD-style client for server-managed agents. Use this when you need persistent, server-side agent definitions with features like file search, code interpreter sessions, or thread management provided by the Azure AI Agent Service.
|
||||
If you need persistent server-side agent resources, use the hosted-agent flows rather than these workflow samples.
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Workflow samples that use `AzureOpenAIResponsesClient` expect:
|
||||
Workflow samples that use `FoundryChatClient` expect:
|
||||
|
||||
- `FOUNDRY_PROJECT_ENDPOINT` (Azure AI Foundry Agent Service (V2) project endpoint)
|
||||
- `FOUNDRY_MODEL` (model deployment name)
|
||||
|
||||
@@ -6,7 +6,7 @@ This sample demonstrates an agent with function tools responding to user queries
|
||||
|
||||
The workflow showcases:
|
||||
- **Function Tools**: Agent equipped with tools to query menu data
|
||||
- **Real Azure OpenAI Agent**: Uses `AzureOpenAIResponsesClient` to create an agent with tools
|
||||
- **Real Foundry-backed agent**: Uses `FoundryChatClient` to create an agent with tools
|
||||
- **Agent Registration**: Shows how to register agents with the `WorkflowFactory`
|
||||
|
||||
## Tools
|
||||
@@ -37,7 +37,7 @@ Drinks:
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Azure OpenAI configured with required environment variables
|
||||
- Microsoft Foundry configured with required environment variables
|
||||
- Authentication via azure-identity (run `az login` before executing)
|
||||
|
||||
## Usage
|
||||
@@ -65,16 +65,16 @@ Session Complete
|
||||
|
||||
## How It Works
|
||||
|
||||
1. Create an Azure OpenAI chat client
|
||||
1. Create a Foundry chat client
|
||||
2. Create an agent with instructions and function tools
|
||||
3. Register the agent with the workflow factory
|
||||
4. Load the workflow YAML and run it with `run()` and `stream=True`
|
||||
|
||||
```python
|
||||
# Create the agent with tools
|
||||
client = AzureOpenAIResponsesClient(
|
||||
project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
|
||||
deployment_name=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
|
||||
client = FoundryChatClient(
|
||||
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
|
||||
model=os.environ["FOUNDRY_MODEL"],
|
||||
credential=AzureCliCredential(),
|
||||
)
|
||||
menu_agent = client.as_agent(
|
||||
|
||||
@@ -92,15 +92,17 @@ from agent_framework.orchestrations import (
|
||||
|
||||
These may appear in event streams (executor_invoked/executor_completed). They're analogous to concurrent's dispatcher and aggregator and can be ignored if you only care about agent activity.
|
||||
|
||||
## Why AzureOpenAIResponsesClient?
|
||||
## Why FoundryChatClient?
|
||||
|
||||
Orchestration samples use `AzureOpenAIResponsesClient` rather than the CRUD-style `AzureAIAgent` client. Orchestrations create agents locally and do not require server-side lifecycle management (create/update/delete). `AzureOpenAIResponsesClient` is a lightweight client that uses the underlying Agent Service V2 (Responses API) for non-CRUD-style agents, which is ideal for orchestration patterns like Sequential, Concurrent, Handoff, GroupChat, and Magentic.
|
||||
Orchestration samples use `FoundryChatClient` because they create agents locally and do not require
|
||||
server-side lifecycle management. `FoundryChatClient` is a lightweight, project-backed client that fits
|
||||
patterns like Sequential, Concurrent, Handoff, GroupChat, and Magentic.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Orchestration samples that use `AzureOpenAIResponsesClient` expect:
|
||||
Orchestration samples that use `FoundryChatClient` expect:
|
||||
|
||||
- `AZURE_AI_PROJECT_ENDPOINT` (Azure AI Foundry Agent Service (V2) project endpoint)
|
||||
- `AZURE_AI_MODEL_DEPLOYMENT_NAME` (model deployment name)
|
||||
- `FOUNDRY_PROJECT_ENDPOINT` (Azure AI Foundry Agent Service (V2) project endpoint)
|
||||
- `FOUNDRY_MODEL` (model deployment name)
|
||||
|
||||
These values are passed directly into the client constructor via `os.getenv()` in sample code.
|
||||
|
||||
@@ -22,16 +22,16 @@ The remaining files are supporting modules used by the server:
|
||||
Make sure to set the following environment variables before running the examples:
|
||||
|
||||
### Required (Server)
|
||||
- `AZURE_AI_PROJECT_ENDPOINT` — Your Azure AI Foundry project endpoint
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME` — Model deployment name (e.g. `gpt-4o`)
|
||||
- `FOUNDRY_PROJECT_ENDPOINT` — Your Azure AI Foundry project endpoint
|
||||
- `FOUNDRY_MODEL` — Model deployment name (e.g. `gpt-4o`)
|
||||
|
||||
### Required (Client)
|
||||
- `A2A_AGENT_HOST` — URL of the A2A server (e.g. `http://localhost:5001/`)
|
||||
|
||||
### Required (Function Tools Sample)
|
||||
- `A2A_AGENT_HOST` — URL of the A2A server (e.g. `http://localhost:5000/`)
|
||||
- `AZURE_AI_PROJECT_ENDPOINT` — Your Azure AI Foundry project endpoint
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME` — Model deployment name (e.g. `gpt-4o`)
|
||||
- `FOUNDRY_PROJECT_ENDPOINT` — Your Azure AI Foundry project endpoint
|
||||
- `FOUNDRY_MODEL` — Model deployment name (e.g. `gpt-4o`)
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -65,7 +65,7 @@ uv run python agent_with_a2a.py
|
||||
### 3. Run the Function Tools Sample
|
||||
|
||||
This sample resolves the remote agent's skills and registers each one as a function tool
|
||||
on a host OpenAI-powered agent. The host agent then autonomously selects the right skill
|
||||
on a host Foundry-backed agent. The host agent then autonomously selects the right skill
|
||||
to handle the user's request.
|
||||
|
||||
```powershell
|
||||
|
||||
@@ -7,7 +7,7 @@ import re
|
||||
import httpx
|
||||
from a2a.client import A2ACardResolver
|
||||
from agent_framework.a2a import A2AAgent
|
||||
from agent_framework.azure import AzureOpenAIResponsesClient
|
||||
from agent_framework.foundry import FoundryChatClient
|
||||
from azure.identity import AzureCliCredential
|
||||
from dotenv import load_dotenv
|
||||
|
||||
@@ -29,8 +29,8 @@ Key concepts demonstrated:
|
||||
|
||||
Prerequisites:
|
||||
- Set A2A_AGENT_HOST to the URL of a running A2A server
|
||||
- Set AZURE_AI_PROJECT_ENDPOINT to your Azure AI Foundry project endpoint
|
||||
- Set AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME to the model deployment name (e.g. gpt-4o)
|
||||
- Set FOUNDRY_PROJECT_ENDPOINT to your Azure AI Foundry project endpoint
|
||||
- Set FOUNDRY_MODEL to the model deployment name (e.g. gpt-4o)
|
||||
|
||||
To run this sample:
|
||||
cd python/samples/04-hosting/a2a
|
||||
@@ -45,11 +45,11 @@ async def main() -> None:
|
||||
if not a2a_agent_host:
|
||||
raise ValueError("A2A_AGENT_HOST environment variable is not set")
|
||||
|
||||
project_endpoint = os.getenv("AZURE_AI_PROJECT_ENDPOINT")
|
||||
deployment_name = os.getenv("AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME")
|
||||
if not project_endpoint or not deployment_name:
|
||||
project_endpoint = os.getenv("FOUNDRY_PROJECT_ENDPOINT")
|
||||
model = os.getenv("FOUNDRY_MODEL")
|
||||
if not project_endpoint or not model:
|
||||
raise ValueError(
|
||||
"AZURE_AI_PROJECT_ENDPOINT and AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME must be set"
|
||||
"FOUNDRY_PROJECT_ENDPOINT and FOUNDRY_MODEL must be set"
|
||||
)
|
||||
|
||||
print(f"Connecting to A2A agent at: {a2a_agent_host}")
|
||||
@@ -83,9 +83,9 @@ async def main() -> None:
|
||||
|
||||
# 5. Create the host agent with the skill tools.
|
||||
credential = AzureCliCredential()
|
||||
client = AzureOpenAIResponsesClient(
|
||||
client = FoundryChatClient(
|
||||
project_endpoint=project_endpoint,
|
||||
deployment_name=deployment_name,
|
||||
model=model,
|
||||
credential=credential,
|
||||
)
|
||||
host_agent = client.as_agent(
|
||||
|
||||
@@ -138,23 +138,35 @@ Expected response:
|
||||
The sample shows how to enable MCP tool triggers with flexible agent configuration:
|
||||
|
||||
```python
|
||||
from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient
|
||||
import os
|
||||
|
||||
# Create Azure OpenAI Chat Client
|
||||
client = AzureOpenAIChatClient()
|
||||
from agent_framework import Agent
|
||||
from agent_framework.azure import AgentFunctionApp
|
||||
from agent_framework.foundry import FoundryChatClient
|
||||
from azure.identity.aio import AzureCliCredential
|
||||
|
||||
# Create Foundry chat client
|
||||
client = FoundryChatClient(
|
||||
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
|
||||
model=os.environ["FOUNDRY_MODEL"],
|
||||
credential=AzureCliCredential(),
|
||||
)
|
||||
|
||||
# Define agents with different roles
|
||||
joker_agent = client.as_agent(
|
||||
joker_agent = Agent(
|
||||
client=client,
|
||||
name="Joker",
|
||||
instructions="You are good at telling jokes.",
|
||||
)
|
||||
|
||||
stock_agent = client.as_agent(
|
||||
stock_agent = Agent(
|
||||
client=client,
|
||||
name="StockAdvisor",
|
||||
instructions="Check stock prices.",
|
||||
)
|
||||
|
||||
plant_agent = client.as_agent(
|
||||
plant_agent = Agent(
|
||||
client=client,
|
||||
name="PlantAdvisor",
|
||||
instructions="Recommend plants.",
|
||||
description="Get plant recommendations.",
|
||||
|
||||
@@ -27,8 +27,8 @@ The backend uses Azure OpenAI responses and supports intent-driven, non-linear h
|
||||
- Node.js 18+
|
||||
- npm 9+
|
||||
- Azure AI project + model deployment configured in environment variables:
|
||||
- `AZURE_AI_PROJECT_ENDPOINT`
|
||||
- `AZURE_AI_MODEL_DEPLOYMENT_NAME`
|
||||
- `FOUNDRY_PROJECT_ENDPOINT`
|
||||
- `FOUNDRY_MODEL`
|
||||
|
||||
## 1) Run Backend
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ def create_agents() -> tuple[Agent, Agent, Agent]:
|
||||
|
||||
client = FoundryChatClient(
|
||||
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
|
||||
model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
|
||||
model=os.environ["FOUNDRY_MODEL"],
|
||||
credential=AzureCliCredential(),
|
||||
)
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ pip install agent-framework-chatkit fastapi uvicorn azure-identity
|
||||
```bash
|
||||
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
|
||||
export AZURE_OPENAI_API_VERSION="2024-06-01"
|
||||
export AZURE_OPENAI_CHAT_DEPLOYMENT_NAME="gpt-4o"
|
||||
export AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o"
|
||||
```
|
||||
|
||||
3. **Authenticate with Azure:**
|
||||
|
||||
@@ -5,4 +5,4 @@ AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o
|
||||
|
||||
# Azure AI Project Configuration (for red teaming)
|
||||
# Create these resources at: https://portal.azure.com
|
||||
AZURE_AI_PROJECT_ENDPOINT=your-ai-project-name
|
||||
FOUNDRY_PROJECT_ENDPOINT=your-ai-project-name
|
||||
|
||||
@@ -11,7 +11,7 @@ For more details on the Red Team setup see [the Azure AI Foundry docs](https://l
|
||||
A focused sample demonstrating Azure AI's RedTeam functionality to assess the safety and resilience of Agent Framework agents against adversarial attacks.
|
||||
|
||||
**What it demonstrates:**
|
||||
1. Creating a financial advisor agent inline using `AzureOpenAIChatClient`
|
||||
1. Creating a financial advisor agent inline using `FoundryChatClient`
|
||||
2. Setting up an async callback to interface the agent with RedTeam evaluator
|
||||
3. Running comprehensive evaluations with 11 different attack strategies:
|
||||
- Basic: EASY and MODERATE difficulty levels
|
||||
@@ -47,7 +47,7 @@ AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o
|
||||
# AZURE_OPENAI_API_KEY is optional if using Azure CLI authentication
|
||||
|
||||
# Azure AI Project (for red teaming)
|
||||
AZURE_AI_PROJECT_ENDPOINT=https://your-project.api.azureml.ms
|
||||
FOUNDRY_PROJECT_ENDPOINT=https://your-project.api.azureml.ms
|
||||
```
|
||||
|
||||
See `.env.example` for a template.
|
||||
@@ -113,7 +113,7 @@ async def main() -> None:
|
||||
credential = AzureCliCredential()
|
||||
|
||||
# 2. Create agent inline
|
||||
agent = AzureOpenAIChatClient(credential=credential).as_agent(
|
||||
agent = FoundryChatClient(credential=credential).as_agent(
|
||||
model="gpt-4o",
|
||||
instructions="You are a helpful financial advisor..."
|
||||
)
|
||||
@@ -125,7 +125,7 @@ async def main() -> None:
|
||||
|
||||
# 4. Run red team scan with multiple strategies
|
||||
red_team = RedTeam(
|
||||
azure_ai_project=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
|
||||
azure_ai_project=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
|
||||
credential=credential
|
||||
)
|
||||
results = await red_team.scan(
|
||||
|
||||
@@ -10,7 +10,7 @@ These samples demonstrate how to build and host AI agents in Python using the [A
|
||||
| [`agent_with_text_search_rag`](./agent_with_text_search_rag/) | Retrieval-augmented generation using a custom `BaseContextProvider` with Contoso Outdoors sample data |
|
||||
| [`agents_in_workflow`](./agents_in_workflow/) | Concurrent workflow that combines researcher, marketer, and legal specialist agents |
|
||||
| [`agent_with_local_tools`](./agent_with_local_tools/) | Local Python tool execution for Seattle hotel search |
|
||||
| [`writer_reviewer_agents_in_workflow`](./writer_reviewer_agents_in_workflow/) | Writer/Reviewer workflow using `AzureOpenAIResponsesClient` |
|
||||
| [`writer_reviewer_agents_in_workflow`](./writer_reviewer_agents_in_workflow/) | Writer/Reviewer workflow using `FoundryChatClient` |
|
||||
|
||||
## Common Prerequisites
|
||||
|
||||
@@ -76,14 +76,14 @@ Example `.env` for Azure OpenAI samples:
|
||||
|
||||
```dotenv
|
||||
AZURE_OPENAI_ENDPOINT=https://<your-openai-resource>.openai.azure.com/
|
||||
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4.1
|
||||
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4.1
|
||||
```
|
||||
|
||||
Example `.env` for Foundry project samples:
|
||||
|
||||
```dotenv
|
||||
PROJECT_ENDPOINT=https://<your-resource>.services.ai.azure.com/api/projects/<your-project>
|
||||
MODEL_DEPLOYMENT_NAME=gpt-4.1
|
||||
FOUNDRY_PROJECT_ENDPOINT=https://<your-resource>.services.ai.azure.com/api/projects/<your-project>
|
||||
FOUNDRY_MODEL=gpt-4.1
|
||||
```
|
||||
|
||||
## Interacting with the Agent
|
||||
|
||||
@@ -22,7 +22,7 @@ template:
|
||||
environment_variables:
|
||||
- name: AZURE_OPENAI_ENDPOINT
|
||||
value: ${AZURE_OPENAI_ENDPOINT}
|
||||
- name: AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
|
||||
- name: AZURE_OPENAI_DEPLOYMENT_NAME
|
||||
value: "{{chat}}"
|
||||
resources:
|
||||
- kind: model
|
||||
|
||||
@@ -25,7 +25,7 @@ template:
|
||||
environment_variables:
|
||||
- name: AZURE_OPENAI_ENDPOINT
|
||||
value: ${AZURE_OPENAI_ENDPOINT}
|
||||
- name: AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
|
||||
- name: AZURE_OPENAI_DEPLOYMENT_NAME
|
||||
value: "{{chat}}"
|
||||
resources:
|
||||
- kind: model
|
||||
|
||||
@@ -20,7 +20,7 @@ template:
|
||||
environment_variables:
|
||||
- name: AZURE_OPENAI_ENDPOINT
|
||||
value: ${AZURE_OPENAI_ENDPOINT}
|
||||
- name: AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
|
||||
- name: AZURE_OPENAI_DEPLOYMENT_NAME
|
||||
value: "{{chat}}"
|
||||
resources:
|
||||
- kind: model
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
AZURE_AI_PROJECT_ENDPOINT="<your-project-endpoint>"
|
||||
AZURE_AI_MODEL_DEPLOYMENT_NAME_WORKFLOW="<your-model-deployment>"
|
||||
AZURE_AI_MODEL_DEPLOYMENT_NAME_EVAL="<your-model-deployment>"
|
||||
FOUNDRY_PROJECT_ENDPOINT="<your-project-endpoint>"
|
||||
FOUNDRY_MODEL_WORKFLOW="<your-model-deployment>"
|
||||
FOUNDRY_MODEL_EVAL="<your-model-deployment>"
|
||||
|
||||
@@ -99,7 +99,7 @@ def fetch_agent_responses(openai_client: OpenAI, workflow_data: dict[str, Any],
|
||||
|
||||
def create_evaluation(openai_client: OpenAI, deployment_name: str | None = "gpt-5.2") -> EvalCreateResponse:
|
||||
"""Create evaluation with multiple evaluators."""
|
||||
deployment_name = os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME", deployment_name)
|
||||
deployment_name = os.environ.get("FOUNDRY_MODEL", deployment_name)
|
||||
data_source_config = {"type": "azure_ai_source", "scenario": "responses"}
|
||||
|
||||
testing_criteria = [
|
||||
@@ -199,8 +199,8 @@ async def main():
|
||||
openai_client = create_openai_client()
|
||||
|
||||
# Model configuration
|
||||
workflow_agent_model = os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME_WORKFLOW", "gpt-4.1-nano")
|
||||
eval_model = os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME_EVAL", "gpt-5.2")
|
||||
workflow_agent_model = os.environ.get("FOUNDRY_MODEL_WORKFLOW", "gpt-4.1-nano")
|
||||
eval_model = os.environ.get("FOUNDRY_MODEL_EVAL", "gpt-5.2")
|
||||
|
||||
# Focus on these agents, uncomment other ones you want to have evals run on
|
||||
agents_to_evaluate = [
|
||||
|
||||
@@ -66,26 +66,26 @@ python/samples/
|
||||
|
||||
## Default provider
|
||||
|
||||
All canonical samples (01-get-started) use **Azure OpenAI Responses** via `AzureOpenAIResponsesClient`
|
||||
All canonical samples (01-get-started) use **Azure AI Foundry project-backed chat** via `FoundryChatClient`
|
||||
with an Azure AI Foundry project endpoint:
|
||||
|
||||
```python
|
||||
import os
|
||||
from agent_framework.azure import AzureOpenAIResponsesClient
|
||||
from agent_framework.foundry import FoundryChatClient
|
||||
from azure.identity import AzureCliCredential
|
||||
|
||||
credential = AzureCliCredential()
|
||||
client = AzureOpenAIResponsesClient(
|
||||
project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
|
||||
deployment_name=os.environ["AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"],
|
||||
client = FoundryChatClient(
|
||||
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
|
||||
model=os.environ["FOUNDRY_MODEL"],
|
||||
credential=credential,
|
||||
)
|
||||
agent = client.as_agent(name="...", instructions="...")
|
||||
```
|
||||
|
||||
Environment variables:
|
||||
- `AZURE_AI_PROJECT_ENDPOINT` — Your Azure AI Foundry project endpoint
|
||||
- `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME` — Model deployment name (e.g. gpt-4o)
|
||||
- `FOUNDRY_PROJECT_ENDPOINT` — Your Azure AI Foundry project endpoint
|
||||
- `FOUNDRY_MODEL` — Model deployment name (e.g. gpt-4o)
|
||||
|
||||
For authentication, run `az login` before running samples.
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ export FOUNDRY_MODEL="gpt-4o"
|
||||
|
||||
**Option 3: Using `env_file_path` parameter** (for per-client configuration):
|
||||
|
||||
All client classes (e.g., `OpenAIChatClient`, `AzureOpenAIResponsesClient`) support an `env_file_path` parameter to load environment variables from a specific file:
|
||||
All client classes (e.g., `OpenAIChatClient`, `OpenAIChatCompletionClient`) support an `env_file_path` parameter to load environment variables from a specific file:
|
||||
|
||||
```python
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
@@ -77,6 +77,92 @@ FOUNDRY_PROJECT_ENDPOINT="your-foundry-project-endpoint"
|
||||
FOUNDRY_MODEL="gpt-4o"
|
||||
```
|
||||
|
||||
#### Consolidated sample env inventory
|
||||
|
||||
This is the single source of truth for package-level environment variables read by packages included by
|
||||
`agent-framework-core[all]`. It intentionally excludes variables that are only read by standalone samples,
|
||||
package sample folders, or tests. When package code adds, removes, or renames an environment variable,
|
||||
update this table in the same change.
|
||||
|
||||
Example values below are illustrative. For entries not backed by a single public class, the `class`
|
||||
column names the closest public surface, helper, or package-level initialization point that reads the
|
||||
variable.
|
||||
|
||||
| package | class | env var | example value |
|
||||
| --- | --- | --- | --- |
|
||||
| `agent-framework-anthropic` | `AnthropicClient` | `ANTHROPIC_API_KEY` | `sk-ant-api03-...` |
|
||||
| `agent-framework-anthropic` | `AnthropicClient` | `ANTHROPIC_CHAT_MODEL_ID` | `claude-sonnet-4-5-20250929` |
|
||||
| `agent-framework-azure-ai` | `AzureAIInferenceEmbeddingClient` | `AZURE_AI_INFERENCE_ENDPOINT` | `https://my-endpoint.inference.ai.azure.com` |
|
||||
| `agent-framework-azure-ai` | `AzureAIInferenceEmbeddingClient` | `AZURE_AI_INFERENCE_API_KEY` | `env-key` |
|
||||
| `agent-framework-azure-ai` | `AzureAIInferenceEmbeddingClient` | `AZURE_AI_INFERENCE_EMBEDDING_MODEL_ID` | `text-embedding-3-small` |
|
||||
| `agent-framework-azure-ai` | `AzureAIInferenceEmbeddingClient` | `AZURE_AI_INFERENCE_IMAGE_EMBEDDING_MODEL_ID` | `Cohere-embed-v3-english` |
|
||||
| `agent-framework-azure-ai-search` | `AzureAISearchContextProvider` | `AZURE_SEARCH_ENDPOINT` | `https://my-search.search.windows.net` |
|
||||
| `agent-framework-azure-ai-search` | `AzureAISearchContextProvider` | `AZURE_SEARCH_API_KEY` | `search-key` |
|
||||
| `agent-framework-azure-ai-search` | `AzureAISearchContextProvider` | `AZURE_SEARCH_INDEX_NAME` | `hotels-index` |
|
||||
| `agent-framework-azure-ai-search` | `AzureAISearchContextProvider` | `AZURE_SEARCH_KNOWLEDGE_BASE_NAME` | `hotels-kb` |
|
||||
| `agent-framework-azure-cosmos` | `CosmosHistoryProvider` | `AZURE_COSMOS_ENDPOINT` | `https://my-cosmos.documents.azure.com:443/` |
|
||||
| `agent-framework-azure-cosmos` | `CosmosHistoryProvider` | `AZURE_COSMOS_DATABASE_NAME` | `agent-history` |
|
||||
| `agent-framework-azure-cosmos` | `CosmosHistoryProvider` | `AZURE_COSMOS_CONTAINER_NAME` | `messages` |
|
||||
| `agent-framework-azure-cosmos` | `CosmosHistoryProvider` | `AZURE_COSMOS_KEY` | `C2F...==` |
|
||||
| `agent-framework-bedrock` | `BedrockChatClient` | `BEDROCK_REGION` | `us-east-1` |
|
||||
| `agent-framework-bedrock` | `BedrockChatClient` | `BEDROCK_CHAT_MODEL_ID` | `anthropic.claude-3-5-sonnet-20241022-v2:0` |
|
||||
| `agent-framework-bedrock` | `BedrockEmbeddingClient` | `BEDROCK_REGION` | `us-east-1` |
|
||||
| `agent-framework-bedrock` | `BedrockEmbeddingClient` | `BEDROCK_EMBEDDING_MODEL_ID` | `amazon.titan-embed-text-v2:0` |
|
||||
| `agent-framework-bedrock` | `BedrockChatClient / BedrockEmbeddingClient` | `AWS_ACCESS_KEY_ID` | `AKIAIOSFODNN7EXAMPLE` |
|
||||
| `agent-framework-bedrock` | `BedrockChatClient / BedrockEmbeddingClient` | `AWS_SECRET_ACCESS_KEY` | `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` |
|
||||
| `agent-framework-bedrock` | `BedrockChatClient / BedrockEmbeddingClient` | `AWS_SESSION_TOKEN` | `IQoJb3JpZ2luX2VjEO7//////////wEaCXVzLXdlc3QtMiJHMEUCIQD...` |
|
||||
| `agent-framework-copilotstudio` | `CopilotStudioAgent` | `COPILOTSTUDIOAGENT__ENVIRONMENTID` | `00000000-0000-0000-0000-000000000000` |
|
||||
| `agent-framework-copilotstudio` | `CopilotStudioAgent` | `COPILOTSTUDIOAGENT__SCHEMANAME` | `cr123_agentname` |
|
||||
| `agent-framework-copilotstudio` | `CopilotStudioAgent` | `COPILOTSTUDIOAGENT__TENANTID` | `11111111-1111-1111-1111-111111111111` |
|
||||
| `agent-framework-copilotstudio` | `CopilotStudioAgent` | `COPILOTSTUDIOAGENT__AGENTAPPID` | `22222222-2222-2222-2222-222222222222` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `ENABLE_INSTRUMENTATION` | `true` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `ENABLE_SENSITIVE_DATA` | `false` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `ENABLE_CONSOLE_EXPORTERS` | `true` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_EXPORTER_OTLP_ENDPOINT` | `http://localhost:4317` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | `http://localhost:4318/v1/traces` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` | `http://localhost:4318/v1/metrics` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` | `http://localhost:4318/v1/logs` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_EXPORTER_OTLP_PROTOCOL` | `grpc` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_EXPORTER_OTLP_HEADERS` | `api-key=demo` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_EXPORTER_OTLP_TRACES_HEADERS` | `api-key=trace-demo` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_EXPORTER_OTLP_METRICS_HEADERS` | `api-key=metric-demo` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_EXPORTER_OTLP_LOGS_HEADERS` | `api-key=log-demo` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_SERVICE_NAME` | `sample-agent` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_SERVICE_VERSION` | `1.0.0` |
|
||||
| `agent-framework-core` | `enable_instrumentation()` | `OTEL_RESOURCE_ATTRIBUTES` | `deployment.environment=dev,service.namespace=agent-framework` |
|
||||
| `agent-framework-devui` | `DevUI server` | `DEVUI_AUTH_TOKEN` | `my-devui-token` |
|
||||
| `agent-framework-foundry` | `FoundryChatClient` | `FOUNDRY_PROJECT_ENDPOINT` | `https://my-project.services.ai.azure.com/api/projects/my-project` |
|
||||
| `agent-framework-foundry` | `FoundryChatClient` | `FOUNDRY_MODEL` | `gpt-4o` |
|
||||
| `agent-framework-foundry` | `FoundryAgent` | `FOUNDRY_AGENT_NAME` | `travel-planner` |
|
||||
| `agent-framework-foundry` | `FoundryAgent` | `FOUNDRY_AGENT_VERSION` | `v1` |
|
||||
| `agent-framework-github-copilot` | `GitHubCopilotAgent` | `GITHUB_COPILOT_CLI_PATH` | `copilot` |
|
||||
| `agent-framework-github-copilot` | `GitHubCopilotAgent` | `GITHUB_COPILOT_MODEL` | `gpt-5` |
|
||||
| `agent-framework-github-copilot` | `GitHubCopilotAgent` | `GITHUB_COPILOT_TIMEOUT` | `60` |
|
||||
| `agent-framework-github-copilot` | `GitHubCopilotAgent` | `GITHUB_COPILOT_LOG_LEVEL` | `info` |
|
||||
| `agent-framework-mem0` | `agent_framework_mem0 package import` | `MEM0_TELEMETRY` | `false` |
|
||||
| `agent-framework-ollama` | `OllamaChatClient` | `OLLAMA_HOST` | `http://localhost:11434` |
|
||||
| `agent-framework-ollama` | `OllamaChatClient` | `OLLAMA_MODEL_ID` | `llama3.1:8b` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `OPENAI_API_KEY` | `sk-proj-...` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `OPENAI_MODEL` | `gpt-4o-mini` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient` | `OPENAI_RESPONSES_MODEL` | `gpt-4.1-mini` |
|
||||
| `agent-framework-openai` | `OpenAIChatCompletionClient` | `OPENAI_CHAT_MODEL` | `gpt-4o` |
|
||||
| `agent-framework-openai` | `OpenAIEmbeddingClient` | `OPENAI_EMBEDDING_MODEL` | `text-embedding-3-small` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `OPENAI_BASE_URL` | `https://api.openai.com/v1/` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `OPENAI_ORG_ID` | `org_123456789` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `AZURE_OPENAI_ENDPOINT` | `https://my-resource.openai.azure.com/` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `AZURE_OPENAI_API_KEY` | `sk-azure-...` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `AZURE_OPENAI_API_VERSION` | `2024-10-21` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `AZURE_OPENAI_BASE_URL` | `https://my-resource.openai.azure.com/openai/v1/` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `AZURE_OPENAI_DEPLOYMENT_NAME` | `gpt-4o` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient` | `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME` | `gpt-4.1` |
|
||||
| `agent-framework-openai` | `OpenAIChatCompletionClient` | `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME` | `gpt-4o-mini` |
|
||||
| `agent-framework-openai` | `OpenAIEmbeddingClient` | `AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME` | `text-embedding-3-large` |
|
||||
| `agent-framework-openai` | `OpenAIChatClient / OpenAIChatCompletionClient / OpenAIEmbeddingClient` | `AZURE_OPENAI_RESOURCE_URL` | `https://cognitiveservices.azure.com/` |
|
||||
|
||||
`agent-framework-openai` supports the Azure OpenAI client-specific deployment aliases listed above; keep
|
||||
`packages/openai/README.md` as the authoritative reference for the exact fallback order and package-specific
|
||||
behavior.
|
||||
|
||||
**Note for production**: In production environments, set environment variables through your deployment platform (e.g., Azure App Settings, Kubernetes ConfigMaps/Secrets) rather than using `.env` files. The `load_dotenv()` call in samples will have no effect when a `.env` file is not present, allowing environment variables to be loaded from the system.
|
||||
|
||||
For Azure authentication, run `az login` before running samples.
|
||||
|
||||
@@ -14,9 +14,9 @@ This gallery helps Semantic Kernel (SK) developers move to the Microsoft Agent F
|
||||
### Azure AI agent parity
|
||||
|
||||
### OpenAI Assistants API parity
|
||||
- [01_basic_openai_assistant.py](openai_assistant/01_basic_openai_assistant.py) — Baseline assistant comparison.
|
||||
- [02_openai_assistant_with_code_interpreter.py](openai_assistant/02_openai_assistant_with_code_interpreter.py) — Code interpreter tool usage.
|
||||
- [03_openai_assistant_function_tool.py](openai_assistant/03_openai_assistant_function_tool.py) — Custom function tooling.
|
||||
|
||||
OpenAI Assistants parity samples were removed alongside the deprecated Python assistants surface and are no longer
|
||||
part of this migration gallery.
|
||||
|
||||
### OpenAI Responses API parity
|
||||
- [01_basic_responses_agent.py](openai_responses/01_basic_responses_agent.py) — Basic responses agent migration.
|
||||
@@ -44,7 +44,7 @@ Each script is fully async and the `main()` routine runs both implementations ba
|
||||
- Python 3.10 or later.
|
||||
- Access to the necessary model endpoints (Azure OpenAI, OpenAI, Azure AI, Copilot Studio, etc.).
|
||||
- Installed SDKs: `semantic-kernel` and the Microsoft Agent Framework (`pip install semantic-kernel agent-framework`), or the repo’s editable packages if you are developing locally.
|
||||
- Service credentials exposed through environment variables (for example `OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_KEY`, or Copilot Studio auth settings).
|
||||
- Service credentials exposed through environment variables (for example `OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_API_KEY`, or Copilot Studio auth settings).
|
||||
|
||||
## Running Single-Agent Samples
|
||||
From the repository root:
|
||||
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# dependencies = [
|
||||
# "semantic-kernel",
|
||||
# ]
|
||||
# ///
|
||||
# Run with any PEP 723 compatible runner, e.g.:
|
||||
# uv run samples/semantic-kernel-migration/openai_assistant/01_basic_openai_assistant.py
|
||||
|
||||
# Copyright (c) Microsoft. All rights reserved.
|
||||
"""Create an OpenAI Assistant using SK and Agent Framework."""
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from agent_framework import Agent
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
ASSISTANT_MODEL = os.environ.get("OPENAI_ASSISTANT_MODEL", "gpt-4o-mini")
|
||||
|
||||
|
||||
async def run_semantic_kernel() -> None:
|
||||
from semantic_kernel.agents import AssistantAgentThread, OpenAIAssistantAgent
|
||||
client = OpenAIAssistantAgent.create_client()
|
||||
# Provision the assistant on the OpenAI Assistants service.
|
||||
definition = await client.beta.assistants.create(
|
||||
model=ASSISTANT_MODEL,
|
||||
name="Helper",
|
||||
instructions="Answer questions in one concise paragraph.",
|
||||
)
|
||||
agent = OpenAIAssistantAgent(client=client, definition=definition)
|
||||
thread: AssistantAgentThread | None = None
|
||||
response = await agent.get_response("What is the capital of Denmark?", thread=thread)
|
||||
thread = response.thread
|
||||
print("[SK]", response.message.content)
|
||||
if thread is not None:
|
||||
print("[SK][thread-id]", thread.id)
|
||||
|
||||
|
||||
async def run_agent_framework() -> None:
|
||||
from agent_framework.openai import OpenAIAssistantsClient
|
||||
assistants_client = OpenAIAssistantsClient()
|
||||
# AF wraps the assistant lifecycle with an async context manager.
|
||||
async with Agent(
|
||||
client=assistants_client,
|
||||
) as assistant_agent:
|
||||
session = assistant_agent.create_session()
|
||||
reply = await assistant_agent.run("What is the capital of Denmark?", session=session)
|
||||
print("[AF]", reply.text)
|
||||
follow_up = await assistant_agent.run(
|
||||
"How many residents live there?",
|
||||
session=session,
|
||||
)
|
||||
print("[AF][follow-up]", follow_up.text)
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
await run_semantic_kernel()
|
||||
await run_agent_framework()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
# /// script
|
||||
|
||||
# requires-python = ">=3.10"
|
||||
# dependencies = [
|
||||
# "semantic-kernel",
|
||||
# ]
|
||||
# ///
|
||||
# Run with any PEP 723 compatible runner, e.g.:
|
||||
# uv run samples/semantic-kernel-migration/openai_assistant/02_openai_assistant_with_code_interpreter.py
|
||||
|
||||
# Copyright (c) Microsoft. All rights reserved.
|
||||
"""Enable the code interpreter tool for OpenAI Assistants in SK and AF."""
|
||||
|
||||
import asyncio
|
||||
|
||||
from agent_framework import Agent
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
|
||||
async def run_semantic_kernel() -> None:
|
||||
from semantic_kernel.agents import OpenAIAssistantAgent
|
||||
from semantic_kernel.connectors.ai.open_ai import OpenAISettings
|
||||
|
||||
client = OpenAIAssistantAgent.create_client()
|
||||
|
||||
code_interpreter_tool, code_interpreter_tool_resources = OpenAIAssistantAgent.configure_code_interpreter_tool()
|
||||
|
||||
# Enable the hosted code interpreter tool on the assistant definition.
|
||||
definition = await client.beta.assistants.create(
|
||||
model=OpenAISettings().chat_model_id,
|
||||
name="CodeRunner",
|
||||
instructions="Run the provided request as code and return the result.",
|
||||
tools=code_interpreter_tool,
|
||||
tool_resources=code_interpreter_tool_resources,
|
||||
)
|
||||
agent = OpenAIAssistantAgent(client=client, definition=definition)
|
||||
response = await agent.get_response(
|
||||
"Use Python to calculate the mean of [41, 42, 45] and explain the steps.",
|
||||
)
|
||||
print(f"[SK]: {response}")
|
||||
|
||||
|
||||
async def run_agent_framework() -> None:
|
||||
from agent_framework.openai import OpenAIAssistantsClient
|
||||
|
||||
assistants_client = OpenAIAssistantsClient()
|
||||
|
||||
# Create code interpreter tool using static method
|
||||
code_interpreter_tool = OpenAIAssistantsClient.get_code_interpreter_tool()
|
||||
|
||||
# AF exposes the same tool configuration via create_agent.
|
||||
async with Agent(client=assistants_client,
|
||||
name="CodeRunner",
|
||||
instructions="Use the code interpreter when calculations are required.",
|
||||
model="gpt-4.1",
|
||||
tools=[code_interpreter_tool],
|
||||
) as assistant_agent:
|
||||
response = await assistant_agent.run(
|
||||
"Use Python to calculate the mean of [41, 42, 45] and explain the steps.",
|
||||
tool_choice="auto",
|
||||
)
|
||||
print(f"[AF]: {response.text}")
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
await run_semantic_kernel()
|
||||
await run_agent_framework()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# dependencies = [
|
||||
# "semantic-kernel",
|
||||
# ]
|
||||
# ///
|
||||
# Run with any PEP 723 compatible runner, e.g.:
|
||||
# uv run samples/semantic-kernel-migration/openai_assistant/03_openai_assistant_function_tool.py
|
||||
|
||||
# Copyright (c) Microsoft. All rights reserved.
|
||||
"""Implement a function tool for OpenAI Assistants in SK and AF."""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from typing import Any
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
ASSISTANT_MODEL = os.environ.get("OPENAI_ASSISTANT_MODEL", "gpt-4o-mini")
|
||||
|
||||
|
||||
async def fake_weather_lookup(city: str, day: str) -> dict[str, Any]:
|
||||
"""Pretend to call a weather service."""
|
||||
|
||||
return {
|
||||
"city": city,
|
||||
"day": day,
|
||||
"forecast": "Sunny with scattered clouds",
|
||||
"high_c": 22,
|
||||
"low_c": 14,
|
||||
}
|
||||
|
||||
|
||||
async def run_semantic_kernel() -> None:
|
||||
from semantic_kernel.agents import AssistantAgentThread, OpenAIAssistantAgent
|
||||
from semantic_kernel.functions import kernel_function
|
||||
|
||||
class WeatherPlugin:
|
||||
@kernel_function(name="get_forecast", description="Look up the forecast for a city and day.")
|
||||
async def fake_weather_lookup(self, city: str, day: str) -> dict[str, Any]:
|
||||
"""Pretend to call a weather service."""
|
||||
return {
|
||||
"city": city,
|
||||
"day": day,
|
||||
"forecast": "Sunny with scattered clouds",
|
||||
"high_c": 22,
|
||||
"low_c": 14,
|
||||
}
|
||||
|
||||
client = OpenAIAssistantAgent.create_client()
|
||||
# Tool schema is registered on the assistant definition.
|
||||
definition = await client.beta.assistants.create(
|
||||
model=ASSISTANT_MODEL,
|
||||
name="WeatherHelper",
|
||||
instructions="Call get_forecast to fetch weather details.",
|
||||
)
|
||||
agent = OpenAIAssistantAgent(client=client, definition=definition, plugins=[WeatherPlugin()])
|
||||
|
||||
thread: AssistantAgentThread | None = None
|
||||
response = await agent.get_response(
|
||||
"What will the weather be like in Seattle tomorrow?",
|
||||
thread=thread,
|
||||
)
|
||||
thread = response.thread
|
||||
print("[SK][initial]", response.message.content)
|
||||
|
||||
|
||||
async def run_agent_framework() -> None:
|
||||
from agent_framework import Agent, tool
|
||||
from agent_framework.openai import OpenAIAssistantsClient
|
||||
|
||||
@tool(
|
||||
name="get_forecast",
|
||||
description="Look up the forecast for a city and day.",
|
||||
)
|
||||
async def get_forecast(city: str, day: str) -> dict[str, Any]:
|
||||
return await fake_weather_lookup(city, day)
|
||||
|
||||
assistants_client = OpenAIAssistantsClient()
|
||||
# AF converts the decorated function into an assistant-compatible tool.
|
||||
async with Agent(client=assistants_client,
|
||||
name="WeatherHelper",
|
||||
instructions="Call get_forecast to fetch weather details.",
|
||||
model=ASSISTANT_MODEL,
|
||||
tools=[get_forecast],
|
||||
) as assistant_agent:
|
||||
reply = await assistant_agent.run(
|
||||
"What will the weather be like in Seattle tomorrow?",
|
||||
tool_choice="auto",
|
||||
)
|
||||
print("[AF]", reply.text)
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
await run_semantic_kernel()
|
||||
await run_agent_framework()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
+3
-3
@@ -36,11 +36,11 @@ async def run_semantic_kernel() -> None:
|
||||
|
||||
async def run_agent_framework() -> None:
|
||||
from agent_framework import Agent
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
|
||||
# AF Agent can swap in an OpenAIResponsesClient directly.
|
||||
# AF Agent can swap in an OpenAIChatClient directly.
|
||||
chat_agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
instructions="Answer in one concise sentence.",
|
||||
name="Expert",
|
||||
)
|
||||
|
||||
+2
-2
@@ -43,14 +43,14 @@ async def run_semantic_kernel() -> None:
|
||||
|
||||
async def run_agent_framework() -> None:
|
||||
from agent_framework import Agent, tool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
|
||||
@tool(name="add", description="Add two numbers")
|
||||
async def add(a: float, b: float) -> float:
|
||||
return a + b
|
||||
|
||||
chat_agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
instructions="Use the add tool when math is required.",
|
||||
name="MathExpert",
|
||||
# AF registers the async function as a tool at construction.
|
||||
|
||||
+2
-2
@@ -46,10 +46,10 @@ async def run_semantic_kernel() -> None:
|
||||
|
||||
async def run_agent_framework() -> None:
|
||||
from agent_framework import Agent
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
|
||||
chat_agent = Agent(
|
||||
client=OpenAIResponsesClient(),
|
||||
client=OpenAIChatClient(),
|
||||
instructions="Return launch briefs as structured JSON.",
|
||||
name="ProductMarketer",
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ from collections.abc import Sequence
|
||||
from typing import cast
|
||||
|
||||
from agent_framework import Agent, Message
|
||||
from agent_framework.azure import AzureOpenAIChatClient
|
||||
from agent_framework.openai import OpenAIChatCompletionClient
|
||||
from agent_framework.orchestrations import ConcurrentBuilder
|
||||
from azure.identity import AzureCliCredential
|
||||
from dotenv import load_dotenv
|
||||
@@ -89,7 +89,7 @@ def _print_semantic_kernel_outputs(outputs: Sequence[ChatMessageContent]) -> Non
|
||||
|
||||
|
||||
async def run_agent_framework_example(prompt: str) -> Sequence[list[Message]]:
|
||||
client = AzureOpenAIChatClient(credential=AzureCliCredential())
|
||||
client = OpenAIChatCompletionClient(credential=AzureCliCredential())
|
||||
|
||||
physics = Agent(client=client,
|
||||
instructions=("You are an expert in physics. Answer questions from a physics perspective."),
|
||||
|
||||
@@ -15,7 +15,7 @@ import asyncio
|
||||
from collections.abc import Sequence
|
||||
|
||||
from agent_framework import Agent
|
||||
from agent_framework.openai import OpenAIChatClient, OpenAIResponsesClient
|
||||
from agent_framework.openai import OpenAIChatClient
|
||||
from agent_framework.orchestrations import MagenticBuilder
|
||||
from dotenv import load_dotenv
|
||||
from semantic_kernel.agents import (
|
||||
@@ -141,8 +141,8 @@ async def run_agent_framework_example(prompt: str) -> str | None:
|
||||
)
|
||||
|
||||
# Create code interpreter tool using static method
|
||||
coder_client = OpenAIResponsesClient()
|
||||
code_interpreter_tool = OpenAIResponsesClient.get_code_interpreter_tool()
|
||||
coder_client = OpenAIChatClient()
|
||||
code_interpreter_tool = OpenAIChatClient.get_code_interpreter_tool()
|
||||
|
||||
coder = Agent(
|
||||
name="CoderAgent",
|
||||
|
||||
@@ -16,7 +16,7 @@ from collections.abc import Sequence
|
||||
from typing import cast
|
||||
|
||||
from agent_framework import Agent, Message
|
||||
from agent_framework.azure import AzureOpenAIChatClient
|
||||
from agent_framework.openai import OpenAIChatCompletionClient
|
||||
from agent_framework.orchestrations import SequentialBuilder
|
||||
from azure.identity import AzureCliCredential
|
||||
from dotenv import load_dotenv
|
||||
@@ -76,7 +76,7 @@ async def sk_agent_response_callback(
|
||||
|
||||
|
||||
async def run_agent_framework_example(prompt: str) -> list[Message]:
|
||||
client = AzureOpenAIChatClient(credential=AzureCliCredential())
|
||||
client = OpenAIChatCompletionClient(credential=AzureCliCredential())
|
||||
|
||||
writer = Agent(client=client,
|
||||
instructions=("You are a concise copywriter. Provide a single, punchy marketing sentence based on the prompt."),
|
||||
|
||||
Reference in New Issue
Block a user