天天看点

来了丨ChatGPT 再升级:Api支持函数调用,新增4倍上下文能力!

作者:运营黑客

就在今天,OpenAI官方迎来重大升级,ChatGPT再次进化!

来了丨ChatGPT 再升级:Api支持函数调用,新增4倍上下文能力!

我们一起来看一下,ChatGPT这次带来哪些更新:

  • Chat Completions API 中新增函数调用功能
  • gpt-4和的更新和更易于操纵的版本gpt-3.5-turbo
  • 新的 (与标准 4k 版本相比)
  • 嵌入模型成本降低了75%
  • 输入令牌成本降低 25% gpt-3.5-turbo
  • gpt-3.5-turbo-0301宣布和gpt-4-0314模型的弃用时间表

关键词:函数调用

OpenAI API 现在支持函数调用了,但仅限于 gpt-4-0613 和 gpt-3.5-turbo-0613 模型,其实就是支持插件了!应用场景:

  • 创建聊天机器人,通过调用外部工具(例如 ChatGPT 插件)来回答问题
  • 将自然语言转换为 API 调用或数据库查询
  • 从文本中提取结构化数据
来了丨ChatGPT 再升级:Api支持函数调用,新增4倍上下文能力!

步骤1:打开接口,使用函数和用户输入调用模型

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"]
      }
    }
  ]
}'           

步骤2:调用第三方接口,使用模型响应你的 API

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

步骤 3:开放人工智能应用程序接口,将响应发送回模型进行总结

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 再升级:Api支持函数调用,新增4倍上下文能力!

关键词:新模型发布

GPT-4:发布了包括函数调用在内的更新和改进的 gpt-4-0613 模型,以及具有扩展上下文长度的 gpt-4-32k-0613 模型,以便更好地理解更大的文本。

GPT-3.5 Turbo:gpt-3.5-turbo-0613 模型包括与 GPT-4 相同的函数调用功能,以及通过系统消息更可靠地控制能力,这两个特性使开发者能够更有效地指导模型的响应。

关键词:模型退役

OpenAI 将开始为在 3 月份发布的 gpt-4 和 gpt-3.5-turbo 的初代版本进行升级和退役。

在 6 月 27 日,使用稳定模型名称的应用程序(gpt-3.5-turbo,gpt-4 和 gpt-4-32k)将自动升级为新版本。需要更多时间过渡的开发者可以通过在 API 请求中指定模型参数来继续使用旧模型,这些旧模型将一直可用到 9 月 13 日。

关键词:价格调整

嵌入模型价格降低:将最受欢迎的嵌入模型text-embedding-ada-002 的价格降低了 75%,至每1K tokens $0.0001。

GPT-3.5 Turbo 价格调整:gpt-3.5-turbo 的输入 tokens 的成本降低了 25%,现在,开发者可以仅以每1K 输入tokens $0.0015和每 1K 输出 tokens $0.002的价格使用该模型,约等于每美元 700 页。

gpt-3.5-turbo-16k 将定价为每 1K 输入 tokens $0.003 和每 1K 输出 tokens $0.004。

来了丨ChatGPT 再升级:Api支持函数调用,新增4倍上下文能力!

继续阅读