Struct dify_client::request::ChatMessageRequest

source ·
pub struct ChatMessageRequest {
    pub inputs: HashMap<String, String>,
    pub query: String,
    pub response_mode: ResponseMode,
    pub user: String,
    pub conversation_id: String,
    pub files: Vec<ChatMessageFile>,
    pub auto_generate_name: bool,
}
Expand description

发送对话消息的请求 创建会话消息。

Fields§

§inputs: HashMap<String, String>

允许传入 App 定义的各变量值。
inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。
默认 {}

§query: String

用户输入/提问内容。

§response_mode: ResponseMode

响应模式

  • streaming 流式模式(推荐)。基于 SSE(Server-Sent Events)实现类似打字机输出方式的流式返回。
  • blocking 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。
    由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。
§user: String

用户标识,用于定义终端用户的身份,方便检索、统计。
由开发者定义规则,需保证用户标识在应用内唯一。

§conversation_id: String

会话 ID(选填),需要基于之前的聊天记录继续对话,必须传之前消息的 conversation_id。

§files: Vec<ChatMessageFile>

上传的文件。

§auto_generate_name: bool

自动生成标题(选填),默认 true。
若设置为 false,则可通过调用会话重命名接口并设置 auto_generate 为 true 实现异步生成标题。

Trait Implementations§

source§

impl Debug for ChatMessageRequest

source§

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

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

impl Default for ChatMessageRequest

source§

fn default() -> ChatMessageRequest

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for ChatMessageRequest

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 ChatMessageRequest

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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>,