Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
project_client = AIProjectClient(
endpoint=project_endpoint,
credential=DefaultAzureCredential(exclude_interactive_browser_credential=False), # Use Azure Default Credential for authentication
api_version="latest",
)

with project_client:
Expand Down Expand Up @@ -81,7 +80,7 @@

# Fetch and log all messages from the thread
messages = project_client.agents.messages.list(thread_id=thread.id, order=ListSortOrder.ASCENDING)
for message in messages.data:
for message in messages:
print(f"Role: {message.role}, Content: {message.content}")

# Delete the agent when done to clean up resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
DESCRIPTION:
This sample demonstrates how to use azure function agent operations from
the Azure Agents service using a synchronous client.

USAGE:
python sample_agents_azure_functions.py

Before running the sample:

pip install azure-ai-agents azure-identity

Set these environment variables with your own values:
1) PROJECT_ENDPOINT - the Azure AI Agents endpoint.
2) MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
2) MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
the "Models + endpoints" tab in your Azure AI Foundry project.
3) STORAGE_SERVICE_ENDPONT - the storage service queue endpoint, triggering Azure function.
Please see Getting Started with Azure Functions page for more information on Azure Functions:
Expand All @@ -38,7 +38,6 @@
project_client = AIProjectClient(
endpoint=project_endpoint,
credential=DefaultAzureCredential(),
api_version="latest", # Use the latest API version
)

# Use the project client within a context manager to ensure proper resource cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
project_client = AIProjectClient(
endpoint=project_endpoint,
credential=DefaultAzureCredential(exclude_interactive_browser_credential=False), # Use Azure Default Credential for authentication
api_version="latest",
)

with project_client:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@
project_endpoint = os.environ["PROJECT_ENDPOINT"] # Ensure the PROJECT_ENDPOINT environment variable is set
# Ensure the BING_CONNECTION_ID environment variable is set, following the format:
#"/subscriptions/<sub-id>/resourceGroups/<your-rg-name>/providers/Microsoft.CognitiveServices/accounts/<your-ai-services-name>/projects/<your-project-name>/connections/<your-bing-connection-name>"
conn_id = os.environ["BING_CONNECTION_ID"]
conn_id = os.environ["BING_CONNECTION_ID"]
model_deployment_name = os.environ["MODEL_DEPLOYMENT_NAME"] # Ensure the MODEL_DEPLOYMENT_NAME environment variable is set

# Initialize the AIProjectClient with the endpoint and credentials
project_client = AIProjectClient(
endpoint=project_endpoint,
credential=DefaultAzureCredential(), # Use Azure Default Credential for authentication
api_version="latest",
)

with project_client:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

Set these environment variables with your own values:
1) PROJECT_ENDPOINT - The Azure AI Agents endpoint.
2) MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
2) MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
the "Models + endpoints" tab in your Azure AI Foundry project.
"""

Expand All @@ -43,7 +43,6 @@
project_client = AIProjectClient(
endpoint=project_endpoint,
credential=DefaultAzureCredential(exclude_interactive_browser_credential=False), # Use Azure Default Credential for authentication
api_version="latest",
)

with project_client:
Expand Down Expand Up @@ -85,7 +84,7 @@

# Fetch and log all messages from the thread
messages = project_client.agents.messages.list(thread_id=thread.id)
for message in messages.data:
for message in messages:
print(f"Role: {message.role}, Content: {message.content}")

# Delete the agent after use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
project_client = AIProjectClient(
endpoint=project_endpoint,
credential=DefaultAzureCredential(exclude_interactive_browser_credential=False), # Use Azure Default Credential for authentication
api_version="latest",
)

with project_client:
Expand Down Expand Up @@ -103,5 +102,5 @@

# Fetch and log all messages from the thread
messages = project_client.agents.messages.list(thread_id=thread.id)
for message in messages.data:
for message in messages:
print(f"Role: {message.role}, Content: {message.content}")
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

Set these environment variables with your own values:
1) PROJECT_ENDPOINT - the Azure AI Agents endpoint.
2) MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
2) MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
the "Models + endpoints" tab in your Azure AI Foundry project.
"""
# Import necessary modules
Expand All @@ -33,7 +33,6 @@
project_client = AIProjectClient(
endpoint=project_endpoint, # Azure AI Agents endpoint
credential=DefaultAzureCredential(), # Use Azure Default Credential for authentication
api_version="latest", # Use the latest API version
)

# Initialize the FunctionTool with user-defined functions
Expand Down
17 changes: 8 additions & 9 deletions samples/microsoft/python/getting-started-agents/logic_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
"""
DESCRIPTION:
This sample demonstrates how to use agents with Logic Apps to execute the task of sending an email.

PREREQUISITES:
1) Create a Logic App within the same resource group as your Azure AI Project in Azure Portal
2) To configure your Logic App to send emails, you must include an HTTP request trigger that is
2) To configure your Logic App to send emails, you must include an HTTP request trigger that is
configured to accept JSON with 'to', 'subject', and 'body'. The guide to creating a Logic App Workflow
can be found here:
can be found here:
https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/agents-logic-apps#create-logic-apps-workflows-for-function-calling

USAGE:
python sample_agents_logic_apps.py

Before running the sample:

pip install azure-ai-agents azure-identity

Set this environment variables with your own values:
1) PROJECT_ENDPOINT - the Azure AI Agents endpoint.
2) MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
2) MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
the "Models + endpoints" tab in your Azure AI Foundry project.

Replace the following values in the sample with your own values:
Expand All @@ -40,7 +40,7 @@
from typing import Set
from azure.ai.agents.models import ToolSet, FunctionTool
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects import AIProjectClient

# Import user-defined functions and tools
from user_functions import fetch_current_datetime # Example user function to fetch current datetime
Expand All @@ -52,7 +52,6 @@
project_client = AIProjectClient(
endpoint=os.environ["PROJECT_ENDPOINT"], # Azure AI Agents endpoint from environment variables
credential=DefaultAzureCredential(), # Use Azure Default Credential for authentication
api_version="latest", # Use the latest API version
)

# Extract subscription ID and resource group name from environment variables
Expand Down
5 changes: 2 additions & 3 deletions samples/microsoft/python/getting-started-agents/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
project_client = AIProjectClient(
endpoint=os.environ["PROJECT_ENDPOINT"], # Ensure the PROJECT_ENDPOINT environment variable is set
credential=DefaultAzureCredential(), # Use Azure Default Credential for authentication
api_version="latest",
)

# Access the Azure OpenAI client for chat completions
Expand Down Expand Up @@ -85,7 +84,7 @@

# Fetch and log all messages from the thread
messages = project_client.agents.messages.list(thread_id=thread.id)
for message in messages.data:
for message in messages:
print(f"Role: {message.role}, Content: {message.content}")

# Delete the agent after use
Expand Down Expand Up @@ -133,7 +132,7 @@

result = project.evaluation.create_agent_evaluation(
thread=thread.id,
run=run.id,
run=run.id,
evaluators=[EvaluatorIds.AGENT_QUALITY_EVALUATOR])

# wait for evaluation to complete
Expand Down