Tool and function calling
Tool Calling
Represents tool invocation details when an LLM needs to call external functions/plugins during generation:
Index
: Call sequence in chat streams (optional)ID
: Unique identifier for the tool callType
: Distinguishes between different tool-calling logicFunction
: Described by FunctionCall
with function detailsFunction Calling
Describes called function details:
Description
: Explains the call's purposeName
: Identifies the specific interfaceParameters
: Description of required arguments (typically JSON)Arguments
: Actual parameter string passed to the functionCommon Use Cases
1.
send_email(to: string, body: string)
get_current_weather(location: string, unit: 'celsius' | 'fahrenheit')
2.
"Who are my top customers?" →
get_customers(min_revenue: int, created_before: string, limit: int)
3.
extract_data(name: string, birthday: string)
sql_query(query: string)
Basic Function Calling Workflow
1.
Send user query + define available functions in
functions
parameter2.
Model may choose to call ≥1 functions. If calling:
3.
4.
修改于 2025-05-29 05:39:21