The developer writes the function and gpt-4-0613
and gpt-3.5-turbo-0613
to have the model intelligently choose the output of a JSON object containing the arguments to call these functions. This is a new way to more reliably connect GPT functionality with external tools and APIs.
These models are fine-tuned to detect when a function needs to be called (in response to user input) and respond with JSON that conforms to the function’s signature. Function calls allow developers to more reliably retrieve structured data from models. For example, developers can:
- Create a chatbot that calls external tools (such as the ChatGPT plugin) to answer questions
Convert a query like “Send an email to Anya to see if she would like to get coffee next Friday” into a function call like this: send_email(to: string, body: string)
or “What’s the weather like in Boston?” get_current_weather(location: string, unit: 'celsius' | 'fahrenheit')
.
- Convert natural language to API calls or database queries
Convert “Who are your top 10 customers this month?”For internal API calls such as get_customers_by_revenue(start_date: string, end_date: string, limit: int)
or in an SQL query using “How many orders did Acme, Inc. place last month?” sql_query(query: string)
.
- Extract structured data from text
Define a function called extract_people_data(people: [{name: string, birthday: string, location: string}])
extracts all people mentioned in Wikipedia articles.
These use cases are enabled by our new API parameters. /v1/chat/completions
the last stop, functions
and function_call
This allows developers to write functions in a model via JSON schema and optionally request the model to call a specific function. Read the developer documentation to get started, Add eval If you find a case where you can improve the function call