Expand description
This module contains the response structures used in the Dify SDK.
It includes error responses, result responses, chat message responses, and more. These structures are used to deserialize JSON responses from the Dify API.
§Examples
Deserialize an error response:
use dify_client::response::ErrorResponse;
let json = r#"
{
"code": "unknown_error",
"message": "An unknown error occurred",
"status": 503
}
"#;
let error_response: ErrorResponse = serde_json::from_str(json).unwrap();
assert_eq!(error_response.code, "unknown_error");
assert_eq!(error_response.message, "An unknown error occurred");
assert_eq!(error_response.status, 503);
Deserialize a chat message response:
use dify_client::response::{ChatMessagesResponse, AppMode};
use serde_json::json;
use std::collections::HashMap;
let json = r#"
{
"base": {
"message_id": "12345",
"conversation_id": "67890",
"created_at": 1705395332
},
"event": "message",
"mode": "chat",
"answer": "Hello, how can I help you?",
"metadata": {
"key1": "value1",
"key2": "value2"
}
}
"#;
let mut metadata = HashMap::new();
metadata.insert("key1".to_string(), json!("value1"));
metadata.insert("key2".to_string(), json!("value2"));
let chat_response: ChatMessagesResponse = serde_json::from_str(json).unwrap();
assert_eq!(chat_response.base.message_id, "12345");
assert_eq!(chat_response.base.conversation_id.unwrap(), "67890");
assert_eq!(chat_response.base.created_at, 1705395332);
assert_eq!(chat_response.event, "message");
assert_eq!(chat_response.mode, AppMode::Chat);
assert_eq!(chat_response.answer, "Hello, how can I help you?");
assert_eq!(chat_response.metadata, metadata);
Structs§
- Audio
ToText Response - 语音转文字响应
- Chat
Messages Response - 发送对话消息的响应
- Completion
Messages Response - 文本生成的响应
- Conversation
Data - 会话数据
- Conversations
Response - 获取会话列表的响应
- Error
Response - 错误响应
- Execution
Metadata - 执行节点元数据
- Files
Upload Response - 上传文件响应
- Message
Base - 对话基础信息
- Message
Data - 历史消息数据
- Message
Feedback - 历史消息数据中的反馈信息
- Message
File - 历史消息数据中的文件信息
- Messages
Response - 获取会话历史消息的响应
- Messages
Suggested Response - 获取下一轮建议问题列表的响应
- Meta
Response - 获取应用Meta信息的响应
- Node
Finished Data - node 执行结束详细内容
- Node
Started Data - node 详细内容
- Parameter
Annotation Reply - 标记回复
- Parameter
Retriever Resource - 引用和归属
- Parameter
Speech ToText - 语音转文本
- Parameter
Suggested Questions After Answer - 启用回答后给出推荐问题。
- Parameters
Response - 获取应用配置信息的响应
- Result
Response - 通用结果响应
- SseMessage
Event Stream - A Stream of SSE message events.
- System
Parameters - 系统参数
- Workflow
Finished Data - workflow 执行结束详细内容
- Workflow
Started Data - workflow 详细内容
- Workflows
RunResponse - 执行 workflow 响应
Enums§
- AppMode
- 应用类型
- Belongs
To - 文件归属方
- Finished
Status - 执行结束状态
- Parameter
File Upload Item - 文件上传配置
- Parameter
User Input Form Item - 用户输入表单配置
- SseMessage
Event - 流式模式分块数据事件
- Tool
Icon - 工具图标
- Transfer
Method - 文件传递方式