Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .env-sample
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# API Host Selection
# Options: github, azure, ollama, openai
API_HOST=github

# GitHub Models Configuration
GITHUB_TOKEN=your_github_token_here
GITHUB_MODEL=gpt-4o
# Options: azure, ollama, openai
API_HOST=azure

# Azure OpenAI Configuration
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_CHAT_DEPLOYMENT=your-deployment-name
AZURE_OPENAI_VERSION=2024-02-15-preview

# Ollama Configuration
OLLAMA_MODEL=llama3.1
OLLAMA_MODEL=qwen3.5:9b
OLLAMA_ENDPOINT=http://localhost:11434/v1
OLLAMA_API_KEY=ollama
OLLAMA_API_KEY=no-key-needed

# OpenAI Configuration (default if API_HOST not set)
Comment thread
pamelafox marked this conversation as resolved.
OPENAI_MODEL=gpt-4o-mini
OPENAI_MODEL=gpt-5.2
OPENAI_API_KEY=your_openai_api_key_here

# GitHub MCP Configuration (for Langchain+GitHub example)
GITHUB_TOKEN=your_github_token_here

# OpenTelemetry Configuration (for Aspire Dashboard)
# Uncomment to enable tracing, metrics, and logs export
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ If you're not using one of the above options, then you'll need to:
```

6. Edit `.env` with your API credentials. Choose one of the following providers by setting `API_HOST`:
- `github` - GitHub Models (requires `GITHUB_TOKEN`)
- `azure` - Azure OpenAI (requires Azure credentials)
- `ollama` - Local Ollama instance
- `ollama` - Local Ollama instance with Responses API support
- `openai` - OpenAI API (requires `OPENAI_API_KEY`)

## Run local MCP servers
Expand Down Expand Up @@ -280,7 +279,7 @@ Pricing varies per region and usage, so it isn't possible to predict exact costs

You can try the [Azure pricing calculator](https://azure.com/e/3987c81282c84410b491d28094030c9a) for the resources:

- **Azure OpenAI Service**: S0 tier, GPT-4o-mini model. Pricing is based on token count. [Pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)
- **Azure OpenAI Service**: S0 tier, GPT-5.2 model. Pricing is based on token count. [Pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)
- **Azure Container Apps**: Consumption tier. [Pricing](https://azure.microsoft.com/pricing/details/container-apps/)
- **Azure Container Registry**: Standard tier. [Pricing](https://azure.microsoft.com/pricing/details/container-registry/)
- **Azure Cosmos DB**: Serverless tier. [Pricing](https://azure.microsoft.com/pricing/details/cosmos-db/)
Expand Down
26 changes: 11 additions & 15 deletions agents/agentframework_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime

from agent_framework import Agent, MCPStreamableHTTPTool
from agent_framework.openai import OpenAIChatClient
from agent_framework.openai import OpenAIResponsesClient
from azure.identity.aio import DefaultAzureCredential, get_bearer_token_provider
from dotenv import load_dotenv
from rich import print
Expand All @@ -24,33 +24,29 @@
MCP_SERVER_URL = os.getenv("MCP_SERVER_URL", "http://localhost:8000/mcp/")

# Configure chat client based on API_HOST
API_HOST = os.getenv("API_HOST", "github")
API_HOST = os.getenv("API_HOST", "azure")
async_credential = None

if API_HOST == "azure":
async_credential = DefaultAzureCredential()
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
client = OpenAIChatClient(
client = OpenAIResponsesClient(
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
api_key=token_provider,
model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
)
elif API_HOST == "github":
client = OpenAIChatClient(
base_url="https://models.github.ai/inference",
api_key=os.environ["GITHUB_TOKEN"],
model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4.1-mini"),
)
elif API_HOST == "ollama":
client = OpenAIChatClient(
client = OpenAIResponsesClient(
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
api_key="none",
model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"),
api_key=os.getenv("OLLAMA_API_KEY", "no-key-needed"),
model_id=os.environ.get("OLLAMA_MODEL", "qwen3.5:9b"),
)
else:
client = OpenAIChatClient(
api_key=os.environ.get("OPENAI_API_KEY"), model_id=os.environ.get("OPENAI_MODEL", "gpt-4.1-mini")
elif API_HOST == "openai":
client = OpenAIResponsesClient(
api_key=os.environ.get("OPENAI_API_KEY"), model_id=os.environ.get("OPENAI_MODEL", "gpt-5.2")
)
else:
raise ValueError(f"Unsupported API_HOST '{API_HOST}'. Use one of: azure, ollama, openai.")


# --- Main Agent Logic ---
Expand Down
26 changes: 11 additions & 15 deletions agents/agentframework_learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

from agent_framework import Agent, MCPStreamableHTTPTool
from agent_framework.openai import OpenAIChatClient
from agent_framework.openai import OpenAIResponsesClient
from azure.identity.aio import DefaultAzureCredential, get_bearer_token_provider
from dotenv import load_dotenv
from rich import print
Expand All @@ -18,32 +18,28 @@
load_dotenv(override=True)

# Configure chat client based on API_HOST
API_HOST = os.getenv("API_HOST", "github")
API_HOST = os.getenv("API_HOST", "azure")
async_credential = None
if API_HOST == "azure":
async_credential = DefaultAzureCredential()
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
client = OpenAIChatClient(
client = OpenAIResponsesClient(
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
api_key=token_provider,
model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
)
elif API_HOST == "github":
client = OpenAIChatClient(
base_url="https://models.github.ai/inference",
api_key=os.environ["GITHUB_TOKEN"],
model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4.1-mini"),
)
elif API_HOST == "ollama":
client = OpenAIChatClient(
client = OpenAIResponsesClient(
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
api_key="none",
model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"),
api_key=os.getenv("OLLAMA_API_KEY", "no-key-needed"),
model_id=os.environ.get("OLLAMA_MODEL", "qwen3.5:9b"),
)
else:
client = OpenAIChatClient(
api_key=os.environ.get("OPENAI_API_KEY"), model_id=os.environ.get("OPENAI_MODEL", "gpt-4.1-mini")
elif API_HOST == "openai":
client = OpenAIResponsesClient(
api_key=os.environ.get("OPENAI_API_KEY"), model_id=os.environ.get("OPENAI_MODEL", "gpt-5.2")
)
else:
raise ValueError(f"Unsupported API_HOST '{API_HOST}'. Use one of: azure, ollama, openai.")


async def http_mcp_example() -> None:
Expand Down
29 changes: 17 additions & 12 deletions agents/langchainv1_github.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""LangChain MCP Tool Filtering Example

Demonstrates how to filter MCP tools to create safe, focused agents.
Shows filtering for read-only research agent using GitHub MCP server.
Shows filtering for a read-only research agent using the GitHub MCP server
with a Responses-compatible model host.
"""

import asyncio
Expand All @@ -21,7 +22,7 @@
load_dotenv(override=True)

# Configure model
API_HOST = os.getenv("API_HOST", "github")
API_HOST = os.getenv("API_HOST", "azure")
if API_HOST == "azure":
token_provider = azure.identity.get_bearer_token_provider(
azure.identity.DefaultAzureCredential(),
Expand All @@ -31,19 +32,23 @@
model=os.environ.get("AZURE_OPENAI_CHAT_DEPLOYMENT"),
base_url=os.environ["AZURE_OPENAI_ENDPOINT"] + "/openai/v1/",
api_key=token_provider,
)
elif API_HOST == "github":
model = ChatOpenAI(
model=os.getenv("GITHUB_MODEL", "gpt-4o"),
base_url="https://models.inference.ai.azure.com",
api_key=SecretStr(os.environ["GITHUB_TOKEN"]),
use_responses_api=True,
)
elif API_HOST == "ollama":
model = ChatOpenAI(
model=os.environ.get("OLLAMA_MODEL", "llama3.1"),
model=os.environ.get("OLLAMA_MODEL", "qwen3.5:9b"),
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
api_key=SecretStr("none"),
api_key=SecretStr(os.getenv("OLLAMA_API_KEY", "no-key-needed")),
use_responses_api=True,
)
elif API_HOST == "openai":
model = ChatOpenAI(
model=os.getenv("OPENAI_MODEL", "gpt-5.2"),
api_key=SecretStr(os.environ["OPENAI_API_KEY"]),
use_responses_api=True,
)
else:
raise ValueError(f"Unsupported API_HOST '{API_HOST}'. Use one of: azure, ollama, openai.")

console = Console()

Expand Down Expand Up @@ -90,12 +95,12 @@ async def main():
prompt="You help users research GitHub repositories. Search and analyze information.",
)

query = "Find 5 popular Python MCP server repositories and describe in a bulleted list."
query = "Make a list of last 5 issues from the 'PrefectHQ/FastMCP' repository that discuss auth."
rprint(f"[bold]Query:[/bold] {query}\n")

try:
result = await agent.ainvoke({"messages": [HumanMessage(content=query)]})
rprint(f"[bold green]Result:[/bold green]\n{result['messages'][-1].content}\n")
rprint(f"[bold green]Result:[/bold green]\n{result['messages'][-1].text}\n")
except Exception as e:
rprint(f"[bold red]Error:[/bold red] {str(e)}\n")

Expand Down
24 changes: 13 additions & 11 deletions agents/langchainv1_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
MCP_SERVER_URL = os.getenv("MCP_SERVER_URL", "http://localhost:8000/mcp/")

# Configure language model based on API_HOST
API_HOST = os.getenv("API_HOST", "github")
API_HOST = os.getenv("API_HOST", "azure")

if API_HOST == "azure":
token_provider = azure.identity.get_bearer_token_provider(
Expand All @@ -34,21 +34,23 @@
model=os.environ.get("AZURE_OPENAI_CHAT_DEPLOYMENT"),
base_url=os.environ["AZURE_OPENAI_ENDPOINT"] + "/openai/v1/",
api_key=token_provider,
)
elif API_HOST == "github":
base_model = ChatOpenAI(
model=os.getenv("GITHUB_MODEL", "gpt-4o"),
base_url="https://models.inference.ai.azure.com",
api_key=SecretStr(os.environ["GITHUB_TOKEN"]),
use_responses_api=True,
)
elif API_HOST == "ollama":
base_model = ChatOpenAI(
model=os.environ.get("OLLAMA_MODEL", "llama3.1"),
model=os.environ.get("OLLAMA_MODEL", "qwen3.5:9b"),
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
api_key=SecretStr(os.environ["OLLAMA_API_KEY"]),
api_key=SecretStr(os.getenv("OLLAMA_API_KEY", "no-key-needed")),
use_responses_api=True,
)
elif API_HOST == "openai":
base_model = ChatOpenAI(
model=os.getenv("OPENAI_MODEL", "gpt-5.2"),
api_key=SecretStr(os.environ["OPENAI_API_KEY"]),
use_responses_api=True,
)
else:
base_model = ChatOpenAI(model=os.getenv("OPENAI_MODEL", "gpt-4o-mini"))
raise ValueError(f"Unsupported API_HOST '{API_HOST}'. Use one of: azure, ollama, openai.")


async def run_agent() -> None:
Expand Down Expand Up @@ -79,7 +81,7 @@ async def run_agent() -> None:
)

# Display result
final_response = response["messages"][-1].content
final_response = response["messages"][-1].text
print(final_response)


Expand Down
6 changes: 3 additions & 3 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {

var prefix = '${name}-${resourceToken}'

var openAiDeploymentName = 'gpt-4o-mini'
var openAiModelName = 'gpt-4o-mini'
var openAiDeploymentName = 'gpt-5.2'
var openAiModelName = 'gpt-5.2'

// Cosmos DB configuration
var cosmosDbDatabaseName = 'expenses-database'
Expand Down Expand Up @@ -150,7 +150,7 @@ module openAi 'br/public:avm/res/cognitive-services/account:0.7.2' = {
model: {
format: 'OpenAI'
name: openAiModelName
version: '2024-07-18'
version: '2025-12-11'
}
sku: {
name: 'GlobalStandard'
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies = [
"langchain-openai>=1.0.1",
"langchain-mcp-adapters>=0.1.11",
"azure-ai-agents>=1.1.0",
"agent-framework>=1.0.0rc5",
"agent-framework-core==1.0.0rc5",
"azure-cosmos>=4.9.0",
"azure-monitor-opentelemetry>=1.8.3",
"opentelemetry-instrumentation-starlette>=0.60b0",
Expand Down
5 changes: 2 additions & 3 deletions spanish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ Si no usas una de las opciones anteriores, necesitas:
```

6. Edita `.env` con tus credenciales de API. Elige uno de los siguientes proveedores definiendo `API_HOST`:
- `github` - GitHub Models (requiere `GITHUB_TOKEN`)
- `azure` - Azure OpenAI (requiere credenciales de Azure)
- `ollama` - Instancia local de Ollama
- `ollama` - Instancia local de Ollama con soporte para Responses API
- `openai` - OpenAI API (requiere `OPENAI_API_KEY`)

## Correr servidores MCP locales
Expand Down Expand Up @@ -279,7 +278,7 @@ Los precios varían por región y uso, así que no es posible predecir costos ex

Puedes usar la [calculadora de precios de Azure](https://azure.com/e/3987c81282c84410b491d28094030c9a) para estos recursos:

- **Azure OpenAI Service**: nivel S0, modelo GPT-4o-mini. El precio se basa en tokens. [Precios](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)
- **Azure OpenAI Service**: nivel S0, modelo GPT-5.2. El precio se basa en tokens. [Precios](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)
- **Azure Container Apps**: nivel de consumo. [Precios](https://azure.microsoft.com/pricing/details/container-apps/)
- **Azure Container Registry**: nivel estándar. [Precios](https://azure.microsoft.com/pricing/details/container-registry/)
- **Azure Cosmos DB**: nivel serverless. [Precios](https://azure.microsoft.com/pricing/details/cosmos-db/)
Expand Down
Loading
Loading