July 23, 2023

ChatGPT functions - a huge step in Generative AI

ChatGPT Function is the latest tech in AI and it could become a game-changer in the Generative AI industry.

Written by
Yuriy Pulyaev
CTO

OpenAI ChatGPT Functions

A couple of days ago OpenAI team released a pack of updates including new function calling capability. This is the newest approach in AI development services and it could become a game-changer in the Generative AI companies industry. Let`s start with the understanding of what are those ChatGPT functions, how they connected to generative AI technology, and why they are so important.

ChatGPT Function Calling

What is ChatGPT function calling?

Function calling is a new feature that allows Artificial Intelligence AI engineer to describe functions to the ChatGPT language model, enabling the model to respond with a JSON object containing arguments for those functions. This feature enhances the interaction between engineers and the Large Language Model (LLM) and provides a more structured and reliable way to leverage the model’s capabilities in various applications.

So, with the calling of any function, developers can define specific functions and their corresponding input arguments using JSON Schema. E.g., when a user interacts with ChatGPT and asks questions or provides input, the model can detect when a function needs to be called based on the user’s query. In response, ChatGPT generates a JSON object containing the necessary arguments for the identified function.

How does ChatGPT function work?

A function calling feature introduces the new parameter to the OpenAI ChatGPT API. This parameter list of functions. Each function has 3 fields: name, description, and its parameters. The name and description fields describe the name of the function and its functionality respectively.

The parameters field describes the parameters that the function takes. In order for the LLM to be able to generate an accurate function call, these parameters need to be described using the JSON schema specification. Let’s see how we may implement the ChatGPT function calling considering a stock market analysis example.

User input: “What’s the current price of Apple stocks?”

How ChatGPT Function Works

The model then generates a JSON output that can be used to call the get_stock_price function from your code.

When the large language model AI generates a function call in its response, it adds a new field function_call that contains the name of the function that the LLM wants to call and the values of the arguments for that function. We can easily read the value of the function_call field in the response and parse it as JSON.

If the LLM decides not to make a function call, then the function_call field in the response is not set, instead you will find the LLM’s reply in the content field. By checking if the function_call field is set in the response or not, we can know when the LLM is making a function call.

The rules of ChatGPT functions creation

There are several rules that will help you to create functions and avoid AI algorithms confusing.

ChatGPT Function Creation Rules

1. Limit the number of functions

An excessive number of choices can lead to ChatGPT functioning inaccurately. Additionally, function descriptions consume tokens, and every token incurs a cost. Therefore, it is important to offer access to only necessary functions and avoid redundancy.

2. Combine functions

AI works much better when it can call a single function instead of chaining multiple function interactions. If an action requires calls to various functions, it is better to combine them into a single function and allow AI to call that grouping function instead.

3. Input validation

Never assume that function arguments generated by the AI software are correct. Treat all data received from AI as potentially incorrect and validate everything. ChatGPT can make errors just like humans do.

4. Return helpful error messages

Please, remember that ChatGPT can correct function arguments if the error message explains what went wrong. If a specific interaction consistently fails, it is a sign that the prompt or function descriptions need improvement.

Summary

Function Calling has opened up exciting possibilities for utilizing natural language understanding as an interface, ushering in a significant advancement. Although there remains ample uncharted territory, this article aims to lay the groundwork for comprehending the mechanics of function calling and its potential to elevate AI integration.

Customer retention is the key

Lorem ipsum dolor sit amet, consectetur adipiscing elit lobortis arcu enim urna adipiscing praesent velit viverra sit semper lorem eu cursus vel hendrerit elementum morbi curabitur etiam nibh justo, lorem aliquet donec sed sit mi dignissim at ante massa mattis.

  1. Neque sodales ut etiam sit amet nisl purus non tellus orci ac auctor
  2. Adipiscing elit ut aliquam purus sit amet viverra suspendisse potent
  3. Mauris commodo quis imperdiet massa tincidunt nunc pulvinar
  4. Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia

What are the most relevant factors to consider?

Vitae congue eu consequat ac felis placerat vestibulum lectus mauris ultrices cursus sit amet dictum sit amet justo donec enim diam porttitor lacus luctus accumsan tortor posuere praesent tristique magna sit amet purus gravida quis blandit turpis.

Odio facilisis mauris sit amet massa vitae tortor.

Don’t overspend on growth marketing without good retention rates

At risus viverra adipiscing at in tellus integer feugiat nisl pretium fusce id velit ut tortor sagittis orci a scelerisque purus semper eget at lectus urna duis convallis porta nibh venenatis cras sed felis eget neque laoreet suspendisse interdum consectetur libero id faucibus nisl donec pretium vulputate sapien nec sagittis aliquam nunc lobortis mattis aliquam faucibus purus in.

  • Neque sodales ut etiam sit amet nisl purus non tellus orci ac auctor
  • Adipiscing elit ut aliquam purus sit amet viverra suspendisse potenti
  • Mauris commodo quis imperdiet massa tincidunt nunc pulvinar
  • Adipiscing elit ut aliquam purus sit amet viverra suspendisse potenti
What’s the ideal customer retention rate?

Nisi quis eleifend quam adipiscing vitae aliquet bibendum enim facilisis gravida neque euismod in pellentesque massa placerat volutpat lacus laoreet non curabitur gravida odio aenean sed adipiscing diam donec adipiscing tristique risus amet est placerat in egestas erat.

“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua enim ad minim veniam.”
Next steps to increase your customer retention

Eget lorem dolor sed viverra ipsum nunc aliquet bibendum felis donec et odio pellentesque diam volutpat commodo sed egestas aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod eu tincidunt tortor aliquam nulla facilisi aenean sed adipiscing diam donec adipiscing ut lectus arcu bibendum at varius vel pharetra nibh venenatis cras sed felis eget.