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="")

更多详细信息,请参阅完整的使用模式指南

模块#

在我们的模块部分中,你可以找到相应的教程,以了解可用的聊天引擎是如何运作的。