迁移到 streamEvents v2
¥Migrating to streamEvents v2
本迁移指南仍在编写中,尚未完成。
¥This migration guide is a work in progress and is not complete.
随着 0.2.0
的发布,我们添加了 streamEvents
API 的 v2
。你可以查看此 PR 了解更多详细信息。
¥We've added a v2
of the streamEvents
API with the release of 0.2.0
. You can see this PR for more details.
v2
版本是 v1
版本的重写,效率更高,事件输出也更一致。v1
版本的 API 将被弃用,取而代之的是 v2
版本,并将在 0.4.0
中被移除。
¥The v2
version is a re-write of the v1
version, and should be more efficient, with more consistent output for the events. The v1
version of the API will be deprecated in favor of the v2
version and will be removed in 0.4.0
.
以下是 API v1
和 v2
版本之间的更改列表。
¥Below is a list of changes between the v1
and v2
versions of the API.
on_chat_model_end
的输出
¥output for on_chat_model_end
在 v1
中,与 on_chat_model_end
相关的输出会根据聊天模型是作为根级可运行对象运行还是作为链的一部分运行而变化。
¥In v1
, the outputs associated with on_chat_model_end
changed depending on whether the
chat model was run as a root level runnable or as part of a chain.
作为根级可运行对象,输出如下:
¥As a root level runnable the output was:
{
data: {
output: AIMessageChunk((content = "hello world!"), (id = "some id"));
}
}
作为链的一部分,输出如下:
¥As part of a chain the output was:
{
data: {
output: {
generations: [
[
{
generation_info: None,
message: AIMessageChunk(
content="hello world!", id="some id"
),
text: "hello world!",
}
]
],
}
},
}
从 v2
开始,输出将始终采用更简单的表示形式:
¥As of v2
, the output will always be the simpler representation:
{
data: {
output: AIMessageChunk((content = "hello world!"), (id = "some id"));
}
}
目前,非聊天模型(即常规 LLM)将始终与更详细的格式相关联。
¥Non chat models (i.e., regular LLMs) will be consistently associated with the more verbose format for now.
on_retriever_end
的输出
¥output for on_retriever_end
on_retriever_end
的输出将始终返回 Documents
的列表。
¥on_retriever_end
output will always return a list of Documents
.
这是 v1
中的输出:
¥This was the output in v1
:
{
data: {
output: {
documents: [
Document(...),
Document(...),
...
]
}
}
}
这是 v2
的新输出:
¥And here is the new output for v2
:
{
data: {
output: [
Document(...),
Document(...),
...
]
}
}
已移除 on_retriever_stream
¥Removed on_retriever_stream
on_retriever_stream
事件是实现的产物,已被删除。
¥The on_retriever_stream
event was an artifact of the implementation and has been removed.
与该事件相关的完整信息已在 on_retriever_end
事件中提供。
¥Full information associated with the event is already available in the on_retriever_end
event.
请使用 on_retriever_end
。
¥Please use on_retriever_end
instead.
已移除 on_tool_stream
¥Removed on_tool_stream
on_tool_stream
事件是实现的产物,已被删除。
¥The on_tool_stream
event was an artifact of the implementation and has been removed.
与该事件相关的完整信息已在 on_tool_end
事件中提供。
¥Full information associated with the event is already available in the on_tool_end
event.
请使用 on_tool_end
。
¥Please use on_tool_end
instead.
名称传播
¥Propagating Names
可运行对象的名称已更新,更加一致。
¥Names of runnables have been updated to be more consistent.
如果你按事件名称进行过滤,请检查是否需要更新过滤器。
¥If you're filtering by event names, check if you need to update your filters.