openAI sheep

OpenAI Announces Function Calling and Other API Updates

OpenAI has recently announced a series of updates to their API models, including more steerable API models, function calling capabilities, longer context, and lower prices. These updates are designed to enhance the capabilities of the models and provide developers with more flexibility and control.

One of the most significant updates is the introduction of function calling capabilities to the gpt-4-0613 and gpt-3.5-turbo-0613 models. Developers can now describe functions to these models, and the models can intelligently output a JSON object containing arguments to call those functions. This new feature provides a more reliable way to connect GPT’s capabilities with external tools and APIs.

These models have been fine-tuned to both detect when a function needs to be called (based on the user’s input) and to respond with JSON that adheres to the function signature. Function calling allows developers to more reliably get structured data back from the model.

Function Calling Use Cases

Here are some examples of how developers can leverage function calling:

  1. Creating Chatbots: Developers can create chatbots that answer questions by calling external tools, similar to ChatGPT Plugins.
  2. Converting Queries: Queries such as “Email Anya to see if she wants to get coffee next Friday” can be converted to a function call like send_email(to: string, body: string), or “What’s the weather like in Boston?” to get_current_weather(location: string, unit: 'celsius' | 'fahrenheit').
  3. Converting Natural Language into API Calls or Database Queries: Developers can convert natural language into API calls or database queries. For instance, “Who are my top ten customers this month?” can be converted to an internal API call such as get_customers_by_revenue(start_date: string, end_date: string, limit: int), or “How many orders did Acme, Inc. place last month?” to a SQL query using sql_query(query: string).
  4. Extracting Structured Data from Text: Developers can define a function called extract_people_data(people: [{name: string, birthday: string, location: string}]), to extract all people mentioned in a Wikipedia article.

These use cases are enabled by new API parameters in the /v1/chat/completions endpoint, functions and function_call, that allow developers to describe functions to the model via JSON Schema, and optionally ask it to call a specific function.

Developers can get started with these new features by referring to the developer documentation provided by OpenAI. OpenAI also encourages developers to add evaluations if they find cases where function calling could be improved.

The alpha release of ChatGPT plugins has provided OpenAI with insights into ensuring the safe integration of tools and language models. However, there remain unresolved research questions. For instance, a proof-of-concept exploit demonstrates how the model can be manipulated into performing unintended actions through untrusted data from a tool’s output. To safeguard their applications, developers are advised to only use data from reliable tools and to incorporate user confirmation steps before executing actions with tangible consequences, such as dispatching an email, publishing online, or executing a purchase.

Scroll to top