You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-foundry/agents/how-to/tools/function-calling.md
+15-16Lines changed: 15 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,15 +29,28 @@ Azure AI Agents supports function calling, which allows you to describe the stru
29
29
30
30
::: zone pivot="python"
31
31
32
+
## Example agent code
32
33
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.
35
38
36
39
```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
37
44
import json
38
45
import datetime
39
46
from typing import Any, Callable, Set, Dict, List, Optional
40
47
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
+
41
54
deffetch_weather(location: str) -> str:
42
55
"""
43
56
Fetches the weather information for the specified location.
> 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
69
68
70
69
# Retrieve the project endpoint from environment variables
0 commit comments