Skip to content

Commit 764d343

Browse files
authored
Merge pull request #3017 from MicrosoftDocs/main
Publish to live, Wednesday 4AM PST, 2/19
2 parents c8b07a8 + 8fbc857 commit 764d343

File tree

17 files changed

+1111
-30
lines changed

17 files changed

+1111
-30
lines changed

articles/ai-services/agents/how-to/tools/azure-ai-search.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ Use an existing Azure AI Search index with the agent's Azure AI Search tool.
3434

3535
## Usage support
3636

37-
|Azure AI foundry support | Python SDK | C# SDK | JavaScript SDK | Basic agent setup | Standard agent setup |
38-
|---------|---------|---------|---------|---------|---------|
39-
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
37+
|Azure AI foundry support | Python SDK | C# SDK | JavaScript SDK | REST API | Basic agent setup | Standard agent setup |
38+
|---------|---------|---------|---------|---------|---------|---------|
39+
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
4040

4141
[!INCLUDE [setup](../../includes/azure-search/setup.md)]
4242

articles/ai-services/agents/how-to/tools/azure-functions.md

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ You can find the template and code used here on [GitHub](https://github.com/Azur
3737

3838
## Usage support
3939

40-
|Azure AI foundry support | Python SDK | C# SDK | Basic agent setup | Standard agent setup |
41-
|---------|---------|---------|---------|---------|
42-
| | ✔️ | | | ✔️ |
40+
|Azure AI foundry support | Python SDK | C# SDK | REST API | Basic agent setup | Standard agent setup |
41+
|---------|---------|---------|---------|---------|---------|
42+
| | ✔️ | | ✔️ | | ✔️ |
4343

4444
### Create Azure resources for local and cloud dev-test
4545

@@ -177,6 +177,7 @@ def process_queue_message(msg: func.QueueMessage) -> None:
177177

178178
In the sample below we create a client and an agent that has the tools definition for the Azure Function
179179

180+
# [Python](#tab/python)
180181
```python
181182
# Initialize the client and create agent for the tools Azure Functions that the agent can use
182183

@@ -230,16 +231,74 @@ agent = project_client.agents.create_agent(
230231
)
231232
```
232233

234+
# [REST API](#tab/rest)
235+
Follow the [REST API Quickstart](../../quickstart.md?pivots=rest-api) to set the right values for the environment variables `AZURE_AI_AGENTS_TOKEN` and `AZURE_AI_AGENTS_ENDPOINT`. The create the agent using:
236+
```console
237+
curl $AZURE_AI_AGENTS_ENDPOINT/assistants?api-version=2024-12-01-preview \
238+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
239+
-H "Content-Type: application/json" \
240+
-d '{
241+
"instructions": "You are a helpful support agent. Answer the user's questions to the best of your ability.",
242+
"name": "azure-function-agent-get-weather",
243+
"model": "gpt-4o-mini",
244+
"tools": [
245+
{
246+
"type": "azure_function",
247+
"azure_function": {
248+
"function": {
249+
"name": "GetWeather",
250+
"description": "Get the weather in a location.",
251+
"parameters": {
252+
"type": "object",
253+
"properties": {
254+
"location": {"type": "string", "description": "The location to look up."}
255+
},
256+
"required": ["location"]
257+
}
258+
},
259+
"input_binding": {
260+
"type": "storage_queue",
261+
"storage_queue": {
262+
"queue_service_endpoint": "https://storageaccount.queue.core.windows.net",
263+
"queue_name": "input"
264+
}
265+
},
266+
"output_binding": {
267+
"type": "storage_queue",
268+
"storage_queue": {
269+
"queue_service_endpoint": "https://storageaccount.queue.core.windows.net",
270+
"queue_name": "output"
271+
}
272+
}
273+
}
274+
}
275+
]
276+
}'
277+
```
278+
279+
---
280+
233281
## Create a thread for the agent
234282

283+
# [Python](#tab/python)
235284
```python
236285
# Create a thread
237286
thread = project_client.agents.create_thread()
238287
print(f"Created thread, thread ID: {thread.id}")
239288
```
240289

290+
# [REST API](#tab/rest)
291+
```console
292+
curl $AZURE_AI_AGENTS_ENDPOINT/threads?api-version=2024-12-01-preview \
293+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
294+
-H "Content-Type: application/json" \
295+
-d ''
296+
```
297+
---
298+
241299
## Create a run and check the output
242300

301+
# [Python](#tab/python)
243302
```python
244303
# Send the prompt to the agent
245304
message = project_client.agents.create_message(
@@ -261,9 +320,35 @@ while run.status in ["queued", "in_progress", "requires_action"]:
261320

262321
print(f"Run finished with status: {run.status}")
263322
```
323+
# [REST API](#tab/rest)
324+
```console
325+
curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/messages?api-version=2024-12-01-preview \
326+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
327+
-H "Content-Type: application/json" \
328+
-d '{
329+
"role": "user",
330+
"content": "What is the weather in Seattle, WA?"
331+
}'
332+
```
333+
334+
```console
335+
curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/runs?api-version=2024-12-01-preview \
336+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
337+
-H "Content-Type: application/json" \
338+
-d '{
339+
"assistant_id": "asst_abc123",
340+
}'
341+
```
264342

265-
### Get the result of the run
343+
```console
344+
curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/runs/run_abc123?api-version=2024-12-01-preview \
345+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
346+
```
347+
348+
---
349+
## Get the result of the run
266350

351+
# [Python](#tab/python)
267352
```python
268353
# Get messages from the assistant thread
269354
messages = project_client.agents.get_messages(thread_id=thread.id)
@@ -279,4 +364,10 @@ project_client.agents.delete_agent(agent.id)
279364
print("Deleted agent")
280365
```
281366

367+
# [REST API](#tab/rest)
368+
```console
369+
curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/messages?api-version=2024-12-01-preview \
370+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
371+
```
372+
282373
::: zone-end

articles/ai-services/agents/how-to/tools/bing-grounding.md

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ Developers and end users don't have access to raw content returned from Groundin
3030
3131
## Usage support
3232

33-
|Azure AI foundry support | Python SDK | C# SDK | JavaScript SDK |Basic agent setup | Standard agent setup |
34-
|---------|---------|---------|---------|---------|---------|
35-
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
33+
|Azure AI foundry support | Python SDK | C# SDK | JavaScript SDK | REST API |Basic agent setup | Standard agent setup |
34+
|---------|---------|---------|---------|---------|---------|---------|
35+
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
3636

3737
## Setup
3838

@@ -97,7 +97,7 @@ Your use of Grounding with Bing Search will be governed by the Terms of Use. By
9797

9898
::: zone pivot="code-example"
9999

100-
## Step 1: Create an agent with Grounding with Bing Search
100+
## Step 1: Create a project client
101101

102102
Create a client object, which will contain the connection string for connecting to your AI project and other resources.
103103

@@ -155,9 +155,12 @@ const client = AIProjectsClient.fromConnectionString(
155155
);
156156
```
157157

158+
# [REST API](#tab/rest)
159+
Follow the [REST API Quickstart](../../quickstart.md?pivots=rest-api) to set the right values for the environment variables `AZURE_AI_AGENTS_TOKEN` and `AZURE_AI_AGENTS_ENDPOINT`.
160+
158161
---
159162

160-
## Step 2: Enable the Grounding with Bing search tool
163+
## Step 2: Create an Agent with the Grounding with Bing search tool enabled
161164

162165
To make the Grounding with Bing search tool available to your agent, use a connection to initialize the tool and attach it to the agent. You can find your connection in the **connected resources** section of your project in the Azure AI Foundry portal.
163166

@@ -224,6 +227,30 @@ const agent = await client.agents.createAgent("gpt-4o", {
224227
console.log(`Created agent, agent ID : ${agent.id}`);
225228
```
226229

230+
# [REST API](#tab/rest)
231+
```console
232+
curl $AZURE_AI_AGENTS_ENDPOINT/assistants?api-version=2024-12-01-preview \
233+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
234+
-H "Content-Type: application/json" \
235+
-d '{
236+
"instructions": "You are a helpful agent.",
237+
"name": "my-agent",
238+
"model": "gpt-4o",
239+
"tools": [
240+
{
241+
"type": "bing_grounding",
242+
"bing_grounding": {
243+
"connections": [
244+
{
245+
"connection_id": "/subscriptions/<your-subscription-id>/resourceGroups/<your-resource-group>/providers/Microsoft.MachineLearningServices/workspaces/<your-project-name>/connections/<your-bing-connection-name>"
246+
}
247+
]
248+
}
249+
}
250+
]
251+
}'
252+
```
253+
227254
---
228255

229256

@@ -274,6 +301,28 @@ await client.agents.createMessage(
274301
});
275302
```
276303

304+
# [REST API](#tab/rest)
305+
### Create a thread
306+
307+
```console
308+
curl $AZURE_AI_AGENTS_ENDPOINT/threads?api-version=2024-12-01-preview \
309+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
310+
-H "Content-Type: application/json" \
311+
-d ''
312+
```
313+
314+
### Add a user question to the thread
315+
316+
```console
317+
curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/messages?api-version=2024-12-01-preview \
318+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
319+
-H "Content-Type: application/json" \
320+
-d '{
321+
"role": "user",
322+
"content": "What is the weather in Seattle?"
323+
}'
324+
```
325+
277326
---
278327

279328
## Step 4: Create a run and check the output
@@ -390,6 +439,32 @@ foreach (ThreadMessage threadMessage in messages)
390439
}
391440
```
392441
442+
# [REST API](#tab/rest)
443+
### Run the thread
444+
445+
```console
446+
curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/runs?api-version=2024-12-01-preview \
447+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
448+
-H "Content-Type: application/json" \
449+
-d '{
450+
"assistant_id": "asst_abc123",
451+
}'
452+
```
453+
454+
### Retrieve the status of the run
455+
456+
```console
457+
curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/runs/run_abc123?api-version=2024-12-01-preview \
458+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
459+
```
460+
461+
### Retrieve the agent response
462+
463+
```console
464+
curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/messages?api-version=2024-12-01-preview \
465+
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
466+
```
467+
393468
---
394469
395470
::: zone-end

0 commit comments

Comments
 (0)