Run.observeStream()
.observeStream() 方法会为当前正在运行的工作流运行打开一个新的 ReadableStream,如果原始流不再可用,它允许你观察事件流。
🌐 The .observeStream() method opens a new ReadableStream to a workflow run that is currently running, allowing you to observe the stream of events if the original stream is no longer available.
使用示例Direct link to 使用示例
🌐 Usage example
const run = await workflow.createRun();
run.stream({
inputData: {
value: "initial data",
},
});
const stream = await run.observeStream();
for await (const chunk of stream) {
console.log(chunk);
}
返回Direct link to 返回
🌐 Returns
ReadableStream<ChunkType>
流事件Direct link to 流事件
🌐 Stream Events
在工作流执行过程中,流会发出各种类型的事件。每个事件都有一个 type 字段和一个包含相关数据的 payload:
🌐 The stream emits various event types during workflow execution. Each event has a type field and a payload containing relevant data:
workflow-start:工作流执行开始workflow-step-start:一个步骤开始执行workflow-step-output:步骤的自定义输出workflow-step-result:一个步骤完成并产生结果workflow-finish:工作流执行完成,附带使用统计
相关Direct link to 相关
🌐 Related