Skip to content

Commit 50a8092

Browse files
authored
Merge pull request #3810 from MicrosoftDocs/main
3/28/2025 PM Publish
2 parents afeb7d1 + 624a4b4 commit 50a8092

15 files changed

+101
-227
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: 'How to use Agents with your licensed data'
3+
titleSuffix: Azure AI services
4+
description: Learn how to connect your licensed data for grounding with Azure AI Agent Service.
5+
services: cognitive-services
6+
manager: nitinme
7+
ms.service: azure
8+
ms.topic: how-to
9+
ms.date: 03/04/2025
10+
author: aahill
11+
ms.author: aahi
12+
recommendations: false
13+
---
14+
15+
# Bring your licensed data
16+
17+
Azure AI Agent Service integrates your own licensed data from specialized data providers,
18+
such as Tripadvisor. This integration enhances the quality of your agent's responses with high-quality, fresh data,
19+
such as travel guidance and reviews. These insights empower your agents to deliver nuanced, informed
20+
solutions tailored to specific use cases.
21+
22+
Tripadvisor is the first licensed data provider and you can ground with your licensed Tripadvisor data through the API, SDK, and Azure AI Foundry portal.
23+
24+
> [!IMPORTANT]
25+
> - Your use of connected non-Microsoft services is subject to the terms between you and the service provider. By connecting to a non-Microsoft service, you acknowledge that some of your data, such as prompt content, is passed to the non-Microsoft service, and/or your application might receive data from the non-Microsoft service. You're responsible for your use of non-Microsoft data.
26+
> - Grounding with licensed data incurs usage with licensed data providers, review the pricing plan with your selected licensed data providers.
27+
28+
## Prerequisites
29+
30+
* Obtain an API key for your [Tripadvisor developer account](https://www.tripadvisor.com/developers?screen=credentials).
31+
32+
## Setup
33+
1. Go to [Azure AI Foundry portal](https://ai.azure.com/) and select your AI Project. Select **Management Center**.
34+
35+
:::image type="content" source="../../media/tools/licensed-data/project-assets.png" alt-text="A screenshot showing the selectors for the management center for an AI project." lightbox="../../media/tools/licensed-data/project-assets.png":::
36+
37+
1. Select **+new connection** in the settings page.
38+
39+
:::image type="content" source="../../media/tools/licensed-data/connected-resources.png" alt-text="A screenshot showing the connections for the selected AI project." lightbox="../../media/tools/licensed-data/connected-resources.png":::
40+
41+
1. Select **custom keys** in **other resource types**.
42+
43+
:::image type="content" source="../../media/tools/licensed-data/custom-keys.png" alt-text="A screenshot showing the custom key option in the settings page." lightbox="../../media/tools/licensed-data/custom-keys.png":::
44+
45+
1. Enter the following information to create a connection to store your Tripadvisor key:
46+
1. Set **Custom keys** to "key", with the value being your Tripadvisor API key.
47+
1. Make sure **is secret** is checked.
48+
1. Set the connection name to your connection name. You use this connection name in your sample code or Foundry Portal later.
49+
1. For the **Access** setting, you can choose either *this project only* or *shared to all projects*. Just make sure in your code, the connection string of the project you entered has access to this connection.
50+
51+
:::image type="content" source="../../media/tools/licensed-data/connect-custom-resource.png" alt-text="A screenshot showing the screen for adding Tripadvisor connection information." lightbox="../../media/tools/licensed-data/connect-custom-resource.png":::
52+
53+
## Use Tripadvisor tool through Foundry portal
54+
55+
1. To use the Tripadvisor tool in the Azure AI Foundry, in the **Create and debug** screen for your agent, scroll down the **Setup** pane on the right to **action**. Then select **Add**.
56+
57+
:::image type="content" source="../../media/tools/knowledge-tools.png" alt-text="A screenshot showing the available tool categories in the Azure AI Foundry portal." lightbox="../../media/tools/knowledge-tools.png":::
58+
59+
1. Select **Tripadvisor** and follow the prompts to add the tool.
60+
61+
:::image type="content" source="../../media/tools/knowledge-tools-list.png" alt-text="A screenshot showing available knowledge tools." lightbox="../../media/tools/knowledge-tools-list.png":::
62+
63+
1. Give a name for your Tripadvisor tool and provide an optional description.
64+
65+
:::image type="content" source="../../media/tools/licensed-data/add-data-source.png" alt-text="A screenshot showing the Tripadvisor data source." lightbox="../../media/tools/licensed-data/add-data-source.png":::
66+
67+
1. Select the custom key connection you just created.
68+
69+
:::image type="content" source="../../media/tools/licensed-data/add-connection.png" alt-text="A screenshot showing the connection for your Tripadvisor tool, and a JSON example." lightbox="../../media/tools/licensed-data/add-connection.png":::
70+
71+
1. Finish and start chatting.
72+
73+
## Connect Tripadvisor through code-first experience
74+
75+
You can follow the instructions in [OpenAPI Spec tool](./openapi-spec.md) to connect Tripadvisor through OpenAPI spec.
76+
77+
1. Remember to store and import Tripadvisor OpenAPI spec. You can find it through Foundry Portal.
78+
79+
1. Make sure you have updated the authentication method to be `connection` and fill in the connection ID of your custom key connection.
80+
``` python
81+
auth = OpenApiConnectionAuthDetails(security_scheme=OpenApiConnectionSecurityScheme(connection_id="your_connection_id"))
82+
```

articles/ai-services/agents/includes/quickstart-csharp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: aahill
44
ms.author: aahi
55
ms.service: azure-ai-agent-service
66
ms.topic: include
7-
ms.date: 01/15/2025
7+
ms.date: 03/28/2025
88
---
99

1010
| [Reference documentation](/dotnet/api/overview/azure/ai.projects-readme) | [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Projects/tests/Samples) | [Library source code](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Projects) | [Package (NuGet)](https://www.nuget.org/packages/Azure.AI.Projects/) |
@@ -38,7 +38,7 @@ ms.date: 01/15/2025
3838
Install the .NET package to your project. For example if you're using the .NET CLI, run the following command.
3939

4040
```console
41-
dotnet add package Azure.AI.Projects
41+
dotnet add package Azure.AI.Projects --prerelease
4242
dotnet add package Azure.Identity
4343
```
4444

articles/ai-services/agents/includes/quickstart-javascript.md

Lines changed: 3 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: aahill
44
ms.author: aahi
55
ms.service: azure-ai-agent-service
66
ms.topic: include
7-
ms.date: 03/21/2025
7+
ms.date: 03/28/2025
88
ms.custom: devx-track-js
99
---
1010

@@ -88,112 +88,7 @@ Set this connection string as an environment variable named `PROJECT_CONNECTION_
8888

8989
Next, create an `index.js` file and paste in the code below:
9090

91-
```javascript
92-
// index.js
93-
import {
94-
AIProjectsClient,
95-
DoneEvent,
96-
ErrorEvent,
97-
isOutputOfType,
98-
MessageStreamEvent,
99-
RunStreamEvent,
100-
ToolUtility,
101-
} from "@azure/ai-projects";
102-
import { DefaultAzureCredential } from "@azure/identity";
103-
import dotenv from 'dotenv';
104-
105-
dotenv.config();
106-
107-
// Set the connection string from the environment variable
108-
const connectionString = process.env.PROJECT_CONNECTION_STRING;
109-
const model = "gpt-4o";
110-
111-
// Throw an error if the connection string is not set
112-
if (!connectionString) {
113-
throw new Error("Please set the PROJECT_CONNECTION_STRING environment variable.");
114-
}
115-
116-
export async function main() {
117-
const client = AIProjectsClient.fromConnectionString(
118-
connectionString || "",
119-
new DefaultAzureCredential(),
120-
);
121-
122-
// Step 1 code interpreter tool
123-
const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([]);
124-
125-
// Step 2 an agent
126-
const agent = await client.agents.createAgent(model, {
127-
name: "my-agent",
128-
instructions: "You are a helpful agent",
129-
tools: [codeInterpreterTool.definition],
130-
toolResources: codeInterpreterTool.resources,
131-
});
132-
133-
// Step 3 a thread
134-
const thread = await client.agents.createThread();
135-
136-
// Step 4 a message to thread
137-
await client.agents.createMessage(
138-
thread.id, {
139-
role: "user",
140-
content: "I need to solve the equation `3x + 11 = 14`. Can you help me?",
141-
});
142-
143-
// Intermission is now correlated with thread
144-
// Intermission messages will retrieve the message just added
145-
146-
// Step 5 the agent
147-
const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream();
148-
149-
for await (const eventMessage of streamEventMessages) {
150-
switch (eventMessage.event) {
151-
case RunStreamEvent.ThreadRunCreated:
152-
break;
153-
case MessageStreamEvent.ThreadMessageDelta:
154-
{
155-
const messageDelta = eventMessage.data;
156-
messageDelta.delta.content.forEach((contentPart) => {
157-
if (contentPart.type === "text") {
158-
const textContent = contentPart;
159-
const textValue = textContent.text?.value || "No text";
160-
}
161-
});
162-
}
163-
break;
164-
165-
case RunStreamEvent.ThreadRunCompleted:
166-
break;
167-
case ErrorEvent.Error:
168-
console.log(`An error occurred. Data ${eventMessage.data}`);
169-
break;
170-
case DoneEvent.Done:
171-
break;
172-
}
173-
}
174-
175-
// 6. Print the messages from the agent
176-
const messages = await client.agents.listMessages(thread.id);
177-
178-
// Messages iterate from oldest to newest
179-
// messages[0] is the most recent
180-
const messagesArray = messages.data;
181-
for (let i = messagesArray.length - 1; i >= 0; i--) {
182-
const m = messagesArray[i];
183-
console.log(`Type: ${m.content[0].type}`);
184-
if (isOutputOfType(m.content[0], "text")) {
185-
const textContent = m.content[0];
186-
console.log(`Text: ${textContent.text.value}`);
187-
}
188-
}
189-
190-
// 7. Delete the agent once done
191-
await client.agents.deleteAgent(agent.id);
192-
}
193-
194-
main().catch((err) => {
195-
console.error("The sample encountered an error:", err);
196-
});
197-
```
91+
:::code language="JavaScript" source="~/azure-typescript-e2e-apps/quickstarts/ai-agents/js/src/index.js":::
92+
19893

19994
Run the code using `node index.js` and observe.

articles/ai-services/agents/includes/quickstart-typescript.md

Lines changed: 2 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: aahill
44
ms.author: aahi
55
ms.service: azure-ai-agent-service
66
ms.topic: include
7-
ms.date: 03/21/2025
7+
ms.date: 03/28/2025
88
ms.custom: devx-track-ts
99
---
1010

@@ -72,118 +72,6 @@ For example, your connection string may look something like:
7272

7373
Set this connection string as an environment variable named `PROJECT_CONNECTION_STRING`.
7474

75-
```typescript
76-
// index.ts
77-
import {
78-
AIProjectsClient,
79-
DoneEvent,
80-
ErrorEvent,
81-
isOutputOfType,
82-
MessageStreamEvent,
83-
RunStreamEvent,
84-
ToolUtility
85-
} from "@azure/ai-projects";
86-
import type {
87-
MessageDeltaChunk,
88-
MessageDeltaTextContent,
89-
MessageTextContentOutput
90-
} from "@azure/ai-projects";
91-
import { DefaultAzureCredential } from "@azure/identity";
92-
import dotenv from 'dotenv';
93-
94-
dotenv.config();
95-
96-
// Set the connection string from the environment variable
97-
const connectionString = process.env.PROJECT_CONNECTION_STRING;
98-
const model = "gpt-4o";
99-
100-
// Throw an error if the connection string is not set
101-
if (!connectionString) {
102-
throw new Error("Please set the PROJECT_CONNECTION_STRING environment variable.");
103-
}
104-
105-
export async function main() {
106-
const client = AIProjectsClient.fromConnectionString(
107-
connectionString || "",
108-
new DefaultAzureCredential(),
109-
);
110-
111-
// Step 1 code interpreter tool
112-
const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([]);
113-
114-
// Step 2 an agent
115-
const agent = await client.agents.createAgent(model, {
116-
name: "my-agent",
117-
instructions: "You are a helpful agent",
118-
tools: [codeInterpreterTool.definition],
119-
toolResources: codeInterpreterTool.resources,
120-
});
121-
122-
// Step 3 a thread
123-
const thread = await client.agents.createThread();
124-
125-
// Step 4 a message to thread
126-
await client.agents.createMessage(
127-
thread.id, {
128-
role: "user",
129-
content: "I need to solve the equation `3x + 11 = 14`. Can you help me?",
130-
});
131-
132-
// Intermission is now correlated with thread
133-
// Intermission messages will retrieve the message just added
134-
135-
// Step 5 the agent
136-
const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream();
137-
138-
for await (const eventMessage of streamEventMessages) {
139-
switch (eventMessage.event) {
140-
case RunStreamEvent.ThreadRunCreated:
141-
break;
142-
case MessageStreamEvent.ThreadMessageDelta:
143-
{
144-
const messageDelta = eventMessage.data as MessageDeltaChunk;
145-
messageDelta.delta.content.forEach((contentPart) => {
146-
if (contentPart.type === "text") {
147-
const textContent = contentPart as MessageDeltaTextContent;
148-
const textValue = textContent.text?.value || "No text";
149-
}
150-
});
151-
}
152-
break;
153-
154-
case RunStreamEvent.ThreadRunCompleted:
155-
break;
156-
case ErrorEvent.Error:
157-
console.log(`An error occurred. Data ${eventMessage.data}`);
158-
break;
159-
case DoneEvent.Done:
160-
break;
161-
}
162-
}
163-
164-
// 6. Print the messages from the agent
165-
const messages = await client.agents.listMessages(thread.id);
166-
167-
// Messages iterate from oldest to newest
168-
// messages[0] is the most recent
169-
const messagesArray = messages.data;
170-
for (let i = messagesArray.length - 1; i >= 0; i--) {
171-
const m = messagesArray[i];
172-
console.log(`Type: ${m.content[0].type}`);
173-
if (isOutputOfType<MessageTextContentOutput>(m.content[0], "text")) {
174-
const textContent = m.content[0] as MessageTextContentOutput;
175-
console.log(`Text: ${textContent.text.value}`);
176-
}
177-
}
178-
179-
// 7. Delete the agent once done
180-
await client.agents.deleteAgent(agent.id);
181-
}
182-
183-
main().catch((err) => {
184-
console.error("The sample encountered an error:", err);
185-
});
186-
```
187-
75+
:::code language="TypeScript" source="~/azure-typescript-e2e-apps/quickstarts/ai-agents/ts/src/index.ts":::
18876

18977
Build the TypeScript code then run the code using `node index.js` and observe.
208 KB
Loading
120 KB
Loading
80.9 KB
Loading
28.4 KB
Loading
34.7 KB
Loading
40.8 KB
Loading

0 commit comments

Comments
 (0)