@@ -6,7 +6,7 @@ services: cognitive-services
6
6
manager : nitinme
7
7
ms.service : azure
8
8
ms.topic : how-to
9
- ms.date : 12/11 /2024
9
+ ms.date : 12/16 /2024
10
10
author : aahill
11
11
ms.author : aahi
12
12
zone_pivot_groups : selection-function-calling
@@ -25,7 +25,7 @@ OpenAPI Specified tool improves your function calling experience by providing st
25
25
automated, and scalable API integrations that enhance the capabilities and efficiency of your agent.
26
26
[ OpenAPI specifications] ( https://spec.openapis.org/oas/latest.html ) provide a formal standard for
27
27
describing HTTP APIs. This allows people to understand how an API works, how a sequence of APIs
28
- work together, generate client code, create tests, apply design standards, and much, much more.
28
+ work together, generate client code, create tests, apply design standards, and more.
29
29
30
30
## Set up
31
31
1 . Ensure you've completed the prerequisites and setup steps in the [ quickstart] ( ../../quickstart.md ) .
@@ -117,12 +117,15 @@ public partial class Sample_Agent_OpenAPI : SamplesBase<AIProjectsTestEnvironmen
117
117
var storageQueueUri = TestEnvironment .STORAGE_QUEUE_URI ;
118
118
AgentsClient client = new (connectionString , new DefaultAzureCredential ());
119
119
var file_path = GetFile ();
120
- ````
120
+ ```
121
121
122
+ -- -
122
123
123
124
## Step 2: Enable the OpenAPI Spec tool
124
- You may want to store the OpenAPI specification in another file and import the content to initialize the tool . Please note the sample code is using `anonymous ` as authentication type .
125
+ You might want to store the OpenAPI specification in another file and import the content to initialize the tool . Please note the sample code is using `anonymous ` as authentication type .
126
+
125
127
# [Python](#tab/python)
128
+
126
129
```python
127
130
with open ('./weather_openapi.json' , 'r' ) as f :
128
131
openapi_spec = jsonref .loads (f .read ())
@@ -146,6 +149,7 @@ auth = OpenApiManagedAuthDetails(security_scheme=OpenApiManagedSecurityScheme(au
146
149
An example of the audience would be ```https:// cognitiveservices.azure.com/```.
147
150
148
151
# [C#](#tab/csharp)
152
+
149
153
```csharp
150
154
#region Snippet:OpenAPIDefineFunctionTools
151
155
OpenApiAnonymousAuthDetails oaiAuth = new ();
@@ -158,7 +162,9 @@ An example of the audience would be ```https://cognitiveservices.azure.com/```.
158
162
```
159
163
160
164
## Step 3: Create a thread
165
+
161
166
# [Python](#tab/python)
167
+
162
168
```python
163
169
# Create agent with OpenApi tool and process assistant run
164
170
with project_client :
@@ -188,9 +194,13 @@ Response<AgentThread> threadResponse = await client.CreateThreadAsync();
188
194
AgentThread thread = threadResponse .Value ;
189
195
```
190
196
197
+ -- -
198
+
191
199
## Step 4: Create a run and check the output
192
200
Create a run and observe that the model uses the OpenAPI Spec tool to provide a response to the user 's question.
201
+
193
202
# [Python](#tab/python)
203
+
194
204
```python
195
205
# Create message to thread
196
206
message = project_client .agents .create_message (
@@ -215,7 +225,9 @@ Create a run and observe that the model uses the OpenAPI Spec tool to provide a
215
225
messages = project_client .agents .list_messages (thread_id = thread .id )
216
226
print (f " Messages: {messages}" )
217
227
```
228
+
218
229
# [C#](#tab/csharp)
230
+
219
231
```csharp
220
232
#region Snippet:OpenAPIHandlePollingWithRequiredAction
221
233
Response < ThreadMessage > messageResponse = await client .CreateMessageAsync (
@@ -258,4 +270,7 @@ Create a run and observe that the model uses the OpenAPI Spec tool to provide a
258
270
}
259
271
}
260
272
```
273
+
274
+ -- -
275
+
261
276
::: zone - end
0 commit comments