Skip to content

Commit 61dce6d

Browse files
committed
consolidating code
1 parent dabd3ae commit 61dce6d

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,28 @@ Azure AI Agents supports function calling, which allows you to describe the stru
2929

3030
::: zone pivot="python"
3131

32+
## Example agent code
3233

33-
## Define a function for your agent to call
34-
Start by defining a function for your agent to call. When you create a function for an agent to call, you describe its structure with any required parameters in a docstring.
34+
> [!NOTE]
35+
> You can find a streaming example on [GitHub](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-agents/samples/agents_streaming/sample_agents_stream_eventhandler_with_functions.py).
36+
37+
Use the following code sample to create an agent and call the function.
3538

3639
```python
40+
import os, time
41+
from azure.identity import DefaultAzureCredential
42+
from azure.ai.projects import AIProjectClient
43+
from azure.ai.agents.models import FunctionTool
3744
import json
3845
import datetime
3946
from typing import Any, Callable, Set, Dict, List, Optional
4047

48+
49+
# Start by defining a function for your agent to call.
50+
# When you create a function for an agent to call, you describe its structure
51+
# with any required parameters in a docstring.
52+
53+
4154
def fetch_weather(location: str) -> str:
4255
"""
4356
Fetches the weather information for the specified location.
@@ -52,20 +65,6 @@ def fetch_weather(location: str) -> str:
5265

5366
# Define user functions
5467
user_functions = {fetch_weather}
55-
```
56-
57-
## Example agent code
58-
59-
> [!NOTE]
60-
> You can find a streaming example on [GitHub](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-agents/samples/agents_streaming/sample_agents_stream_eventhandler_with_functions.py).
61-
62-
Use the following code sample to create an agent and call the function.
63-
64-
```python
65-
import os, time
66-
from azure.identity import DefaultAzureCredential
67-
from azure.ai.projects import AIProjectClient
68-
from azure.ai.agents.models import FunctionTool
6968

7069
# Retrieve the project endpoint from environment variables
7170
project_endpoint = os.environ["PROJECT_ENDPOINT"]

0 commit comments

Comments
 (0)