Skip to content

Commit 3afb96f

Browse files
committed
Address PR review comments: rename Azure AI Foundry to Microsoft Foundry, fix redis_history_provider.py consistency, clean up expenses.csv
1 parent c293d76 commit 3afb96f

9 files changed

Lines changed: 58 additions & 53 deletions

File tree

.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=YOUR-KEY;IngestionEndpo
1818
# Configure for Azure AI Search (used by agent_knowledge_aisearch.py):
1919
AZURE_SEARCH_ENDPOINT=https://YOUR-SEARCH-SERVICE.search.windows.net
2020
AZURE_SEARCH_KNOWLEDGE_BASE_NAME=YOUR-KB-NAME
21-
# Optional: Set to log evaluation results to Azure AI Foundry for rich visualization
21+
# Optional: Set to log evaluation results to Microsoft Foundry for rich visualization
2222
AZURE_AI_PROJECT=https://YOUR-ACCOUNT.services.ai.azure.com/api/projects/YOUR-PROJECT

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ urlFragment: python-agentframework-demos
1717
[![Open in GitHub Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https://codespaces.new/Azure-Samples/python-agentframework-demos)
1818
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/python-agentframework-demos)
1919

20-
This repository provides examples of [Microsoft Agent Framework](https://learn.microsoft.com/agent-framework/) using LLMs from [Azure AI Foundry](https://learn.microsoft.com/azure/ai-foundry/) or other model providers.
20+
This repository provides examples of [Microsoft Agent Framework](https://learn.microsoft.com/agent-framework/) using LLMs from [Microsoft Foundry](https://learn.microsoft.com/azure/ai-foundry/) or other model providers.
2121

2222
* [Getting started](#getting-started)
2323
* [GitHub Codespaces](#github-codespaces)
2424
* [VS Code Dev Containers](#vs-code-dev-containers)
2525
* [Local environment](#local-environment)
2626
* [Configuring model providers](#configuring-model-providers)
27-
* [Using Azure AI Foundry models](#using-azure-ai-foundry-models)
27+
* [Using Microsoft Foundry models](#using-microsoft-foundry-models)
2828
* [Using OpenAI.com models](#using-openaicom-models)
2929
* [Running the Python examples](#running-the-python-examples)
3030
* [Resources](#resources)
@@ -94,11 +94,11 @@ The dev container includes a Redis server, which is used by the `agent_history_r
9494

9595
## Configuring model providers
9696

97-
These examples can be run with Azure AI Foundry or OpenAI.com, depending on the environment variables you set. All the scripts reference the environment variables from a `.env` file, and an example `.env.sample` file is provided. Host-specific instructions are below.
97+
These examples can be run with Microsoft Foundry or OpenAI.com, depending on the environment variables you set. All the scripts reference the environment variables from a `.env` file, and an example `.env.sample` file is provided. Host-specific instructions are below.
9898

99-
## Using Azure AI Foundry models
99+
## Using Microsoft Foundry models
100100

101-
This project includes infrastructure as code (IaC) to provision Azure OpenAI deployments of "gpt-5.4" and "text-embedding-3-large" via Azure AI Foundry. The IaC is defined in the `infra` directory and uses the Azure Developer CLI to provision the resources.
101+
This project includes infrastructure as code (IaC) to provision Azure OpenAI deployments of "gpt-5.4" and "text-embedding-3-large" via Microsoft Foundry. The IaC is defined in the `infra` directory and uses the Azure Developer CLI to provision the resources.
102102

103103
1. Make sure the [Azure Developer CLI (azd)](https://aka.ms/install-azd) is installed.
104104

@@ -208,7 +208,7 @@ You can run the examples in this repository by executing the scripts in the `exa
208208
| [agent_otel_aspire.py](examples/agent_otel_aspire.py) | An agent with OpenTelemetry tracing, metrics, and structured logs exported to the [Aspire Dashboard](https://aspire.dev/dashboard/standalone/). |
209209
| [agent_otel_appinsights.py](examples/agent_otel_appinsights.py) | An agent with OpenTelemetry tracing, metrics, and structured logs exported to [Azure Application Insights](https://learn.microsoft.com/azure/azure-monitor/app/app-insights-overview). Requires Azure provisioning via `azd provision`. |
210210
| [agent_evaluation_generate.py](examples/agent_evaluation_generate.py) | Generate synthetic evaluation data for the travel planner agent. |
211-
| [agent_evaluation.py](examples/agent_evaluation.py) | Evaluate a travel planner agent using [Azure AI Evaluation](https://learn.microsoft.com/azure/ai-foundry/concepts/evaluation-evaluators/agent-evaluators) agent evaluators (IntentResolution, ToolCallAccuracy, TaskAdherence, ResponseCompleteness). Optionally set `AZURE_AI_PROJECT` in `.env` to log results to [Azure AI Foundry](https://learn.microsoft.com/azure/ai-foundry/how-to/develop/agent-evaluate-sdk). |
211+
| [agent_evaluation.py](examples/agent_evaluation.py) | Evaluate a travel planner agent using [Azure AI Evaluation](https://learn.microsoft.com/azure/ai-foundry/concepts/evaluation-evaluators/agent-evaluators) agent evaluators (IntentResolution, ToolCallAccuracy, TaskAdherence, ResponseCompleteness). Optionally set `AZURE_AI_PROJECT` in `.env` to log results to [Microsoft Foundry](https://learn.microsoft.com/azure/ai-foundry/how-to/develop/agent-evaluate-sdk). |
212212
| [agent_evaluation_batch.py](examples/agent_evaluation_batch.py) | Batch evaluation of agent responses using Azure AI Evaluation's `evaluate()` function. |
213213
| [agent_redteam.py](examples/agent_redteam.py) | Red-team a financial advisor agent using [Azure AI Evaluation](https://learn.microsoft.com/azure/ai-foundry/how-to/develop/red-teaming-agent) to test resilience against adversarial attacks across risk categories (Violence, HateUnfairness, Sexual, SelfHarm). Requires `AZURE_AI_PROJECT` in `.env`. |
214214
@@ -279,7 +279,7 @@ This example requires an `APPLICATIONINSIGHTS_CONNECTION_STRING` environment var
279279
280280
**Option A: Automatic via `azd provision`**
281281
282-
If you run `azd provision` (see [Using Azure AI Foundry models](#using-azure-ai-foundry-models)), the Application Insights resource is provisioned automatically and the connection string is written to your `.env` file.
282+
If you run `azd provision` (see [Using Microsoft Foundry models](#using-microsoft-foundry-models)), the Application Insights resource is provisioned automatically and the connection string is written to your `.env` file.
283283
284284
**Option B: Manual from the Azure Portal**
285285

examples/agent_evaluation_batch.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Batch evaluation of agent responses using Azure AI Evaluation's evaluate() function.
22
33
Reads evaluation data from a JSONL file (produced by agent_evaluation_generate.py) and runs
4-
all evaluators in a single batch call. Optionally logs results to Azure AI Foundry
4+
all evaluators in a single batch call. Optionally logs results to Microsoft Foundry
55
if AZURE_AI_PROJECT is set.
66
77
Usage:
88
python agent_evaluation_batch.py # uses eval_data.jsonl
9-
AZURE_AI_PROJECT=<url> python agent_evaluation_batch.py # logs to Azure AI Foundry
9+
AZURE_AI_PROJECT=<url> python agent_evaluation_batch.py # logs to Microsoft Foundry
1010
"""
1111

1212
import logging
@@ -48,7 +48,7 @@
4848
model=os.environ.get("OPENAI_MODEL", "gpt-5.4"),
4949
)
5050

51-
# Optional: Set AZURE_AI_PROJECT in .env to log results to Azure AI Foundry.
51+
# Optional: Set AZURE_AI_PROJECT in .env to log results to Microsoft Foundry.
5252
# Example: https://your-account.services.ai.azure.com/api/projects/your-project
5353
AZURE_AI_PROJECT = os.getenv("AZURE_AI_PROJECT")
5454

@@ -134,7 +134,7 @@ def main() -> None:
134134
if AZURE_AI_PROJECT:
135135
studio_url = eval_result.get("studio_url")
136136
if studio_url:
137-
print(f"\nView results in Azure AI Foundry:\n{studio_url}")
137+
print(f"\nView results in Microsoft Foundry:\n{studio_url}")
138138
else:
139139
logger.info("Results saved to eval_results.json")
140140

examples/expenses.csv

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
date,amount,category,description,payment_method
22
2026-02-08,1200.0,gadget,Laptop purchase,visa
3-
2026-04-02,1200.0,gadget,laptop,visa
4-
2026-04-02,1200.0,gadget,Compra de laptop,visa
5-
2026-04-02,1200.0,gadget,Laptop purchase,visa
6-
2026-04-02,1200.0,gadget,Compra de laptop,visa
7-
2026-04-02,1200.0,gadget,Compra de laptop,visa

examples/redis_history_provider.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Copyright (c) Microsoft. All rights reserved.
22

3+
"""
4+
Redis History Provider Session Example
5+
6+
This sample demonstrates how to use Redis as a history provider for session
7+
management, enabling persistent conversation history storage across sessions
8+
with Redis as the backend data store.
9+
"""
10+
311
import asyncio
412
import os
513
from uuid import uuid4
@@ -11,28 +19,27 @@
1119
from dotenv import load_dotenv
1220

1321
# Load environment variables from .env file
14-
load_dotenv()
15-
16-
"""
17-
Redis History Provider Session Example
18-
19-
This sample demonstrates how to use Redis as a history provider for session
20-
management, enabling persistent conversation history storage across sessions
21-
with Redis as the backend data store.
22-
"""
22+
load_dotenv(override=True)
23+
API_HOST = os.getenv("API_HOST", "azure")
2324

2425
# Default Redis URL for local Redis Stack.
2526
# Override via the REDIS_URL environment variable for remote or authenticated instances.
2627
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379")
2728

2829

29-
async_credential = DefaultAzureCredential()
30-
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
31-
client = OpenAIChatClient(
32-
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
33-
api_key=token_provider,
34-
model=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
35-
)
30+
async_credential = None
31+
if API_HOST == "azure":
32+
async_credential = DefaultAzureCredential()
33+
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
34+
client = OpenAIChatClient(
35+
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
36+
api_key=token_provider,
37+
model=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
38+
)
39+
else:
40+
client = OpenAIChatClient(
41+
api_key=os.environ["OPENAI_API_KEY"], model=os.environ.get("OPENAI_MODEL", "gpt-5.4")
42+
)
3643

3744

3845
async def example_manual_memory_store() -> None:
@@ -268,6 +275,9 @@ async def main() -> None:
268275
except Exception as e:
269276
print(f"Error running examples: {e}")
270277
raise
278+
finally:
279+
if async_credential:
280+
await async_credential.close()
271281

272282

273283
if __name__ == "__main__":

examples/spanish/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
---
33
name: Python Agent Framework Demos
4-
description: Colección de ejemplos en Python para Microsoft Agent Framework usando Azure AI Foundry.
4+
description: Colección de ejemplos en Python para Microsoft Agent Framework usando Microsoft Foundry.
55
languages:
66
- python
77
products:
@@ -18,14 +18,14 @@ urlFragment: python-agentframework-demos
1818
[![Abrir en GitHub Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https://codespaces.new/Azure-Samples/python-agentframework-demos)
1919
[![Abrir en Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/python-agentframework-demos)
2020

21-
Este repositorio ofrece ejemplos de [Microsoft Agent Framework](https://learn.microsoft.com/agent-framework/) usando LLMs de [Azure AI Foundry](https://learn.microsoft.com/azure/ai-foundry/) u otros proveedores de modelos.
21+
Este repositorio ofrece ejemplos de [Microsoft Agent Framework](https://learn.microsoft.com/agent-framework/) usando LLMs de [Microsoft Foundry](https://learn.microsoft.com/azure/ai-foundry/) u otros proveedores de modelos.
2222

2323
* [Cómo empezar](#cómo-empezar)
2424
* [GitHub Codespaces](#github-codespaces)
2525
* [VS Code Dev Containers](#vs-code-dev-containers)
2626
* [Entorno local](#entorno-local)
2727
* [Configurar proveedores de modelos](#configurar-proveedores-de-modelos)
28-
* [Usar modelos de Azure AI Foundry](#usar-modelos-de-azure-ai-foundry)
28+
* [Usar modelos de Microsoft Foundry](#usar-modelos-de-microsoft-foundry)
2929
* [Usar modelos de OpenAI.com](#usar-modelos-de-openaicom)
3030
* [Ejecutar los ejemplos en Python](#ejecutar-los-ejemplos-en-python)
3131
* [Recursos](#recursos)
@@ -95,11 +95,11 @@ El dev container incluye un servidor Redis, que se usa en el ejemplo `agent_hist
9595

9696
## Configurar proveedores de modelos
9797

98-
Estos ejemplos se pueden ejecutar con Azure AI Foundry u OpenAI.com, dependiendo de las variables de entorno que configures. Todos los scripts hacen referencia a las variables de entorno de un archivo `.env`, y se proporciona un archivo de ejemplo `.env.sample`. Las instrucciones específicas de cada proveedor se encuentran a continuación.
98+
Estos ejemplos se pueden ejecutar con Microsoft Foundry u OpenAI.com, dependiendo de las variables de entorno que configures. Todos los scripts hacen referencia a las variables de entorno de un archivo `.env`, y se proporciona un archivo de ejemplo `.env.sample`. Las instrucciones específicas de cada proveedor se encuentran a continuación.
9999

100-
## Usar modelos de Azure AI Foundry
100+
## Usar modelos de Microsoft Foundry
101101

102-
Este proyecto incluye infraestructura como código (IaC) para provisionar despliegues de Azure OpenAI de "gpt-5.4" y "text-embedding-3-large" a través de Azure AI Foundry. La IaC está definida en el directorio `infra` y usa Azure Developer CLI para provisionar los recursos.
102+
Este proyecto incluye infraestructura como código (IaC) para provisionar despliegues de Azure OpenAI de "gpt-5.4" y "text-embedding-3-large" a través de Microsoft Foundry. La IaC está definida en el directorio `infra` y usa Azure Developer CLI para provisionar los recursos.
103103

104104
1. Asegúrate de tener instalado [Azure Developer CLI (azd)](https://aka.ms/install-azd).
105105

@@ -203,7 +203,7 @@ Puedes ejecutar los ejemplos en este repositorio ejecutando los scripts en el di
203203
| [agent_otel_aspire.py](agent_otel_aspire.py) | Un agente con trazas, métricas y logs estructurados de OpenTelemetry exportados al [Aspire Dashboard](https://aspire.dev/dashboard/standalone/). |
204204
| [agent_otel_appinsights.py](agent_otel_appinsights.py) | Un agente con trazas, métricas y logs estructurados de OpenTelemetry exportados a [Azure Application Insights](https://learn.microsoft.com/azure/azure-monitor/app/app-insights-overview). Requiere aprovisionamiento de Azure con `azd provision`. |
205205
| [agent_evaluation_generate.py](agent_evaluation_generate.py) | Genera datos sintéticos de evaluación para el agente planificador de viajes. |
206-
| [agent_evaluation.py](agent_evaluation.py) | Evalúa un agente planificador de viajes usando evaluadores de [Azure AI Evaluation](https://learn.microsoft.com/azure/ai-foundry/concepts/evaluation-evaluators/agent-evaluators) (IntentResolution, ToolCallAccuracy, TaskAdherence, ResponseCompleteness). Opcionalmente configura `AZURE_AI_PROJECT` en `.env` para registrar resultados en [Azure AI Foundry](https://learn.microsoft.com/azure/ai-foundry/how-to/develop/agent-evaluate-sdk). |
206+
| [agent_evaluation.py](agent_evaluation.py) | Evalúa un agente planificador de viajes usando evaluadores de [Azure AI Evaluation](https://learn.microsoft.com/azure/ai-foundry/concepts/evaluation-evaluators/agent-evaluators) (IntentResolution, ToolCallAccuracy, TaskAdherence, ResponseCompleteness). Opcionalmente configura `AZURE_AI_PROJECT` en `.env` para registrar resultados en [Microsoft Foundry](https://learn.microsoft.com/azure/ai-foundry/how-to/develop/agent-evaluate-sdk). |
207207
| [agent_evaluation_batch.py](agent_evaluation_batch.py) | Evaluación por lotes de respuestas de agentes con la función `evaluate()` de Azure AI Evaluation. |
208208
| [agent_redteam.py](agent_redteam.py) | Prueba de red team a un agente asesor financiero usando [Azure AI Evaluation](https://learn.microsoft.com/azure/ai-foundry/how-to/develop/red-teaming-agent) para evaluar su resiliencia ante ataques adversariales en categorías de riesgo (Violence, HateUnfairness, Sexual, SelfHarm). Requiere `AZURE_AI_PROJECT` en `.env`. |
209209
@@ -274,7 +274,7 @@ Este ejemplo requiere la variable de entorno `APPLICATIONINSIGHTS_CONNECTION_STR
274274

275275
**Opción A: Automática con `azd provision`**
276276

277-
Si ejecutas `azd provision` (consulta [Usar modelos de Azure AI Foundry](#usar-modelos-de-azure-ai-foundry)), el recurso de Application Insights se provisiona automáticamente y la cadena de conexión se escribe en tu archivo `.env`.
277+
Si ejecutas `azd provision` (consulta [Usar modelos de Microsoft Foundry](#usar-modelos-de-microsoft-foundry)), el recurso de Application Insights se provisiona automáticamente y la cadena de conexión se escribe en tu archivo `.env`.
278278

279279
**Opción B: Manual desde el Portal de Azure**
280280

examples/spanish/agent_evaluation_batch.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
33
Lee datos de evaluación de un archivo JSONL (producido por agent_evaluation_generate.py) y ejecuta
44
todos los evaluadores en una sola llamada por lotes. Opcionalmente registra resultados en
5-
Azure AI Foundry si AZURE_AI_PROJECT está configurado.
5+
Microsoft Foundry si AZURE_AI_PROJECT está configurado.
66
77
Uso:
88
python agent_evaluation_batch.py # usa eval_data.jsonl
9-
AZURE_AI_PROJECT=<url> python agent_evaluation_batch.py # registra en Azure AI Foundry
9+
AZURE_AI_PROJECT=<url> python agent_evaluation_batch.py # registra en Microsoft Foundry
1010
"""
1111

1212
import logging
@@ -48,7 +48,7 @@
4848
model=os.environ.get("OPENAI_MODEL", "gpt-5.4"),
4949
)
5050

51-
# Opcional: Establece AZURE_AI_PROJECT en .env para registrar resultados en Azure AI Foundry.
51+
# Opcional: Establece AZURE_AI_PROJECT en .env para registrar resultados en Microsoft Foundry.
5252
# Ejemplo: https://tu-cuenta.services.ai.azure.com/api/projects/tu-proyecto
5353
AZURE_AI_PROJECT = os.getenv("AZURE_AI_PROJECT")
5454

@@ -134,7 +134,7 @@ def main() -> None:
134134
if AZURE_AI_PROJECT:
135135
studio_url = eval_result.get("studio_url")
136136
if studio_url:
137-
print(f"\nVer resultados en Azure AI Foundry:\n{studio_url}")
137+
print(f"\nVer resultados en Microsoft Foundry:\n{studio_url}")
138138
else:
139139
logger.info("Resultados guardados en eval_results.json")
140140

0 commit comments

Comments
 (0)