Function calling
1. Use Cases
The Function Calling feature enables the model to call external tools to enhance its capabilities. This capability can leverage external tools through the large model, such as searching for external knowledge, checking itineraries, or using specific domain tools, effectively addressing issues like hallucination and Knowledge Timeliness.
2. Usage
2.1 Adding tools Request Parameters via REST API
Add in the request body:
For example, complete payload information:
2.2 Request via OpenAI Library
This feature is compatible with OpenAI. When using the OpenAI library, add tools=[corresponding tools]
to the corresponding request parameters.
For example:
3. List of Supported Models
The current list of supported models includes:
-
Deepseek Series:
- deepseek-ai/DeepSeek-V2.5
- deepseek-ai/DeepSeek-V3
-
internlm Series:
- internlm/internlm2_5-20b-chat
- internlm/internlm2_5-7b-chat
- Pro/internlm/internlm2_5-7b-chat
-
Qwen Series:
- Qwen/Qwen2.5-72B-Instruct
- Qwen/Qwen2.5-32B-Instruct
- Qwen/Qwen2.5-14B-Instruct
- Qwen/Qwen2.5-7B-Instruct
- Pro/Qwen/Qwen2.5-7B-Instruct
-
GLM Series:
- THUDM/glm-4-9b-chat
- Pro/THUDM/glm-4-9b-chat
4. Usage Examples
4.1. Example 1: Extending Large Language Model’s Numerical Computation Capability via Function Calling
his code inputs 4 functions: addition, subtraction, comparison, and counting duplicate letters in a string. It demonstrates how to use function calling to address execution issues in domains where token prediction is not strong for large language models.
The model will output:
4.2. Example 2: Extending Large Language Model’s Understanding of External Environments via Function Calling This code inputs 1 function to query external information via an external API.
The model will output: