Skip to content

Remove package function enable_telemetry() #41609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
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
53 changes: 49 additions & 4 deletions sdk/ai/azure-ai-projects/AGENTS_MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Agents migration guide from Hub-based projects to Endpoint-based projects.
This guide describes migration from hub-based to Endpoint-based projects. To create a Endpoint-based project, please use one of the deployment scripts on [foundry samples repository](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/infrastructure-setup) appropriate for your scenario, also you can use Azure AI Foundry UI. The support of hub-based projects was dropped in `azure-ai-projects` version `1.0.0b11`. In this document, we show the operation implementation of before `1.0.0b11` in **Hub-based** secion, followed by code for `azure-ai-projects` version `1.0.0b11` or later in **Endpoint-based**.
# Agents migration guide from Hub-based projects to Endpoint-based projects

This guide describes migration from hub-based to Endpoint-based projects. To create a Endpoint-based project, please use one of the deployment scripts on [foundry samples repository](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/infrastructure-setup) appropriate for your scenario, also you can use Azure AI Foundry UI. The support of hub-based projects was dropped in `azure-ai-projects` version `1.0.0b11`. In this document, we show the operation implementation of before `1.0.0b11` in **Hub-based** section, followed by code for `azure-ai-projects` version `1.0.0b11` or later in **Endpoint-based**.

## Import changes

Expand Down Expand Up @@ -109,9 +110,11 @@ Files Operations
| `project_client.agents.delete_file` | `project_client.agents.files.delete` |

## API changes

1. Create project. The connection string is replaced by the endpoint. The project endpoint URL has the form https://\<your-ai-services-account-name\>.services.ai.azure.com/api/projects/\<your-project-name\>. It can be found in your Azure AI Foundry Project overview page.

**Hub-based**

```python
project_client = AIProjectClient.from_connection_string(
credential=DefaultAzureCredential(),
Expand All @@ -120,22 +123,27 @@ Files Operations
```

**Endpoint-based**

```python
project_client = AIProjectClient(endpoint=endpoint, credential=DefaultAzureCredential())
```

2. Crate an agent. In the new versions of SDK, the agent can be created using project client or directly created by using `AgentsClient` constructor. In the code below, `project_client.agents`is an `AgentsClient` instance so `project_client.agents` and `agents_client` can be used interchangeably. For simplicity we will use ` project_client.agents `.

**Hub-based**

```python
agent = project_client.agents.create_agent(
model= "gpt-4o",
name="my-assistant",
instructions="You are helpful assistant",
)
```
**Endpoint-based**

Agent is instantiated using `AIProjectClient `
**Endpoint-based**

Agent is instantiated using `AIProjectClient`

```python
agent = project_client.agents.create_agent(
model="gpt-4o",
Expand All @@ -145,6 +153,7 @@ Files Operations
```

Agent is instantiated using `AgentsClient` constructor:

```python
from azure.ai.agents import AgentsClient

Expand All @@ -158,9 +167,11 @@ Files Operations
instructions="You are helpful agent",
)
```

3. List agents. New version of SDK allows more convenient ways of listing threads, messages and agents by returning `ItemPaged` and `AsyncItemPaged`. The list of returned items is split by pages, which may be consequently returned to user. Below we will demonstrate this mechanism for agents. The `limit` parameter defines the number of items on the page. This example is also applicable for listing threads, runs, run steps, vector stores, files in vector store, and messages.

**Hub-based**

```python
has_more = True
last_id = None
Expand All @@ -173,6 +184,7 @@ Files Operations
```

**Endpoint-based**

```python
agents = project_client.agents.list_agents(limit=2)
# Iterate items by page. Each page will be limited by two items.
Expand All @@ -190,29 +202,36 @@ Files Operations
4. Delete agent. In versions azure-ai-projects 1.0.0b11, all deletion operations used to return deletion status, for example, deletion of agent was returning `AgentDeletionStatus`. In 1.0.0b11 and later, these operations do not return a value.

**Hub-based**

```python
deletion_status = project_client.agents.delete_agent(agent.id)
print(deletion_status.deleted)
```

**Endpoint-based**

```python
project_client.agents.delete_agent(agent.id)
```

5. Create a thread.

**Hub-based**

```python
thread = project_client.agents.create_thread()
```

**Endpoint-based**

```python
thread = project_client.agents.threads.create()
```

6. List threads.

**Hub-based**

```python
with project_client:
last_id = None
Expand All @@ -229,6 +248,7 @@ Files Operations
```

**Endpoint-based**

```python
threads = project_client.agents.threads.list(limit=2)
# Iterate items by page. Each page will be limited by two items.
Expand All @@ -246,42 +266,52 @@ Files Operations
7. Delete the thread. In previous SDK thread deletion used to return ` ThreadDeletionStatus` object, while in new version it does not return value.

**Hub-based**

```python
delete_status = project_client.agents.delete_thread(tread_id)
print(delete_status.deleted)
```

**Endpoint-based**

```python
project_client.agents.threads.delete(tread_id)
```

8. Create the message on a thread.

**Hub-based**

```python
message = project_client.agents.create_message(thread_id=thread.id, role="user", content="The message text.")
```

**Endpoint-based**

```python
message = agents_client.messages.create(thread_id=thread.id, role="user", content=" The message text."")
```

9. Create and get the run.

**Hub-based**

```python
run = project_client.agents.runs.create(thread_id=thread.id, agent_id=agent.id)
run = project_client.agents.get_run(thread_id=thread.id, run_id=run.id)
```

**Endpoint-based**

```python
run = project_client.agents.runs.create(thread_id=thread.id, agent_id=agent.id)
run = project_client.agents.runs.get(thread_id=thread.id, run_id=run.id)
```

10. List Runs.

**Hub-based**

```python
has_more = True
last_id = None
Expand All @@ -294,6 +324,7 @@ Files Operations
```

**Endpoint-based**

```python
runs = project_client.agents.runs.list(thread.id)
for one_run in runs:
Expand All @@ -303,6 +334,7 @@ Files Operations
11. List Run steps.

**Hub-based**

```python
has_more = True
last_id = None
Expand All @@ -315,6 +347,7 @@ Files Operations
```

**Endpoint-based**

```python
run_steps = project_client.agents.run_steps.list(thread.id, run.id)
for one_run_step in run_steps:
Expand All @@ -324,6 +357,7 @@ Files Operations
12. Using streams.

**Hub-based**

```python
with project_client.agents.create_stream(thread_id=thread.id, agent_id=agent.id) as stream:
for event_type, event_data, func_return in stream:
Expand All @@ -334,6 +368,7 @@ Files Operations
```

**Endpoint-based**

```python
with project_client.agents.runs.stream(thread_id=thread.id, agent_id=agent.id, event_handler=MyEventHandler()) as stream:
for event_type, event_data, func_return in stream:
Expand All @@ -346,6 +381,7 @@ Files Operations
13. List messages.

**Hub-based**

```python
messages = project_client.agents.list_messages(thread_id=thread.id)
# In code below we assume that the number of messages fits one page for brevity.
Expand All @@ -356,16 +392,19 @@ Files Operations
```

**Endpoint-based**

```python
messages = project_client.agents.messages.list(thread_id=thread.id)
for msg in messages:
if msg.text_messages:
last_text = msg.text_messages[-1]
print(f"{msg.role}: {last_text.text.value}")
```

14. Create, list and delete files are now handled by file operations, again, delete call in new SDK version does not return a value.

**Hub-based**

```python
# Create file
file = project_client.agents.upload_file_and_poll(file_path="product_info_1.md", purpose=FilePurpose.AGENTS)
Expand All @@ -379,6 +418,7 @@ Files Operations
```

**Endpoint-based**

```python
# Create file
file = project_client.agents.files.upload_and_poll(file_path=asset_file_path, purpose=FilePurpose.AGENTS)
Expand All @@ -389,9 +429,11 @@ Files Operations
# Delete file.
project_client.agents.files.delete(file_id=file.id)
```

15. Create, list vector store files list and delete vector stores.

**Hub-based**

```python
# Create a vector store with no file and wait for it to be processed
vector_store = project_client.agents.create_vector_store_and_poll(file_ids=[file.id], name="sample_vector_store")
Expand Down Expand Up @@ -421,6 +463,7 @@ Files Operations
```

**Endpoint-based**

```python
# Create a vector store with no file and wait for it to be processed
vector_store = project_client.agents.vector_stores.create_and_poll(file_ids=[file.id], name="my_vectorstore")
Expand All @@ -441,6 +484,7 @@ Files Operations
16. Vector store batch file search.

**Hub-based**

```python
# Batch upload files
vector_store_file_batch = project_client.agents.create_vector_store_file_batch_and_poll(
Expand All @@ -460,6 +504,7 @@ Files Operations
```

**Endpoint-based**

```python
# Batch upload files
vector_store_file_batch = project_client.agents.vector_store_file_batches.create_and_poll(
Expand Down
31 changes: 31 additions & 0 deletions sdk/ai/azure-ai-projects/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Release History

## 1.0.0b12 (Unreleased)

### Breaking changes

* These 3 methods on `AIProjectClient` were removed: `.inference.get_chat_completions_client()`,
`.inference.get_embeddings_client()`, `.inference.get_image_embeddings_client()`.
For guidance on obtaining an authenticated `azure-ai-inference` client for your AI Foundry Project,
refer to the updated samples in the `samples\inference\azure-ai-inference` directory. For example,
`sample_chat_completions_with_azure_ai_inference_client.py`. Alternatively, use the `.inference.get_azure_openai_client()` method
to get an authenticated `AzureOpenAI` client from the `openai` package, and perform chat completions. See samples
in the folder `samples\inference\azure-openai`.
* Method argument name changes:
* In method `.indexes.create_or_update()` argument `body` was renamed `index`.
* In method `.datasets.create_or_update()` argument `body` was renamed `dataset_version`.
* In method `.datasets.pending_upload()` argument `body` was renamed `pending_upload_request`.

### Bugs Fixed

* Fix to package function `enable_telemetry()` to correctly instrument `azure-ai-agents`.

### Sample updates

* Per mentioned above, the samples in the `samples\inference` folder were updated. They were moved into two new
sub-folders, one showing usage of AzureOpenAI client (no change there). The other showing usage of the
clients from the `azure-ai-inference` package (changes were made there).

### Other

* Set dependency on `azure-ai-agents` version `1.0.0` or above,
now that we have a stable release of the Agents package.

## 1.0.0b11 (2025-05-15)

There have been significant updates with the release of version 1.0.0b11, including breaking changes.
Expand Down
Loading