Enum SseMessageEvent

Source
pub enum SseMessageEvent {
    Message {
        base: Option<MessageBase>,
        id: String,
        task_id: String,
        answer: String,
        extra: HashMap<String, Value>,
    },
    MessageFile {
        base: Option<MessageBase>,
        id: String,
        type_: FileType,
        belongs_to: BelongsTo,
        url: String,
        extra: HashMap<String, Value>,
    },
    MessageEnd {
        base: Option<MessageBase>,
        id: String,
        task_id: String,
        metadata: HashMap<String, Value>,
        extra: HashMap<String, Value>,
    },
    MessageReplace {
        base: Option<MessageBase>,
        task_id: String,
        answer: String,
        extra: HashMap<String, Value>,
    },
    WorkflowStarted {
        base: Option<MessageBase>,
        task_id: String,
        workflow_run_id: String,
        data: WorkflowStartedData,
        extra: HashMap<String, Value>,
    },
    NodeStarted {
        base: Option<MessageBase>,
        task_id: String,
        workflow_run_id: String,
        data: NodeStartedData,
        extra: HashMap<String, Value>,
    },
    NodeFinished {
        base: Option<MessageBase>,
        task_id: String,
        workflow_run_id: String,
        data: NodeFinishedData,
        extra: HashMap<String, Value>,
    },
    WorkflowFinished {
        base: Option<MessageBase>,
        task_id: String,
        workflow_run_id: String,
        data: WorkflowFinishedData,
        extra: HashMap<String, Value>,
    },
    AgentMessage {
        base: Option<MessageBase>,
        id: String,
        task_id: String,
        answer: String,
        extra: HashMap<String, Value>,
    },
    AgentThought {
        base: Option<MessageBase>,
        id: String,
        task_id: String,
        position: u32,
        thought: String,
        observation: String,
        tool: String,
        tool_labels: Value,
        tool_input: String,
        message_files: Vec<String>,
    },
    Error {
        base: Option<MessageBase>,
        status: u32,
        code: String,
        message: String,
        extra: HashMap<String, Value>,
    },
    Ping,
}
Expand description

流式模式分块数据事件

Variants§

§

Message

LLM 返回文本块事件,即:完整的文本以分块的方式输出。

Fields

§base: Option<MessageBase>

消息基础信息

§id: String

消息 ID

§task_id: String

任务 ID,用于请求跟踪和下方的停止响应接口

§answer: String

LLM 返回文本块内容

§

MessageFile

文件事件,表示有新文件需要展示

Fields

§base: Option<MessageBase>

消息基础信息

§id: String

文件唯一 ID

§type_: FileType

文件类型,目前仅为 image

§belongs_to: BelongsTo

文件归属,user 或 assistant,该接口返回仅为 assistant

§url: String

文件访问地址

§

MessageEnd

消息结束事件,收到此事件则代表流式返回结束。

Fields

§base: Option<MessageBase>

消息基础信息

§id: String

消息 ID

§task_id: String

任务 ID,用于请求跟踪和下方的停止响应接口

§metadata: HashMap<String, Value>

元数据

§

MessageReplace

消息内容替换事件
开启内容审查和审查输出内容时,若命中了审查条件,则会通过此事件替换消息内容为预设回复。

Fields

§base: Option<MessageBase>

消息基础信息

§task_id: String

任务 ID,用于请求跟踪和下方的停止响应接口

§answer: String

替换内容(直接替换 LLM 所有回复文本)

§

WorkflowStarted

workflow 开始执行

Fields

§base: Option<MessageBase>

消息基础信息

§task_id: String

任务 ID,用于请求跟踪和下方的停止响应接口

§workflow_run_id: String

workflow 执行 ID

§data: WorkflowStartedData

workflow 详细内容

§

NodeStarted

node 执行开始

Fields

§base: Option<MessageBase>

消息基础信息

§task_id: String

任务 ID,用于请求跟踪和下方的停止响应接口

§workflow_run_id: String

workflow 执行 ID

§data: NodeStartedData

node 详细内容

§

NodeFinished

node 执行结束, 成功失败同一事件中不同状态

Fields

§base: Option<MessageBase>

消息基础信息

§task_id: String

任务 ID,用于请求跟踪和下方的停止响应接口

§workflow_run_id: String

workflow 执行 ID

§data: NodeFinishedData

node 执行结束详细内容

§

WorkflowFinished

workflow 执行结束,成功失败同一事件中不同状态

Fields

§base: Option<MessageBase>

消息基础信息

§task_id: String

任务 ID,用于请求跟踪和下方的停止响应接口

§workflow_run_id: String

workflow 执行 ID

§data: WorkflowFinishedData

workflow 详细内容

§

AgentMessage

Agent模式下返回文本块事件,即:在Agent模式下,文章的文本以分块的方式输出(仅Agent模式下使用)

Fields

§base: Option<MessageBase>

消息基础信息

§id: String

消息 ID

§task_id: String

任务 ID,用于请求跟踪和下方的停止响应接口

§answer: String

LLM 返回文本块内容

§

AgentThought

Agent模式下有关Agent思考步骤的相关内容,涉及到工具调用(仅Agent模式下使用)

Fields

§base: Option<MessageBase>

消息基础信息

§id: String

消息 ID

§task_id: String

任务 ID,用于请求跟踪和下方的停止响应接口

§position: u32

agent_thought在消息中的位置,如第一轮迭代position为1

§thought: String

agent的思考内容

§observation: String

工具调用的返回结果

§tool: String

使用的工具列表,以 ; 分割多个工具

§tool_labels: Value

工具的标签

§tool_input: String

工具的输入,JSON格式的字符串

§message_files: Vec<String>

当前 agent_thought 关联的文件ID

§

Error

流式输出过程中出现的异常会以 stream event 形式输出,收到异常事件后即结束。

Fields

§base: Option<MessageBase>

消息基础信息

§status: u32

HTTP 状态码

§code: String

错误码

§message: String

错误消息

§

Ping

Trait Implementations§

Source§

impl Clone for SseMessageEvent

Source§

fn clone(&self) -> SseMessageEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SseMessageEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SseMessageEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SseMessageEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,