Skip to content

Commit 30e4ff4

Browse files
authored
Merge pull request #1 from JAVA-LW/taichuy_dev
Taichuy dev
2 parents 05fd061 + 538f9a4 commit 30e4ff4

18 files changed

+3062
-195
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,7 @@ cython_debug/
173173
# macOS
174174
.DS_Store
175175
.AppleDouble
176-
.LSOverride
176+
.LSOverride
177+
docs/
178+
examples/test_sse.py
179+
examples/test_sse.py

DEPLOYMENT.md

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
# Dify SSE 请求工具插件 - 部署指南
2+
3+
## 📦 插件安装
4+
5+
### 方法1:从源码安装
6+
7+
1. **克隆或下载插件代码**
8+
```bash
9+
git clone https://github.com/JAVA-LW/dify_sse_node_plugin.git
10+
cd dify_sse_node_plugin
11+
```
12+
13+
2. **安装依赖**
14+
```bash
15+
pip install -r requirements.txt
16+
```
17+
18+
3. **在Dify中安装插件**
19+
- 将插件文件夹复制到Dify的插件目录
20+
- 或者通过Dify管理界面上传插件包
21+
22+
### 方法2:通过Dify插件市场安装
23+
24+
1. 打开Dify管理界面
25+
2. 进入插件市场
26+
3. 搜索"SSE Request Tool"
27+
4. 点击安装
28+
29+
## 🚀 快速开始
30+
31+
### 1. 创建工作流
32+
33+
在Dify中创建一个新的工作流,添加SSE请求工具节点。
34+
35+
### 2. 基本配置
36+
37+
```yaml
38+
# 最简配置
39+
URL: https://your-sse-server.com/stream
40+
认证类型: none
41+
超时时间: 30
42+
```
43+
44+
### 3. 高级配置
45+
46+
```yaml
47+
# 完整配置示例
48+
URL: https://api.example.com/sse/events
49+
认证类型: bearer
50+
认证令牌: your-bearer-token
51+
请求头: |
52+
Content-Type: application/json
53+
X-Custom-Header: custom-value
54+
查询参数: |
55+
stream: true
56+
topic: updates
57+
format: json
58+
超时时间: 60
59+
最大事件数: 200
60+
最大持续时间: 300
61+
重试次数: 3
62+
```
63+
64+
## 🔧 配置说明
65+
66+
### URL配置
67+
- 必须是有效的HTTP/HTTPS URL
68+
- 支持查询参数
69+
- 示例:`https://api.example.com/sse?stream=true`
70+
71+
### 认证配置
72+
73+
#### 无认证 (none)
74+
```yaml
75+
认证类型: none
76+
```
77+
78+
#### Bearer Token认证
79+
```yaml
80+
认证类型: bearer
81+
认证令牌: your-bearer-token
82+
```
83+
84+
#### API Key认证
85+
```yaml
86+
认证类型: api_key
87+
认证令牌: your-api-key
88+
认证头名称: X-API-Key
89+
```
90+
91+
### 请求头配置
92+
每行一个头部,格式:`key: value`
93+
```
94+
Content-Type: application/json
95+
Accept: text/event-stream
96+
X-Custom-Header: custom-value
97+
```
98+
99+
### 查询参数配置
100+
每行一个参数,格式:`key: value`
101+
```
102+
stream: true
103+
format: json
104+
topic: updates
105+
```
106+
107+
## 📊 输出处理
108+
109+
### 实时事件处理
110+
插件会实时输出接收到的每个SSE事件:
111+
```json
112+
{
113+
"type": "event",
114+
"event_number": 1,
115+
"event_type": "message",
116+
"data": "实时数据",
117+
"event_id": "event-123",
118+
"timestamp": "2024-01-01T12:00:00Z"
119+
}
120+
```
121+
122+
### 最终汇总
123+
连接结束后输出汇总信息:
124+
```json
125+
{
126+
"type": "summary",
127+
"status": "completed",
128+
"total_events": 50,
129+
"connection_duration": 25.5,
130+
"events": [...],
131+
"summary": "SSE连接成功,接收到50个事件,耗时25.5秒"
132+
}
133+
```
134+
135+
## 🛠️ 故障排除
136+
137+
### 常见问题
138+
139+
#### 1. 连接超时
140+
**问题**:连接建立失败或超时
141+
**解决方案**:
142+
- 检查URL是否正确
143+
- 增加超时时间
144+
- 检查网络连接
145+
- 验证服务器是否支持SSE
146+
147+
#### 2. 认证失败
148+
**问题**:401或403错误
149+
**解决方案**:
150+
- 检查认证令牌是否正确
151+
- 确认认证类型配置
152+
- 验证认证头名称
153+
154+
#### 3. 无事件接收
155+
**问题**:连接成功但没有接收到事件
156+
**解决方案**:
157+
- 检查服务器是否正在发送事件
158+
- 增加最大持续时间
159+
- 检查事件格式是否符合SSE规范
160+
161+
#### 4. 事件解析错误
162+
**问题**:接收到事件但解析失败
163+
**解决方案**:
164+
- 检查服务器发送的事件格式
165+
- 确认Content-Type为text/event-stream
166+
- 查看错误日志获取详细信息
167+
168+
### 调试技巧
169+
170+
1. **启用详细日志**
171+
```python
172+
import logging
173+
logging.basicConfig(level=logging.DEBUG)
174+
```
175+
176+
2. **使用测试端点**
177+
```bash
178+
# 使用curl测试SSE端点
179+
curl -N -H "Accept: text/event-stream" https://your-sse-server.com/stream
180+
```
181+
182+
3. **检查网络连接**
183+
```bash
184+
# 测试基本连接
185+
curl -I https://your-sse-server.com/stream
186+
```
187+
188+
## 🔒 安全注意事项
189+
190+
1. **保护认证令牌**
191+
- 不要在日志中记录敏感信息
192+
- 使用环境变量存储令牌
193+
- 定期轮换API密钥
194+
195+
2. **验证SSL证书**
196+
- 确保使用HTTPS连接
197+
- 验证服务器证书有效性
198+
199+
3. **限制连接时间**
200+
- 设置合理的超时时间
201+
- 限制最大事件数量
202+
- 避免无限期连接
203+
204+
## 📈 性能优化
205+
206+
1. **连接管理**
207+
- 合理设置超时时间
208+
- 使用连接池(如果支持)
209+
- 及时关闭不需要的连接
210+
211+
2. **事件处理**
212+
- 限制最大事件数量
213+
- 使用流式处理避免内存溢出
214+
- 定期清理事件缓存
215+
216+
3. **错误处理**
217+
- 实现指数退避重试
218+
- 设置最大重试次数
219+
- 记录错误统计信息
220+
221+
## 📞 技术支持
222+
223+
如遇到问题,请:
224+
1. 查看插件日志
225+
2. 检查配置是否正确
226+
3. 参考故障排除指南
227+
4. 联系技术支持:[email protected]
228+
229+
## 🔄 更新日志
230+
231+
### v0.0.1 (2024-01-01)
232+
- 初始版本发布
233+
- 支持基本SSE连接
234+
- 实现多种认证方式
235+
- 添加自动重试机制

PRIVACY.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1-
## Privacy
1+
# 隐私政策 / Privacy Policy
22

3-
!!! Please fill in the privacy policy of the plugin.
3+
## 中文版
4+
5+
### 数据收集
6+
本插件(Dify SSE请求工具)不会收集、存储或传输任何用户个人信息。
7+
8+
### 数据处理
9+
- 插件仅处理用户在工作流中配置的SSE请求参数
10+
- 所有数据处理都在用户的本地环境中进行
11+
- 不会向第三方服务发送用户数据(除了用户明确配置的SSE端点)
12+
13+
### 网络连接
14+
- 插件会根据用户配置连接到指定的SSE服务器
15+
- 连接仅限于用户明确指定的URL
16+
- 不会建立任何未经授权的网络连接
17+
18+
### 数据安全
19+
- 认证令牌和敏感信息仅在请求期间使用
20+
- 不会持久化存储任何敏感信息
21+
- 所有网络通信遵循标准的HTTPS安全协议
22+
23+
---
24+
25+
## English Version
26+
27+
### Data Collection
28+
This plugin (Dify SSE Request Tool) does not collect, store, or transmit any personal user information.
29+
30+
### Data Processing
31+
- The plugin only processes SSE request parameters configured by users in their workflows
32+
- All data processing occurs within the user's local environment
33+
- No user data is sent to third-party services (except for user-explicitly configured SSE endpoints)
34+
35+
### Network Connections
36+
- The plugin connects to SSE servers as specified by user configuration
37+
- Connections are limited to URLs explicitly specified by users
38+
- No unauthorized network connections are established
39+
40+
### Data Security
41+
- Authentication tokens and sensitive information are only used during requests
42+
- No sensitive information is persistently stored
43+
- All network communications follow standard HTTPS security protocols
44+
45+
---
46+
47+
## 联系方式 / Contact
48+
49+
如有隐私相关问题,请联系:[email protected]
50+
51+
For privacy-related questions, please contact: [email protected]

0 commit comments

Comments
 (0)