Function Calling allows the model to call external tools to enhance its capabilities.Notice#
The current version of the deepseek-chat
model's Function Calling capabilitity is unstable, which may result in looped calls or empty responses. We are actively working on a fix, and it is expected to be resolved in the next version.Sample Code#
Here is an example of using Function Calling to get the current weather information of the user's location, demonstrated with complete Python code.For the specific API format of Function Calling, please refer to the Chat Completion documentation.The execution flow of this example is as follows:1.
User: Asks about the current weather in Hangzhou
2.
Model: Returns the function get_weather({location: 'Hangzhou'})
3.
User: Calls the function get_weather({location: 'Hangzhou'})
and provides the result to the model
4.
Model: Returns in natural language, "The current temperature in Hangzhou is 24Β°C."
Note: In the above code, the functionality of the get_weather
function needs to be provided by the user. The model itself does not execute specific functions. Modified atΒ 2025-02-06 08:37:41