对接ChatGPT时如何保证同一个用户会话的连惯性

闪电发卡2年前ChatGPT1122
要保证对接ChatGPT API时是同一个用户的连续问题,可以使用API返回的completion对象中的conversation_id属性来实现。conversation_id是一个字符串,可以唯一标识一个会话(即一个用户的连续问题)。
具体地说,当您第一次发送请求时,可以不指定conversation_id,API将自动生成一个新的conversation_id并返回。当您想要继续与同一用户的会话时,需要将上一次请求中返回的conversation_id作为当前请求的参数之一。
例如,您第一次发送请求时,请求可以这样写:
{
    "model": "davinci",
    "prompt": "Hello, how can I help you today?",
    "temperature": 0.5,
    "max_tokens": 50
}
API返回的completion对象中包含conversation_id属性,例如:
{
    "id": "cmpl-1234567890",
    "object": "text_completion",
    "created": 1619692352,
    "model": "davinci",
    "prompt": "Hello, how can I help you today?",
    "choices": [
        {
            "text": "I'm feeling a bit down lately. Can you help me figure out why?",
            "index": 0,
            "logprobs": null,
            "finish_reason": "length"
        }
    ],
    "conversation_id": "conv-1234567890"
}
接下来,当您想要继续与同一用户的会话时,可以将上一次请求中返回的conversation_id作为当前请求的参数之一:
{
    "model": "davinci",
    "prompt": "I'm feeling a bit down lately. Can you help me figure out why?",
    "temperature": 0.5,
    "max_tokens": 50,
    "conversation_id": "conv-1234567890"
}
这样,API就能够识别这是同一个用户的连续问题,并能够保证回答的连贯性。



闪电发卡ChatGPT产品推荐:

ChatGPT独享账号:https://www.chatgptzh.com/post/86.html

ChatGPT Plus共享账号:https://www.chatgptzh.com/post/319.html

ChatGPT Plus独享账号(购买充值代充订阅):https://www.chatgptzh.com/post/306.html

ChatGPT APIKey购买充值(直连+转发):https://www.chatgptzh.com/post/305.html

ChatGPT Plus国内镜像逆向版:https://www.chatgptzh.com/post/312.html

ChatGPT国内版(AIChat):https://www.chatgptzh.com/post/318.html


相关文章

成品号共享与ChatGPT Pro:如何充分利用多用户协作?

闪电发卡ChatGPT和Claude产品推荐:ChatGPT Pro共享账号ChatGPT Pro独享账号ChatGPT独享账号Claude Pro & ChatGPT Plus &...

部署本地共享版ChatGPT,一次搭建,多人免费使用

部署本地共享版ChatGPT,一次搭建,多人免费使用

寻找一个可以本地部署并能同多人共享的 ChatGPT,很幸运,在牛掰的 GitHub 上,找到了。需求分析和意向解决方案使用 ChatGPT 有几个苦恼:需要科学上网 ,这是基础,但连打开科...

深入解析GPT 4.0升级到4.5的价值:购买指南

闪电发卡ChatGPT和Claude产品推荐: ChatGPT Pro共享账号 ChatGPT Pro独享账号 ChatGPT独享账号 Claude Pr...

如何通过200美金充值成为ChatGPT Pro会员?

闪电发卡ChatGPT和Claude产品推荐:ChatGPT Pro共享账号ChatGPT Pro独享账号ChatGPT独享账号Claude Pro & ChatGPT Plus &...

用ChatGPT生成热门视频脚本:自媒体创作新利器

闪电发卡ChatGPT产品推荐:ChatGPT独享账号:https://www.chatgptzh.com/post/86.htmlChatGPT Plus独享共享账号购买代充:https://www...

如何在3小时快速开发上线一款ChatGPT微信小程序

如何在3小时快速开发上线一款ChatGPT微信小程序

ChatGPT是一款由OpenAI开发的聊天机器人模型,是一种高效语言模型,它能够模拟人类的语言行为,与用户进行自然的交互。它的名称来源于它所使用的技术——GPT-3架构,即生成式语言模型的第3代。C...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。