Skip to content

聊天引擎#

概念#

聊天引擎是与您的数据进行对话的高级接口(支持多轮交互而非单次问答)。可以将其理解为增强版ChatGPT,能够结合您的知识库进行交流。

从概念上讲,它是查询引擎有状态类比。通过记录对话历史,它能够基于上下文语境回答问题。

Tip

如果您需要对数据提出独立问题(即不需要保持对话历史记录),请改用查询引擎

使用模式#

快速开始:

chat_engine = index.as_chat_engine()
response = chat_engine.chat("Tell me a joke.")

流式响应模式:

chat_engine = index.as_chat_engine()
streaming_response = chat_engine.stream_chat("Tell me a joke.")
for token in streaming_response.response_gen:
    print(token, end="")

完整用法请参阅使用模式指南

模块#

模块章节中,您可以通过实际教程了解可用的聊天引擎类型。