Expand description
This module contains the request structures used in the Dify client SDK.
The request structures define the data structures used to send various requests to the Dify API. These requests include sending chat messages, stopping stream tasks, getting suggested questions, providing message feedback, retrieving conversation history, managing conversations, uploading files, executing workflows, converting text to audio, converting audio to text, and generating completion messages.
Each request structure is defined as a Rust struct and is annotated with #[derive(Debug, Clone, Default, Serialize, Deserialize)]
to enable serialization and deserialization using the serde crate.
The request structures include additional documentation comments to provide information about the purpose and usage of each field in the structure.
Example:
// FILEPATH: ~/git/dify/dify-sdk-rs/dify-client/src/request.rs
pub use bytes::Bytes;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// 发送对话消息的请求
/// 创建会话消息。
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ChatMessagesRequest {
/// 允许传入 App 定义的各变量值。
/// inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。
/// 默认 {}
pub inputs: HashMap<String, String>,
/// 用户输入/提问内容。
pub query: String,
/// 响应模式
/// * streaming 流式模式(推荐)。基于 SSE(Server-Sent Events)实现类似打字机输出方式的流式返回。
/// * blocking 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。
/// 由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。
pub response_mode: ResponseMode,
/// 用户标识,用于定义终端用户的身份,方便检索、统计。
/// 由开发者定义规则,需保证用户标识在应用内唯一。
pub user: String,
/// 会话 ID(选填),需要基于之前的聊天记录继续对话,必须传之前消息的 conversation_id。
pub conversation_id: String,
/// 上传的文件。
pub files: Vec<FileInput>,
/// 自动生成标题(选填),默认 true。
/// 若设置为 false,则可通过调用会话重命名接口并设置 auto_generate 为 true 实现异步生成标题。
pub auto_generate_name: bool,
}
// ... (other request structures)
The request structures can be used to construct requests to the Dify API by populating the fields with the required data.
These structures can then be serialized into JSON or other formats using the serde crate’s serialization capabilities.
For more information on each request structure and its fields, refer to the documentation comments provided for each structure.
Structs§
- Audio
ToText Request - 语音转文字请求
- Bytes
- A cheaply cloneable and sliceable chunk of contiguous memory.
- Chat
Messages Request - 发送对话消息的请求 创建会话消息。
- Completion
Messages Request - 文本生成请求
- Conversations
Delete Request - 删除会话请求
- Conversations
Rename Request - 会话重命名请求
- Conversations
Request - 获取会话列表的请求
- Files
Upload Request - 上传文件请求
- Messages
Feedbacks Request - 消息反馈请求 消息终端用户反馈、点赞,方便应用开发者优化输出预期。
- Messages
Request - 获取会话历史消息的请求 滚动加载形式返回历史聊天记录,第一页返回最新 limit 条,即:倒序返回。
- Messages
Suggested Request - 获取下一轮建议问题列表请求
- Meta
Request - 获取应用Meta信息的请求
- Parameters
Request - 获取应用配置信息的请求
- Stream
Task Stop Request - 停止响应请求
- Text
ToAudio Request - 文字转语音请求
- Workflows
RunRequest - 执行 workflow 请求
Enums§
- Feedback
- 消息反馈
- File
Input - 上传的文件
- File
Type - 文件类型
- Response
Mode - 响应模式