Writesonic
  1. 聊天声 API
Writesonic
  • 简介
    • 介绍
    • 如何查找您的 API 密钥
  • 聊天声 API
    • 记忆功能
    • ChatSonic (如 ChatGPT)
      POST
  • 照片声 API
    • 生成图像
      POST
  • 写声 API
    • 人工智能文章作者
      • 人工智能文章创意
      • 人工智能文章介绍
      • 人工智能文章大纲
      • 人工智能文章作家 3.0
    • 亚马逊
      • AIDA 框架
      • 亚马逊产品描述
      • 亚马逊产品标题
      • 亚马逊产品特点
      • 亚马逊赞助品牌广告标题
    • Emails
      • Cold Emails V2
      • 电子邮件
      • 电子邮件V2
      • 电子邮件主题行
    • Google
      • Google 广告说明
      • Google 广告说明 V2
      • Google 广告标题
      • Google 广告标题 V2
      • Google 广告
    • Instagram
      • Instagram 标题
      • Instagram 热门话题标签
    • LinkedIn
      • LinkedIn 广告说明
      • LinkedIn 广告标题
      • LinkedIn 广告
      • LinkedIn 帖子 V2
      • LinkedIn 短帖子
    • TikTok
      • TikTok 视频 Hooks
      • TikTok 视频脚本
    • Twitter
      • 推文
      • 推特话题
    • YouTube
      • YouTube 创意
      • YouTube 简介
      • YouTube 简介 V2
      • YouTube 描述
      • YouTube 描述 V2
      • Youtube Hooks
      • YouTube 概要
      • YouTube 标题
    • 类比生成器
      POST
    • ans-my-ques
      POST
    • 应用程序和短信通知
      POST
    • 项目符号回答
      POST
    • 行动号召
      POST
    • 公司使命
      POST
    • 公司愿景
      POST
    • 结论撰写器
      POST
    • 内容改写
      POST
    • 内容缩短
      POST
    • 定义
      POST
    • Facebook 广告
      POST
    • 功能优势
      POST
    • 成长理念
      POST
    • 即时文章作家
      POST
    • 关键字提取器(仅限英文)
      POST
    • 登陆页面标题
      POST
    • 登陆页面
      POST
    • 清单创意
      POST
    • Pain-Agitate-Solutions
      POST
    • 段落作者
      POST
    • 被动语态到主动语态
      POST
    • 个人简介
      POST
    • 产品说明
      POST
    • 产品名称
      POST
    • 优点和缺点
      POST
    • Quora 答案
      POST
    • 问题
      POST
    • 房地产清单描述
      POST
    • 评论生成器
      POST
    • 审核回复者
      POST
    • 用关键字重写
      POST
    • 句子扩展器
      POST
    • SEO 元标签(博客文章)
      POST
    • SEO 元标签(主页)
      POST
    • SEO 元标签(产品页面)
      POST
    • 简短的新闻稿
      POST
    • 歌曲歌词
      POST
    • 创业想法
      POST
    • 故事
      POST
    • 文字概要
      POST
    • 变调器
      POST
  • 文章作家 3.0 流媒体端点
    • 开始使用您的 API
  1. 聊天声 API

记忆功能

本页详细介绍了如何在 API 中使用 ChatSonic 的内存功能
ChatSonic 可以维护您的对话上下文,就像您与人交谈一样。它会记住您对话中过去的问题或评论,并可以轻松回答后续问题。

字段格式#

以下是如何在 API 中使用 ChatSonic 的记忆功能
将字段设置为enable_memory``true
按以下格式将以前的对话添加到history_data
[{
  	"is_sent": bool,
    "message": string
}]
该字段的目的是标记是用户提示还是 ChatSonic 响应is_sent``message
设置为用于用户提示is_sent``true
设置为ChatSonic 响应is_sent``false

例子#

让我们通过一个例子来尝试一下
步骤1
我们先来问问ChatSonicWho is the President of the United States?
因为这是第一条消息,所以是一个空的对象数组history_data
// REQUEST BODY
{
    "enable_memory": true,
    "enable_google_results": true,
    "input_text": "Who is the President of the United States?",
    "history_data": []
}

// RESPONSE BODY
{
    "message": "The 46th and current President of the United States is Joseph R. Biden, Jr., who was sworn in on January 20, 2021.",
    "image_urls": null
}
第2步
现在,我们来问一下When was he born?
确保通过之前现场的提示和响应history_data
is_sent设置为用户提示true
is_sent设置为 ChatSonic 响应false
// REQUEST BODY
{
    "enable_memory": true,
    "enable_google_results": true,
    "input_text": "When was he born?",
    "history_data": [
        {
            "is_sent": true,
            "message": "Who is the President of the United States?"
        },
        {
            "is_sent": false,
            "message": "The 46th and current President of the United States is Joseph R. Biden, Jr., who was sworn in on January 20, 2021."
        }
    ]
}

// RESPONSE BODY
{
    "message": "Joseph Robinette Biden Jr. was born on November 20, 1942, in Scranton, Pennsylvania.",
    "image_urls": null
}
步骤3
现在,我们来问一下What is his favorite sports team?
确保通过之前现场的提示和响应history_data
is_sent设置为用户提示true
is_sent设置为 ChatSonic 响应false
// REQUEST BODY
{
    "enable_memory": true,
    "enable_google_results": true,
    "input_text": "What is his favorite sports team?",
    "history_data": [
        {
            "is_sent": true,
            "message": "Who is the President of the United States?"
        },
        {
            "is_sent": false,
            "message": "The 46th and current President of the United States is Joseph R. Biden, Jr., who was sworn in on January 20, 2021."
        },
        {
            "is_sent": true,
            "message": "When was he born?"
        },
        {
            "is_sent": false,
            "message": "Joseph Robinette Biden Jr. was born on November 20, 1942, in Scranton, Pennsylvania."
        }
    ]
}

// RESPONSE BODY
{
    "message": "Joe Biden is a Pennsylvania and Delaware native, and he roots for the Philadelphia Eagles. Biden was at Super Bowl LII cheering for his team with his family.",
    "image_urls": null
}
上一页
如何查找您的 API 密钥
下一页
ChatSonic (如 ChatGPT)
Built with