Python: [BREAKING] Standardize model selection on model (#4999)

* Refactor Anthropic model option and provider clients

Rename the Anthropic client model option from model_id to model, add provider-specific Anthropic wrappers for Foundry, Bedrock, and Vertex, and expose them through the Anthropic, Foundry, Amazon, and Google namespaces. Update core option handling, docs, samples, and tests accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix Anthropic skills sample typing

Cast the Anthropic beta client to Any in the skills sample so the pre-commit sample pyright check no longer fails on beta skills and files endpoints that are not exposed by the current SDK stubs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* undo sample mypy

* Retry CI after transient external failures

Retrigger PR validation after an unrelated Copilot review workflow SAML failure and a transient external tau2 git fetch failure in the Windows Python test setup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address review feedback on model option merging

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address Anthropic compatibility review feedback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* moved all to `model`

* fixes for azure ai search

* Python: standardize remaining sample env var names

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Python: fix foundry-local pyright compatibility

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* updated env vars in cicd

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Eduard van Valkenburg
2026-04-01 19:00:18 +00:00
committed by GitHub
co-authored by Copilot
parent 95550dd0dc
commit 6acab3d1d6
184 changed files with 1749 additions and 1025 deletions
@@ -51,7 +51,7 @@ Depending on the selected client, set the appropriate environment variables:
**For Azure OpenAI clients (`azure_openai_responses` and `azure_openai_chat_completion`):**
- `AZURE_OPENAI_ENDPOINT`: Your Azure OpenAI endpoint
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The Azure OpenAI deployment used by the sample
- `AZURE_OPENAI_MODEL`: 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`
@@ -66,13 +66,13 @@ Depending on the selected client, set the appropriate environment variables:
**For Anthropic client (`anthropic`):**
- `ANTHROPIC_API_KEY`: Your Anthropic API key
- `ANTHROPIC_CHAT_MODEL_ID`: The Anthropic model ID (for example, `claude-sonnet-4-5`)
- `ANTHROPIC_CHAT_MODEL`: The Anthropic model to use (for example, `claude-sonnet-4-5`)
**For Ollama client (`ollama`):**
- `OLLAMA_HOST`: Ollama server URL (defaults to `http://localhost:11434` if unset)
- `OLLAMA_MODEL_ID`: Ollama model name (for example, `mistral`, `qwen2.5:8b`)
- `OLLAMA_MODEL`: Ollama model name (for example, `mistral`, `qwen2.5:8b`)
**For Bedrock client (`bedrock`):**
- `BEDROCK_CHAT_MODEL_ID`: Bedrock model ID (for example, `anthropic.claude-3-5-sonnet-20240620-v1:0`)
- `BEDROCK_CHAT_MODEL`: Bedrock model ID (for example, `anthropic.claude-3-5-sonnet-20240620-v1:0`)
- `BEDROCK_REGION`: AWS region (defaults to `us-east-1` if unset)
- AWS credentials via standard environment variables (for example, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
@@ -24,7 +24,7 @@ async def main() -> None:
Creates a task for the chat request, waits briefly, then cancels it to show proper cleanup.
Configuration:
- OpenAI model ID: Use "model_id" parameter or "OPENAI_MODEL" environment variable
- OpenAI model ID: Use "model" parameter or "OPENAI_MODEL" environment variable
- OpenAI API key: Use "api_key" parameter or "OPENAI_API_KEY" environment variable
"""
client = FoundryChatClient(credential=AzureCliCredential())
@@ -102,7 +102,7 @@ class EchoingChatClient(BaseChatClient[OptionsT]):
response = ChatResponse(
messages=[response_message],
model_id="echo-model-v1",
model="echo-model-v1",
response_id=f"echo-resp-{random.randint(1000, 9999)}",
)
@@ -120,7 +120,7 @@ class EchoingChatClient(BaseChatClient[OptionsT]):
contents=[Content.from_text(char)],
role="assistant",
response_id=f"echo-stream-resp-{random.randint(1000, 9999)}",
model_id="echo-model-v1",
model="echo-model-v1",
)
await asyncio.sleep(stream_delay_seconds)
@@ -33,9 +33,9 @@ Key components:
class TiktokenTokenizer(TokenizerProtocol):
"""TokenizerProtocol implementation backed by tiktoken's o200k_base (gpt-4.1 and up default) encoding."""
def __init__(self, *, encoding_name: str = "o200k_base", model_name: str | None = None) -> None:
if model_name is not None:
self._encoding = tiktoken.encoding_for_model(model_name)
def __init__(self, *, encoding_name: str = "o200k_base", model: str | None = None) -> None:
if model is not None:
self._encoding = tiktoken.encoding_for_model(model)
else:
self._encoding: Any = tiktoken.get_encoding(encoding_name)
@@ -33,7 +33,7 @@ rather than chat history. The memory store is deleted at the end of the run.
Prerequisites:
1. Set FOUNDRY_PROJECT_ENDPOINT environment variable
2. Set FOUNDRY_MODEL for the chat/responses model
3. Set AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME for the embedding model
3. Set AZURE_OPENAI_EMBEDDING_MODEL for the embedding model
4. Deploy both a chat model (e.g. gpt-4) and an embedding model (e.g. text-embedding-3-small)
"""
load_dotenv()
@@ -55,7 +55,7 @@ async def main() -> None:
)
memory_store_definition = MemoryStoreDefaultDefinition(
chat_model=os.environ["FOUNDRY_MODEL"],
embedding_model=os.environ["AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME"],
embedding_model=os.environ["AZURE_OPENAI_EMBEDDING_MODEL"],
options=options,
)
print(f"Creating memory store '{memory_store_name}'...")
@@ -32,7 +32,7 @@ Prerequisites:
- AZURE_SEARCH_INDEX_NAME: Your search index name
- FOUNDRY_PROJECT_ENDPOINT: Your Azure AI Foundry project endpoint
- 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_EMBEDDING_MODEL: (Optional) Your Azure OpenAI embedding deployment for hybrid search
- AZURE_OPENAI_ENDPOINT: (Optional) Your Azure OpenAI resource URL, required if using Azure OpenAI embeddings
"""
@@ -56,7 +56,7 @@ async def main() -> None:
project_endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]
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")
embedding_deployment = os.environ.get("AZURE_OPENAI_EMBEDDING_MODEL")
embedding_client = None
if openai_endpoint and embedding_deployment:
@@ -159,7 +159,7 @@ agent_factory = AgentFactory(
"MyProvider": {
"package": "my_custom_module",
"name": "MyCustomChatClient",
"model_id_field": "model_id",
"model_field": "model",
}
}
)
@@ -176,7 +176,7 @@ agent = agent_factory.create_agent_from_yaml_path(Path("custom_provider.yaml"))
This allows you to extend the declarative framework with custom chat client implementations. The mapping requires:
- **package**: The Python package/module to import from
- **name**: The class name of your SupportsChatGetResponse implementation
- **model_id_field**: The constructor parameter name that accepts the value of the `model.id` field from the YAML
- **model_field**: The constructor parameter name that accepts the value of the `model.id` field from the YAML
You can reference your custom provider using either `Provider.ApiType` format or just `Provider` in your YAML configuration, as long as it matches the registered mapping.
+2 -2
View File
@@ -8,8 +8,8 @@ FOUNDRY_MODEL=gpt-4o
# Azure OpenAI workflow sample
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME=gpt-4o
AZURE_OPENAI_RESPONSES_MODEL=gpt-4o
# Optional fallback env name also supported by workflow_with_agents/workflow.py:
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o
AZURE_OPENAI_MODEL=gpt-4o
# Optional if you need to override the default API version:
AZURE_OPENAI_API_VERSION=2024-10-21
+3 -3
View File
@@ -94,7 +94,7 @@ workflow_name/
| Sample | What it demonstrates | Required keys / auth |
| ------ | -------------------- | -------------------- |
| [**workflow_declarative/**](workflow_declarative/) | A YAML-defined workflow loaded through `WorkflowFactory`, with nested age-based branching and no model client code. | None |
| [**workflow_with_agents/**](workflow_with_agents/) | A content review workflow that uses agents as executors and routes based on structured review output (`Writer -> Reviewer -> Editor/Publisher -> Summarizer`). | `AZURE_OPENAI_ENDPOINT`, plus `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME` or `AZURE_OPENAI_DEPLOYMENT_NAME`; Azure CLI auth via `az login`; `AZURE_OPENAI_API_VERSION` is optional |
| [**workflow_with_agents/**](workflow_with_agents/) | A content review workflow that uses agents as executors and routes based on structured review output (`Writer -> Reviewer -> Editor/Publisher -> Summarizer`). | `AZURE_OPENAI_ENDPOINT`, plus `AZURE_OPENAI_RESPONSES_MODEL` or `AZURE_OPENAI_MODEL`; Azure CLI auth via `az login`; `AZURE_OPENAI_API_VERSION` is optional |
| [**workflow_spam/**](workflow_spam/) | A multi-step spam detection workflow with human-in-the-loop approval, branching for spam vs. legitimate messages, and a final reporting step. | None |
| [**workflow_fanout/**](workflow_fanout/) | A larger fan-out/fan-in data processing workflow with parallel validation, multiple transformations, QA, aggregation, and demo failure toggles. | None |
@@ -130,8 +130,8 @@ export FOUNDRY_MODEL="gpt-4o"
# Azure OpenAI workflow_with_agents sample
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com"
export AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME="gpt-4o"
export AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o"
export AZURE_OPENAI_RESPONSES_MODEL="gpt-4o"
export AZURE_OPENAI_MODEL="gpt-4o"
az login
```
@@ -2,8 +2,8 @@
# This sample uses Azure CLI auth, so run `az login` before starting DevUI.
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME=gpt-4o
AZURE_OPENAI_RESPONSES_MODEL=gpt-4o
# Optional fallback env name also supported by the client:
# AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o
# AZURE_OPENAI_MODEL=gpt-4o
# Optional if you need to override the default API version:
AZURE_OPENAI_API_VERSION=2024-10-21
@@ -65,7 +65,7 @@ def is_approved(message: Any) -> bool:
# Create Azure OpenAI Responses chat client
client = OpenAIChatClient(
model=os.environ.get("AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME") or os.environ.get("AZURE_OPENAI_DEPLOYMENT_NAME"),
model=os.environ.get("AZURE_OPENAI_RESPONSES_MODEL") or os.environ.get("AZURE_OPENAI_MODEL"),
azure_endpoint=os.environ.get("AZURE_OPENAI_ENDPOINT"),
api_version=os.environ.get("AZURE_OPENAI_API_VERSION"),
credential=AzureCliCredential(),
@@ -31,9 +31,9 @@ Prerequisites:
- AZURE_AI_INFERENCE_ENDPOINT: Your Azure AI model inference endpoint URL, for instance:
https://<apim-instance>.azure-api.net/<foundry-instance>/models
- AZURE_AI_INFERENCE_API_KEY: Your API key
- AZURE_AI_INFERENCE_EMBEDDING_MODEL_ID: The text embedding model name
- AZURE_AI_INFERENCE_EMBEDDING_MODEL: The text embedding model name
(e.g. "text-embedding-3-small")
- AZURE_AI_INFERENCE_IMAGE_EMBEDDING_MODEL_ID: The image embedding model name
- AZURE_AI_INFERENCE_IMAGE_EMBEDDING_MODEL: The image embedding model name
(e.g. "Cohere-embed-v3-english")
"""
@@ -49,7 +49,7 @@ async def main() -> None:
result = await client.get_embeddings([image_content])
print(f"Image embedding dimensions: {result[0].dimensions}")
print(f"First 5 values: {result[0].vector[:5]}")
print(f"Model: {result[0].model_id}")
print(f"Model: {result[0].model}")
print(f"Usage: {result.usage}")
print()
@@ -14,7 +14,7 @@ from dotenv import load_dotenv
Prerequisites:
Set the following environment variables or add them to a local ``.env`` file:
- ``AZURE_OPENAI_ENDPOINT``: Your Azure OpenAI endpoint URL
- ``AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME``: The embedding deployment name
- ``AZURE_OPENAI_EMBEDDING_MODEL``: The embedding deployment name
- ``AZURE_OPENAI_API_VERSION``: Optional API version override
Sign in with ``az login`` before running the sample.
@@ -27,7 +27,7 @@ async def main() -> None:
"""Generate embeddings with Azure OpenAI."""
async with AzureCliCredential() as credential:
client = OpenAIEmbeddingClient(
model=os.getenv("AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME"),
model=os.getenv("AZURE_OPENAI_EMBEDDING_MODEL"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
credential=credential,
@@ -41,7 +41,7 @@ def response_matches_expected(response: str, expected_output: str) -> float:
async def main() -> None:
client = FoundryChatClient(
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
model=os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME", "gpt-4o"),
model=os.environ.get("FOUNDRY_MODEL", "gpt-4o"),
credential=AzureCliCredential(),
)
@@ -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_DEPLOYMENT_NAME`: The name of your Azure OpenAI chat model deployment
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The name of your Azure OpenAI responses model deployment
- `AZURE_OPENAI_MODEL`: The name of your Azure OpenAI chat model deployment
- `AZURE_OPENAI_MODEL`: 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`)
@@ -23,7 +23,7 @@ async def test_image() -> None:
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option. Requires AZURE_OPENAI_ENDPOINT and FOUNDRY_MODEL
# environment variables to be set.
# Alternatively, you can pass deployment_name explicitly:
# Alternatively, you can pass model explicitly:
# client = FoundryChatClient(credential=AzureCliCredential(), model="your-deployment-name")
client = FoundryChatClient(credential=AzureCliCredential())
image_uri = create_sample_image()
@@ -32,7 +32,7 @@ async def test_image() -> None:
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option. Requires AZURE_OPENAI_ENDPOINT and FOUNDRY_MODEL
# environment variables to be set.
# Alternatively, you can pass deployment_name explicitly:
# Alternatively, you can pass model explicitly:
# client = FoundryChatClient(credential=AzureCliCredential(), model="your-deployment-name")
client = FoundryChatClient(credential=AzureCliCredential())
@@ -1,7 +1,7 @@
# Bedrock Examples
This folder contains examples demonstrating how to use AWS Bedrock models with the Agent Framework. The sample
uses `BEDROCK_CHAT_MODEL_ID`, `BEDROCK_REGION`, and AWS credentials (`AWS_ACCESS_KEY_ID`,
uses `BEDROCK_CHAT_MODEL`, `BEDROCK_REGION`, and AWS credentials (`AWS_ACCESS_KEY_ID`,
`AWS_SECRET_ACCESS_KEY`, optional `AWS_SESSION_TOKEN`).
## Examples
@@ -12,6 +12,6 @@ uses `BEDROCK_CHAT_MODEL_ID`, `BEDROCK_REGION`, and AWS credentials (`AWS_ACCESS
## Environment Variables
- `BEDROCK_CHAT_MODEL_ID`: Bedrock model ID (for example, `anthropic.claude-3-5-sonnet-20240620-v1:0`)
- `BEDROCK_CHAT_MODEL`: Bedrock model ID (for example, `anthropic.claude-3-5-sonnet-20240620-v1:0`)
- `BEDROCK_REGION`: AWS region (defaults to `us-east-1` if unset)
- AWS credentials via standard variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, optional `AWS_SESSION_TOKEN`)
@@ -17,7 +17,7 @@ Bedrock Chat Client Example
This sample demonstrates using `BedrockChatClient` with an agent and a simple tool.
Environment variables used:
- `BEDROCK_CHAT_MODEL_ID`
- `BEDROCK_CHAT_MODEL`
- `BEDROCK_REGION` (defaults to `us-east-1` if unset)
- AWS credentials via standard variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`,
optional `AWS_SESSION_TOKEN`)
@@ -28,14 +28,14 @@ This folder contains examples demonstrating how to use Anthropic's Claude models
### Anthropic Client
- `ANTHROPIC_API_KEY`: Your Anthropic API key (get one from [Anthropic Console](https://console.anthropic.com/))
- `ANTHROPIC_CHAT_MODEL_ID`: The Claude model to use (e.g., `claude-haiku-4-5`, `claude-sonnet-4-5-20250929`)
- `ANTHROPIC_CHAT_MODEL`: The Claude model to use (e.g., `claude-haiku-4-5`, `claude-sonnet-4-5-20250929`)
### Foundry
- `ANTHROPIC_FOUNDRY_API_KEY`: Your Foundry Anthropic API key
- `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`)
- `ANTHROPIC_CHAT_MODEL`: The Claude model to use in Foundry (e.g., `claude-haiku-4-5`)
### Claude Agent
@@ -35,7 +35,7 @@ async def non_streaming_example() -> None:
print("=== Non-streaming Response Example ===")
agent = Agent(
client=AnthropicClient(model_id="claude-sonnet-4-5-20250929"),
client=AnthropicClient(model="claude-sonnet-4-5-20250929"),
name="WeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -52,7 +52,7 @@ async def streaming_example() -> None:
print("=== Streaming Response Example ===")
agent = Agent(
client=AnthropicClient(model_id="claude-sonnet-4-5-20250929"),
client=AnthropicClient(model="claude-sonnet-4-5-20250929"),
name="WeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -2,8 +2,7 @@
import asyncio
from agent_framework import Agent
from agent_framework.anthropic import AnthropicClient
from anthropic import AsyncAnthropicFoundry
from agent_framework.foundry import AnthropicFoundryClient
from dotenv import load_dotenv
# Load environment variables from .env file
@@ -27,14 +26,14 @@ To use the Foundry integration ensure you have the following environment variabl
- 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
- ANTHROPIC_CHAT_MODEL
Should be something like claude-haiku-4-5
"""
async def main() -> None:
"""Example of streaming response (get results as they are generated)."""
client = AnthropicClient(anthropic_client=AsyncAnthropicFoundry())
client = AnthropicFoundryClient()
# Create MCP tool configuration using instance method
mcp_tool = client.get_mcp_tool(
@@ -29,7 +29,7 @@ async def main() -> None:
client = AnthropicClient[AnthropicChatOptions](additional_beta_flags=["skills-2025-10-02"])
# List Anthropic-managed Skills
skills = await client.anthropic_client.beta.skills.list(source="anthropic", betas=["skills-2025-10-02"])
skills = await client.anthropic_client.beta.skills.list(source="anthropic", betas=["skills-2025-10-02"]) # type: ignore
for skill in skills.data:
print(f"{skill.source}: {skill.id} (version: {skill.latest_version})")
@@ -81,7 +81,7 @@ async def main() -> None:
# Since I'm using the pptx skill, the files will be PowerPoint presentations
print("Generated files:")
for idx, file in enumerate(files):
file_content = await client.anthropic_client.beta.files.download(
file_content = await client.anthropic_client.beta.files.download( # type: ignore
file_id=file.file_id, betas=["files-api-2025-04-14"]
)
with open(Path(__file__).parent / f"python_programming-{idx}.pptx", "wb") as f:
@@ -26,7 +26,7 @@ This folder contains Azure-backed samples for the generic OpenAI clients in
Set these before running the Azure provider samples:
- `AZURE_OPENAI_ENDPOINT`
- `AZURE_OPENAI_DEPLOYMENT_NAME`
- `AZURE_OPENAI_MODEL`
Optionally, you can also set:
@@ -38,7 +38,7 @@ async def non_streaming_example() -> None:
agent = Agent(
client=OpenAIChatCompletionClient(
model=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
model=os.getenv("AZURE_OPENAI_MODEL"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
credential=AzureCliCredential(),
@@ -60,7 +60,7 @@ async def streaming_example() -> None:
agent = Agent(
client=OpenAIChatCompletionClient(
model=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
model=os.getenv("AZURE_OPENAI_MODEL"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
credential=AzureCliCredential(),
@@ -41,7 +41,7 @@ async def main() -> None:
# authentication option.
agent = Agent(
client=OpenAIChatCompletionClient(
model=os.environ["AZURE_OPENAI_DEPLOYMENT_NAME"],
model=os.environ["AZURE_OPENAI_MODEL"],
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
credential=AzureCliCredential(),
),
@@ -38,7 +38,7 @@ async def non_streaming_example() -> None:
agent = Agent(
client=OpenAIChatClient(
model=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
model=os.getenv("AZURE_OPENAI_MODEL"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
credential=AzureCliCredential(),
@@ -60,7 +60,7 @@ async def streaming_example() -> None:
agent = Agent(
client=OpenAIChatClient(
model=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
model=os.getenv("AZURE_OPENAI_MODEL"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
credential=AzureCliCredential(),
@@ -45,4 +45,4 @@ This folder contains Azure AI Foundry and Foundry Local samples for Agent Framew
### Environment Variables
- `FOUNDRY_LOCAL_MODEL_ID`: Optional model alias/ID to use by default when `model_id` is not passed to `FoundryLocalClient`.
- `FOUNDRY_LOCAL_MODEL`: Optional model alias/ID to use by default when `model` is not passed to `FoundryLocalClient`.
@@ -40,8 +40,8 @@ Set the following environment variables:
- `OLLAMA_HOST`: The base URL for your Ollama server (optional, defaults to `http://localhost:11434`)
- Example: `export OLLAMA_HOST="http://localhost:11434"`
- `OLLAMA_MODEL_ID`: The model name to use
- Example: `export OLLAMA_MODEL_ID="qwen2.5:8b"`
- `OLLAMA_MODEL`: The model name to use
- Example: `export OLLAMA_MODEL="qwen2.5:8b"`
- Must be a model you have pulled with Ollama
### For OpenAI Client with Ollama (`ollama_with_openai_chat_client.py`)
@@ -17,7 +17,7 @@ This sample demonstrates implementing a Ollama agent with basic tool usage.
Ensure to install Ollama and have a model running locally before running the sample
Not all Models support function calling, to test function calling try llama3.2 or qwen3:4b
Set the model to use via the OLLAMA_MODEL_ID environment variable or modify the code below.
Set the model to use via the OLLAMA_MODEL environment variable or modify the code below.
https://ollama.com/
"""
@@ -16,7 +16,7 @@ This sample demonstrates implementing a Ollama agent with reasoning.
Ensure to install Ollama and have a model running locally before running the sample
Not all Models support reasoning, to test reasoning try qwen3:8b
Set the model to use via the OLLAMA_MODEL_ID environment variable or modify the code below.
Set the model to use via the OLLAMA_MODEL environment variable or modify the code below.
https://ollama.com/
"""
@@ -17,7 +17,7 @@ This sample demonstrates using the native Ollama Chat Client directly.
Ensure to install Ollama and have a model running locally before running the sample.
Not all Models support function calling, to test function calling try llama3.2
Set the model to use via the OLLAMA_MODEL_ID environment variable or modify the code below.
Set the model to use via the OLLAMA_MODEL environment variable or modify the code below.
https://ollama.com/
"""
@@ -16,7 +16,7 @@ This sample demonstrates implementing a Ollama agent with multimodal input capab
Ensure to install Ollama and have a model running locally before running the sample
Not all Models support multimodal input, to test multimodal input try gemma3:4b
Set the model to use via the OLLAMA_MODEL_ID environment variable or modify the code below.
Set the model to use via the OLLAMA_MODEL environment variable or modify the code below.
https://ollama.com/
"""
@@ -28,7 +28,7 @@ code_defined_skill/
Set the required environment variables in a `.env` file (see `python/.env.example`):
- `FOUNDRY_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The name of your model deployment (defaults to `gpt-4o-mini`)
- `AZURE_OPENAI_MODEL`: The name of your model deployment (defaults to `gpt-4o-mini`)
### Authentication
@@ -48,7 +48,7 @@ file_based_skill/
Set the required environment variables in a `.env` file (see `python/.env.example`):
- `FOUNDRY_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The name of your model deployment (defaults to `gpt-4o-mini`)
- `AZURE_OPENAI_MODEL`: The name of your model deployment (defaults to `gpt-4o-mini`)
### Authentication
@@ -61,7 +61,7 @@ Set environment variables (or create a `.env` file):
```
FOUNDRY_PROJECT_ENDPOINT=https://your-project.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o-mini
AZURE_OPENAI_MODEL=gpt-4o-mini
```
Authenticate with Azure CLI:
@@ -29,7 +29,7 @@ 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`):
- `FOUNDRY_PROJECT_ENDPOINT`: Your Azure AI Foundry project endpoint
- `AZURE_OPENAI_DEPLOYMENT_NAME`: The name of your model deployment (defaults to `gpt-4o-mini`)
- `AZURE_OPENAI_MODEL`: The name of your model deployment (defaults to `gpt-4o-mini`)
### Authentication
+4 -4
View File
@@ -38,7 +38,7 @@ async def demo_anthropic_chat_client() -> None:
print("\n=== Anthropic ChatClient with TypedDict Options ===\n")
# Create Anthropic client
client = AnthropicClient(model_id="claude-sonnet-4-5-20250929")
client = AnthropicClient(model="claude-sonnet-4-5-20250929")
# Standard options work great:
response = await client.get_response(
@@ -53,14 +53,14 @@ async def demo_anthropic_chat_client() -> None:
)
print(f"Anthropic Response: {response.text}")
print(f"Model used: {response.model_id}")
print(f"Model used: {response.model}")
async def demo_anthropic_agent() -> None:
"""Demonstrate Agent with Anthropic client and typed options."""
print("\n=== Agent with Anthropic and Typed Options ===\n")
client = AnthropicClient(model_id="claude-sonnet-4-5-20250929")
client = AnthropicClient(model="claude-sonnet-4-5-20250929")
# Create a typed agent for Anthropic - IDE knows Anthropic-specific options!
agent = Agent(
@@ -129,7 +129,7 @@ async def demo_openai_chat_client_reasoning_models() -> None:
)
print(f"OpenAI Response: {response.text}")
print(f"Model used: {response.model_id}")
print(f"Model used: {response.model}")
async def demo_openai_agent() -> None: