Skip to content

Commit 9bcb7c0

Browse files
Merge pull request #2045 from fosteramanda/main
updating function calling to include missing code
2 parents 012f77e + 11ff643 commit 9bcb7c0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ To use all features of function calling including parallel functions, you need t
3434

3535
## Define a function for your agent to call
3636

37-
Start by defining a function for your agent to call. When you create a function for an agent to call, you describe its structure of it with any required parameters.
37+
Start by defining a function for your agent to call. When you create a function for an agent to call, you describe its structure of it with any required parameters in a docstring. Include all your function definitions in a single file, `user_functions.py` which you can then import into your main script.
3838

3939
# [Python](#tab/python)
4040

4141
```python
42+
import json
43+
import datetime
44+
from typing import Any, Callable, Set, Dict, List, Optional
45+
4246
def fetch_weather(location: str) -> str:
4347
"""
4448
Fetches the weather information for the specified location.
@@ -53,6 +57,11 @@ def fetch_weather(location: str) -> str:
5357
weather = mock_weather_data.get(location, "Weather data not available for this location.")
5458
weather_json = json.dumps({"weather": weather})
5559
return weather_json
60+
61+
# Statically defined user functions for fast reference
62+
user_functions: Set[Callable[..., Any]] = {
63+
fetch_weather,
64+
}
5665
```
5766

5867

0 commit comments

Comments
 (0)