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
1 change: 1 addition & 0 deletions sdk/ai/azure-ai-projects/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ SHAREPOINT_PROJECT_CONNECTION_ID=
A2A_PROJECT_CONNECTION_ID=
BROWSER_AUTOMATION_PROJECT_CONNECTION_ID=
OPENAPI_PROJECT_CONNECTION_ID=
WORK_IQ_PROJECT_CONNECTION_ID=
AI_SEARCH_USER_INPUT=
SHAREPOINT_USER_INPUT=
FABRIC_USER_INPUT=
Expand Down
1 change: 1 addition & 0 deletions sdk/ai/azure-ai-projects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* New Agent tool `FabricIQPreviewTool`.
* New Agent tool `ToolboxSearchPreviewTool`.
* New string properties `description` and `name` added to all Agent tools.
* New `.beta.datasets` sub-client with data generation job operations: `create_generation_job`, `get_generation_job`, `list_generation_jobs`, `cancel_generation_job`, `delete_generation_job`.
* New read-only property `content_hash` on `CodeConfiguration`, returning the SHA-256 hex digest of the uploaded code zip.
* New evaluator generation job operations on `.beta.evaluators`: `create_generation_job`, `get_generation_job`, `list_generation_jobs`, `cancel_generation_job`, `delete_generation_job`.
Expand Down
90 changes: 90 additions & 0 deletions sdk/ai/azure-ai-projects/docs/subclients.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# AIProjectClient Subclients

This document lists all subclients available on `AIProjectClient` and their public method counts.

## Top-level Subclients

| Subclient | Class Name | Public Methods |
|-----------|------------|----------------|
| `agents` | AgentsOperations | 8 |
| `evaluation_rules` | EvaluationRulesOperations | 4 |
| `connections` | ConnectionsOperations | 3 |
| `datasets` | DatasetsOperations | 9 |
| `deployments` | DeploymentsOperations | 2 |
| `indexes` | IndexesOperations | 5 |
| `telemetry` | TelemetryOperations | 1 |
| `beta` | BetaOperations | 0 (container only) |

## Nested Subclients on `.beta`

| Subclient | Class Name | Public Methods |
|-----------|------------|----------------|
| `beta.agents` | BetaAgentsOperations | 10 |
| `beta.evaluation_taxonomies` | BetaEvaluationTaxonomiesOperations | 5 |
| `beta.evaluators` | BetaEvaluatorsOperations | 11 |
| `beta.insights` | BetaInsightsOperations | 3 |
| `beta.memory_stores` | BetaMemoryStoresOperations | 8 |
| `beta.red_teams` | BetaRedTeamsOperations | 3 |
| `beta.schedules` | BetaSchedulesOperations | 6 |
| `beta.toolboxes` | BetaToolboxesOperations | 8 |
| `beta.skills` | BetaSkillsOperations | 7 |
| `beta.datasets` | BetaDatasetsOperations | 5 |

## Summary

**Total: 98 unique public methods across all subclients**

---

### Method Details

#### AgentsOperations (8)
`get`, `delete`, `list`, `create_version`, `create_version_from_manifest`, `get_version`, `delete_version`, `list_versions`

#### EvaluationRulesOperations (4)
`get`, `delete`, `create_or_update`, `list`

#### ConnectionsOperations (3)
`list`, `get`, `get_default`

#### DatasetsOperations (9)
`list_versions`, `list`, `get`, `delete`, `create_or_update`, `pending_upload`, `get_credentials`, `upload_file`, `upload_folder`

#### DeploymentsOperations (2)
`get`, `list`

#### IndexesOperations (5)
`list_versions`, `list`, `get`, `delete`, `create_or_update`

#### TelemetryOperations (1)
`get_application_insights_connection_string`

#### BetaAgentsOperations (10)
`patch_agent_details`, `create_session`, `get_session`, `delete_session`, `list_sessions`, `get_session_log_stream`, `download_session_file`, `get_session_files`, `delete_session_file`, `upload_session_file`

#### BetaEvaluationTaxonomiesOperations (5)
`get`, `list`, `delete`, `create`, `update`

#### BetaEvaluatorsOperations (11)
`list_versions`, `list`, `get_version`, `delete_version`, `create_version`, `update_version`, `create_generation_job`, `get_generation_job`, `list_generation_jobs`, `cancel_generation_job`, `delete_generation_job`

#### BetaInsightsOperations (3)
`generate`, `get`, `list`

#### BetaMemoryStoresOperations (8)
`create`, `update`, `get`, `list`, `delete`, `delete_scope`, `search_memories`, `begin_update_memories`

#### BetaRedTeamsOperations (3)
`get`, `list`, `create`

#### BetaSchedulesOperations (6)
`delete`, `get`, `list`, `create_or_update`, `get_run`, `list_runs`

#### BetaToolboxesOperations (8)
`create_version`, `get`, `list`, `list_versions`, `get_version`, `update`, `delete`, `delete_version`

#### BetaSkillsOperations (7)
`create`, `create_from_package`, `get`, `download`, `list`, `update`, `delete`

#### BetaDatasetsOperations (5)
`get_generation_job`, `list_generation_jobs`, `create_generation_job`, `cancel_generation_job`, `delete_generation_job`
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------

"""
DESCRIPTION:
This sample demonstrates how to create an AI agent with WorkIQ capabilities
using the WorkIQPreviewTool and synchronous Azure AI Projects client. The agent can
access Microsoft 365 data through WorkIQ to provide insights from emails, calendar events,
Teams messages, and other Microsoft 365 content.

The sample shows:
- Creating an agent with WorkIQPreviewTool configured for Microsoft 365 data access
- Making requests that leverage WorkIQ to search and retrieve relevant information
- Processing responses with insights from Microsoft 365 content

USAGE:
python sample_agent_work_iq_preview.py

Before running the sample:

pip install "azure-ai-projects>=2.1.0" python-dotenv

Set these environment variables with your own values:
1) FOUNDRY_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview
page of your Microsoft Foundry portal.
2) FOUNDRY_MODEL_NAME - The deployment name of the AI model, as found under the "Name" column in
the "Models + endpoints" tab in your Microsoft Foundry project.
3) WORK_IQ_PROJECT_CONNECTION_ID - The WorkIQ project connection ID,
as found in the "Connections" tab in your Microsoft Foundry project.
"""

import os
from dotenv import load_dotenv
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import (
PromptAgentDefinition,
WorkIQPreviewTool,
WorkIQPreviewToolParameters,
)

load_dotenv()

endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]

with (
DefaultAzureCredential() as credential,
AIProjectClient(endpoint=endpoint, credential=credential) as project_client,
project_client.get_openai_client() as openai_client,
):

tool = WorkIQPreviewTool(
work_iq_preview=WorkIQPreviewToolParameters(
project_connection_id=os.environ["WORK_IQ_PROJECT_CONNECTION_ID"]
)
)

agent = project_client.agents.create_version(
agent_name="MyAgent",
definition=PromptAgentDefinition(
model=os.environ["FOUNDRY_MODEL_NAME"],
instructions="""You are a helpful assistant that can access Microsoft 365 data through WorkIQ.
Use the WorkIQ tool to search and retrieve information from emails, calendar events,
Teams messages, and other Microsoft 365 content to assist users with their questions.""",
tools=[tool],
),
description="Agent with WorkIQ capabilities for Microsoft 365 data access.",
)
print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})")

# Send a request that will trigger the WorkIQ tool
user_input = "What meetings do I have scheduled today?"
stream_response = openai_client.responses.create(
stream=True,
input=user_input,
extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}},
)

for event in stream_response:
if event.type == "response.created":
print(f"Response created with ID: {event.response.id}")
elif event.type == "response.output_text.delta":
print(f"Delta: {event.delta}")
elif event.type == "response.text.done":
print("\nResponse done!")
elif event.type == "response.output_item.done":
if event.item.type == "message":
item = event.item
if item.content[-1].type == "output_text":
text_content = item.content[-1]
for annotation in text_content.annotations:
if annotation.type == "url_citation":
print(
f"URL Citation: {annotation.url}, "
f"Start index: {annotation.start_index}, "
f"End index: {annotation.end_index}"
)
elif event.type == "response.completed":
print("\nResponse completed!")
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------

"""
DESCRIPTION:
This sample demonstrates how to create an AI agent with WorkIQ capabilities
using the WorkIQPreviewTool and synchronous Azure AI Projects client. The agent can
access Microsoft 365 data through WorkIQ to provide insights from emails, calendar events,
Teams messages, and other Microsoft 365 content.

This non-streaming version waits for the complete response before returning.

The sample shows:
- Creating an agent with WorkIQPreviewTool configured for Microsoft 365 data access
- Making requests that leverage WorkIQ to search and retrieve relevant information
- Processing responses with insights from Microsoft 365 content

USAGE:
python sample_agent_work_iq_preview_non_streaming.py

Before running the sample:

pip install "azure-ai-projects>=2.1.0" python-dotenv

Set these environment variables with your own values:
1) FOUNDRY_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview
page of your Microsoft Foundry portal.
2) FOUNDRY_MODEL_NAME - The deployment name of the AI model, as found under the "Name" column in
the "Models + endpoints" tab in your Microsoft Foundry project.
3) WORK_IQ_PROJECT_CONNECTION_ID - The WorkIQ project connection ID,
as found in the "Connections" tab in your Microsoft Foundry project.
"""

import os
from dotenv import load_dotenv
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import (
PromptAgentDefinition,
WorkIQPreviewTool,
WorkIQPreviewToolParameters,
)

load_dotenv()

endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"]

with (
DefaultAzureCredential() as credential,
AIProjectClient(endpoint=endpoint, credential=credential) as project_client,
project_client.get_openai_client() as openai_client,
):

tool = WorkIQPreviewTool(
work_iq_preview=WorkIQPreviewToolParameters(
project_connection_id=os.environ["WORK_IQ_PROJECT_CONNECTION_ID"]
)
)

agent = project_client.agents.create_version(
agent_name="MyAgent",
definition=PromptAgentDefinition(
model=os.environ["FOUNDRY_MODEL_NAME"],
instructions="""You are a helpful assistant that can access Microsoft 365 data through WorkIQ.
Use the WorkIQ tool to search and retrieve information from emails, calendar events,
Teams messages, and other Microsoft 365 content to assist users with their questions.""",
tools=[tool],
),
description="Agent with WorkIQ capabilities for Microsoft 365 data access.",
)
print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})")

# Send a request that will trigger the WorkIQ tool (non-streaming)
user_input = "What meetings do I have scheduled today?"
response = openai_client.responses.create(
input=user_input,
extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}},
)

print(f"Response output: {response.output_text}")
Loading