开发聊天流#

通过本文档,您可以学习如何从头开始编写流 YAML 来开发聊天流。您可以在流 YAML 架构中找到有关流 YAML 架构的其他信息。

流输入数据#

区分聊天流和标准流最重要的元素是聊天输入聊天历史记录。聊天流可以有多个输入,但聊天历史记录聊天输入是聊天流中必需的输入。

  • 聊天输入:聊天输入是指用户提交给聊天机器人的消息或查询。有效处理聊天输入对于成功的对话至关重要,因为它涉及理解用户意图、提取相关信息和触发适当的响应。

  • 聊天历史记录:聊天历史记录是用户与聊天机器人之间所有交互的记录,包括用户输入和 AI 生成的输出。维护聊天历史记录对于跟踪对话上下文并确保 AI 可以生成上下文相关的响应至关重要。聊天历史记录是一种特殊类型的聊天流输入,它以结构化格式存储聊天消息。

    聊天历史记录示例

    [
      {"inputs": {"question": "What types of container software there are?"}, "outputs": {"answer": "There are several types of container software available, including: Docker, Kubernetes"}},
      {"inputs": {"question": "What's the different between them?"}, "outputs": {"answer": "The main difference between the various container software systems is their functionality and purpose. Here are some key differences between them..."}},
    ] 
    

您可以将 is_chat_input/is_chat_history 设置为 true 以将 chat_input/chat_history 添加到聊天流中。

inputs:
  chat_history:
    type: list
    is_chat_history: true
    default: []
  question:
    type: string
    is_chat_input: true
    default: What is ChatGPT?

有关更多信息,请参阅使用不同工具开发流

使用不同工具开发流#

在一个流中,您可以使用不同类型的工具。我们现在支持内置工具,如LLMPythonPrompt,以及第三方工具,如Serp API向量搜索等。

有关更多信息,请参阅使用不同工具开发流

设置流输出#

聊天输出是聊天流中必需的输出。它指的是 AI 生成的、作为对用户输入的响应而发送给用户的消息。生成上下文适当且引人入胜的聊天输出对于积极的用户体验至关重要。

您可以将 is_chat_output 设置为 true 以将 chat_output 添加到聊天流中。

outputs:
  answer:
    type: string
    reference: ${chat.output}
    is_chat_output: true