Skip to content

Commit 7a132a5

Browse files
committed
small updates
1 parent 7054531 commit 7a132a5

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

articles/ai-services/agents/how-to/tools/openapi-spec.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services: cognitive-services
66
manager: nitinme
77
ms.service: azure
88
ms.topic: how-to
9-
ms.date: 12/11/2024
9+
ms.date: 12/16/2024
1010
author: aahill
1111
ms.author: aahi
1212
zone_pivot_groups: selection-function-calling
@@ -25,7 +25,7 @@ OpenAPI Specified tool improves your function calling experience by providing st
2525
automated, and scalable API integrations that enhance the capabilities and efficiency of your agent.
2626
[OpenAPI specifications](https://spec.openapis.org/oas/latest.html) provide a formal standard for
2727
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.
2929

3030
## Set up
3131
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
117117
var storageQueueUri = TestEnvironment.STORAGE_QUEUE_URI;
118118
AgentsClient client = new(connectionString, new DefaultAzureCredential());
119119
var file_path = GetFile();
120-
````
120+
```
121121

122+
---
122123

123124
## 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+
125127
# [Python](#tab/python)
128+
126129
```python
127130
with open('./weather_openapi.json', 'r') as f:
128131
openapi_spec = jsonref.loads(f.read())
@@ -146,6 +149,7 @@ auth = OpenApiManagedAuthDetails(security_scheme=OpenApiManagedSecurityScheme(au
146149
An example of the audience would be ```https://cognitiveservices.azure.com/```.
147150
148151
# [C#](#tab/csharp)
152+
149153
```csharp
150154
#region Snippet:OpenAPIDefineFunctionTools
151155
OpenApiAnonymousAuthDetails oaiAuth = new();
@@ -158,7 +162,9 @@ An example of the audience would be ```https://cognitiveservices.azure.com/```.
158162
```
159163

160164
## Step 3: Create a thread
165+
161166
# [Python](#tab/python)
167+
162168
```python
163169
# Create agent with OpenApi tool and process assistant run
164170
with project_client:
@@ -188,9 +194,13 @@ Response<AgentThread> threadResponse = await client.CreateThreadAsync();
188194
AgentThread thread = threadResponse.Value;
189195
```
190196

197+
---
198+
191199
## Step 4: Create a run and check the output
192200
Create a run and observe that the model uses the OpenAPI Spec tool to provide a response to the user's question.
201+
193202
# [Python](#tab/python)
203+
194204
```python
195205
# Create message to thread
196206
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
215225
messages = project_client.agents.list_messages(thread_id=thread.id)
216226
print(f"Messages: {messages}")
217227
```
228+
218229
# [C#](#tab/csharp)
230+
219231
```csharp
220232
#region Snippet:OpenAPIHandlePollingWithRequiredAction
221233
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
258270
}
259271
}
260272
```
273+
274+
---
275+
261276
::: zone-end

0 commit comments

Comments
 (0)