Skip to content

Commit 0553336

Browse files
authored
Update function-calling.md
Switched to ```csharp
1 parent 86a1393 commit 0553336

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

articles/ai-services/agents/how-to/tools/function-calling.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ In this example we are demonstrating how to use the local functions with the age
3434

3535
1. First, set up the configuration and create a `PersistentAgentsClient`. This client will be used for all interactions with the Azure AI Agents Service. This step also includes all necessary `using` directives.
3636

37-
```C# Snippet:AgentsFunctions_Step1_SetupClient
37+
```csharp
3838
using Azure;
3939
using Azure.AI.Agents.Persistent;
4040
using Azure.Identity;
@@ -53,7 +53,7 @@ PersistentAgentsClient client = new(projectEndpoint, new DefaultAzureCredential(
5353

5454
2. Next, define the local functions that the agent can call. For each function, create a `FunctionToolDefinition` that describes its name, purpose, and parameters to the agent. These functions and definitions are used by both synchronous and asynchronous agent operations.
5555

56-
```C# Snippet:AgentsFunctions_Step2_DefineFunctionTools
56+
```csharp
5757
string GetUserFavoriteCity() => "Seattle, WA";
5858
FunctionToolDefinition getUserFavoriteCityTool = new("getUserFavoriteCity", "Gets the user's favorite city.");
5959

@@ -113,7 +113,7 @@ FunctionToolDefinition getCurrentWeatherAtLocationTool = new(
113113

114114
3. Create a helper function, `GetResolvedToolOutput`. This function takes a `RequiredToolCall` (when the agent determines a local function should be executed) and invokes the appropriate C# function defined in the previous step. It then wraps the result in a `ToolOutput` object for the agent.
115115

116-
```C# Snippet:AgentsFunctions_Step3_GetResolvedToolOutput
116+
```csharp
117117
ToolOutput GetResolvedToolOutput(RequiredToolCall toolCall)
118118
{
119119
if (toolCall is RequiredFunctionToolCall functionToolCall)
@@ -147,7 +147,7 @@ ToolOutput GetResolvedToolOutput(RequiredToolCall toolCall)
147147

148148
Synchronous sample:
149149

150-
```C# Snippet:AgentsFunctions_Step4_CreateAgent_Sync
150+
```csharp
151151
PersistentAgent agent = client.Administration.CreateAgent(
152152
model: modelDeploymentName,
153153
name: "SDK Test Agent - Functions",
@@ -159,7 +159,7 @@ PersistentAgent agent = client.Administration.CreateAgent(
159159

160160
Asynchronous sample:
161161

162-
```C# Snippet:AgentsFunctions_Step4_CreateAgent_Async
162+
```csharp
163163
PersistentAgent agent = await client.Administration.CreateAgentAsync(
164164
model: modelDeploymentName,
165165
name: "SDK Test Agent - Functions",
@@ -173,7 +173,7 @@ PersistentAgent agent = await client.Administration.CreateAgentAsync(
173173

174174
Synchronous sample:
175175

176-
```C# Snippet:AgentsFunctions_Step5_CreateThreadAndMessage_Sync
176+
```csharp
177177
PersistentAgentThread thread = client.Threads.CreateThread();
178178

179179
client.Messages.CreateMessage(
@@ -184,7 +184,7 @@ client.Messages.CreateMessage(
184184

185185
Asynchronous sample:
186186

187-
```C# Snippet:AgentsFunctions_Step5_CreateThreadAndMessage_Async
187+
```csharp
188188
PersistentAgentThread thread = await client.Threads.CreateThreadAsync();
189189

190190
await client.Messages.CreateMessageAsync(
@@ -197,7 +197,7 @@ await client.Messages.CreateMessageAsync(
197197

198198
Synchronous sample:
199199

200-
```C# Snippet:AgentsFunctions_Step6_CreateAndPollRun_Sync
200+
```csharp
201201
ThreadRun run = client.Runs.CreateRun(thread.Id, agent.Id);
202202

203203
do
@@ -223,7 +223,7 @@ while (run.Status == RunStatus.Queued
223223

224224
Asynchronous sample:
225225

226-
```C# Snippet:AgentsFunctions_Step6_CreateAndPollRun_Async
226+
```csharp
227227
ThreadRun run = await client.Runs.CreateRunAsync(thread.Id, agent.Id);
228228

229229
do
@@ -255,7 +255,7 @@ while (run.Status == RunStatus.Queued
255255

256256
Synchronous sample:
257257

258-
```C# Snippet:AgentsFunctions_Step7_ProcessResults_Sync
258+
```csharp
259259
Pageable<ThreadMessage> messages = client.Messages.GetMessages(
260260
threadId: thread.Id,
261261
order: ListSortOrder.Ascending
@@ -277,7 +277,7 @@ foreach (ThreadMessage threadMessage in messages)
277277

278278
Asynchronous sample:
279279

280-
```C# Snippet:AgentsFunctions_Step7_ProcessResults_Async
280+
```csharp
281281
AsyncPageable<ThreadMessage> messages = client.Messages.GetMessagesAsync(
282282
threadId: thread.Id,
283283
order: ListSortOrder.Ascending
@@ -301,14 +301,14 @@ await foreach (ThreadMessage threadMessage in messages)
301301

302302
Synchronous sample:
303303

304-
```C# Snippet:AgentsFunctions_Step8_Cleanup_Sync
304+
```csharp
305305
client.Threads.DeleteThread(threadId: thread.Id);
306306
client.Administration.DeleteAgent(agentId: agent.Id);
307307
```
308308

309309
Asynchronous sample:
310310

311-
```C# Snippet:AgentsFunctions_Step8_Cleanup_Async
311+
```csharp
312312
await client.Threads.DeleteThreadAsync(threadId: thread.Id);
313313
await client.Administration.DeleteAgentAsync(agentId: agent.Id);
314314
```

0 commit comments

Comments
 (0)