laitimes

ChatGPT upgrade: API supports function calls, adding 4 times the context capability!

author:Operational hacking

Just today, OpenAI officially ushered in a major upgrade, and ChatGPT has evolved again!

ChatGPT upgrade: API supports function calls, adding 4 times the context capability!

Let's take a look at what updates ChatGPT brings this time:

  • Added function calls to the Chat Completions API
  • GPT-4 and the newer and more manipulative version of GPT-3.5-Turbo
  • New (compared to standard 4K version)
  • 75% reduction in embedding model costs
  • 25% reduction in input token cost GPT-3.5-TURBO
  • GPT-3.5-TURBO-0301 announced and deprecation schedule for GPT-4-0314 models

Keyword: function call

OpenAI API now supports function calls, but only for gpt-4-0613 and gpt-3.5-turbo-0613 models, which is actually plug-in support! Application scenarios:

  • Create chatbots to answer questions by invoking external tools such as ChatGPT plugins
  • Translate natural language into API calls or database queries
  • Extract structured data from text
ChatGPT upgrade: API supports function calls, adding 4 times the context capability!

Step 1: Open the interface and call the model with functions and user input

curl https://api.openai.com/v1/chat/completions -u :$OPENAI_API_KEY -H 'Content-Type: application/json' -d '{
  "model": "gpt-3.5-turbo-0613",
  "messages": [
    {"role": "user", "content": "What is the weather like in Boston?"}
  ],
  "functions": [
    {
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": ["celsius", "fahrenheit"]
          }
        },
        "required": ["location"]
      }
    }
  ]
}'           

Step 2: Call the third-party interface and respond to your API with the model

curl https://weatherapi.com/...           

Step 3: Open the AI API and send the response back to the model for summary

curl https://api.openai.com/v1/chat/completions -u :$OPENAI_API_KEY -H 'Content-Type: application/json' -d '{
  "model": "gpt-3.5-turbo-0613",
  "messages": [
    {"role": "user", "content": "What is the weather like in Boston?"},
    {"role": "assistant", "content": null, "function_call": {"name": "get_current_weather", "arguments": "{ \"location\": \"Boston, MA\"}"}},
    {"role": "function", "name": "get_current_weather", "content": "{\"temperature\": "22", \"unit\": \"celsius\", \"description\": \"Sunny\"}"}
  ],
  "functions": [
    {
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": ["celsius", "fahrenheit"]
          }
        },
        "required": ["location"]
      }
    }
  ]
}'           
ChatGPT upgrade: API supports function calls, adding 4 times the context capability!

Keywords: new model release

GPT-4: Updated and improved GPT-4-0613 model including function calls, and GPT-4-32K-0613 model with extended context length for better understanding of larger text.

GPT-3.5 Turbo: The GPT-3.5-turbo-0613 model includes the same function call functionality as GPT-4 and more reliable control through system messages, two features that enable developers to more effectively direct the model's response.

Keywords: model retirement

OpenAI will begin upgrading and retiring the initial versions of gpt-4 and gpt-3.5-turbo released in March.

On June 27, applications that use the stable model name (GPT-3.5-turbo, GPT-4, and GPT-4-32K) will be automatically upgraded to the new version. Developers who need more time to transition can continue to use the old models by specifying model parameters in the API request, which will remain available until September 13.

Keyword: price adjustment

Embedding model price reduction: Reduced the price of the most popular embedding model, text-embedding-ada-002, by 75% to $0.0001 per 1K tokens.

GPT-3.5 Turbo Price Adjustment: The cost of input tokens for gpt-3.5-turbo has been reduced by 25%, and developers can now use the model at just $0.0015 per 1K input tokens and $0.002 per 1K output tokens, which equals approximately 700 pages per dollar.

GPT-3.5-turbo-16K will be priced at $0.003 tokens per 1K input and $0.004 tokens per 1K output.

ChatGPT upgrade: API supports function calls, adding 4 times the context capability!

Read on