java

关注公众号 jb51net

关闭
首页 > 软件编程 > java > 大模型chat/completions和completions

大模型chat/completions和completions区别解析

作者:sdbhewfoqi

OpenAI的completions和chat/completions是两个不同的端点,completions用于单次文本补全,而chat/completions用于多轮对话生成,选择哪个端点取决于你的具体需求,本文介绍大模型chat/completions和completions区别,感兴趣的朋友一起看看吧

chat/completionscompletions 是 OpenAI API 中的两个不同的端点,它们提供了不同的功能和交互模式。以下是它们的主要区别:

completions 端点

用途:

交互模式:

适用场景:

示例请求:

{
    "model": "text-davinci-003",
    "prompt": "Once upon a time, in a land far, far away,",
    "max_tokens": 100
}

示例响应:

{
    "id": "cmpl-5eU3oZz1w9Q8Jt3B3o5Q5Z5Z1",
    "object": "text_completion",
    "created": 1609459200,
    "model": "text-davinci-003",
    "choices": [
        {
            "text": " there lived a wise old owl who knew all the secrets of the forest...",
            "index": 0,
            "logprobs": null,
            "finish_reason": "length"
        }
    ],
    "usage": {
        "prompt_tokens": 10,
        "completion_tokens": 100,
        "total_tokens": 110
    }
}

chat/completions 端点

用途:

交互模式:

适用场景:

示例请求:

{
    "model": "gpt-4",
    "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who won the world series in 2020?"},
        {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
        {"role": "user", "content": "Where was it played?"}
    ]
}

示例响应:

{
    "id": "chatcmpl-5eU3oZz1w9Q8Jt3B3o5Q5Z5Z1",
    "object": "chat.completion",
    "created": 1609459200,
    "model": "gpt-4",
    "choices": [
        {
            "message": {
                "role": "assistant",
                "content": "The 2020 World Series was played at Globe Life Field in Arlington, Texas."
            },
            "index": 0,
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 50,
        "completion_tokens": 20,
        "total_tokens": 70
    }
}

总结

选择哪个端点取决于你的具体需求。

到此这篇关于大模型chat/completions和completions区别解析的文章就介绍到这了,更多相关大模型chat/completions和completions内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文