SSE Request Tool · emploidai Marketplace
emploidai Marketplace
Add-onsAppletsPlugins
Search tools, teams, and capabilitiesPublish
MarketplacePluginsSSE Request Tool
Plugin
Limited listing

SSE Request Tool

by tdcktz · v0.0.5

A Server-Sent Events (SSE) request tool for Dify workflows. Establishes long connections to receive real-time event streams from servers with support for authentication, custom headers, and automatic retry mechanisms.

1.8k installsUpdated Aug 21, 2025
Documentation
Publisher information is incomplete

This community listing does not yet include every recommended support, privacy, pricing, and permission disclosure. Review the available package permissions before installing.

Capabilities

Tools

Available inside your emploidai workspace after installation.

Data sources

Available inside your emploidai workspace after installation.

Category

tool

Version

0.0.5tdcktz

Requirements

Maximum memory 256MB

Pricing

Not disclosed by publisher

Security & access

Review before installing

CompatibleRequires emploidai 1.0.0+

Permissions

  • Uses app capability
  • Uses tool capability

Dependencies

No additional dependencies

Resources

DocumentationPrivacy policy
emploidai Marketplace

Discover capabilities. Review access. Install inside your workspace.

DocumentationSecuritySupportPrivacyTerms

Dify SSE 请求工具插件

Author: lw
Version: 0.0.3
Type: tool

📖 描述

这是一个为Dify工作流设计的Server-Sent Events (SSE) 请求工具插件。它允许你在Dify工作流中建立长连接,接收服务器实时推送的事件流数据,并提供流式输出和最终汇总结果。

✨ 主要功能

  • 🔗 长连接支持: 建立并维护SSE长连接
  • 📡 实时数据流: 接收服务器推送的实时事件数据
  • 🔐 多种认证方式: 支持Bearer Token、API Key等认证方式
  • ⚙️ 灵活配置: 自定义Headers、查询参数、超时设置等
  • 🔄 自动重连: 连接失败时自动重试机制
  • 📊 流式输出: 实时输出接收到的事件,同时提供最终汇总
  • 🛡️ 错误处理: 完善的错误处理和状态监控

🚀 快速开始

基本用法

在Dify工作流中添加SSE请求工具,配置以下参数:

URL: https://your-sse-server.com/stream
认证类型: none
超时时间: 30
最大事件数: 100
最大持续时间: 300

带认证的请求

URL: https://api.example.com/sse/events
认证类型: bearer
认证令牌: your-bearer-token
请求头: |
  Content-Type: application/json
  X-Custom-Header: custom-value
查询参数: |
  stream: true
  topic: updates

📋 参数说明

参数名类型必需默认值说明
urlstring✅-SSE服务器端点URL
headersstring❌-自定义HTTP头,每行一个,格式:key: value
query_paramsstring❌-URL查询参数,每行一个,格式:key: value
auth_typeselect❌none认证类型:none/bearer/api_key
auth_tokenstring❌-认证令牌或API密钥
auth_headerstring❌AuthorizationAPI密钥认证的头名称
timeoutnumber❌30连接超时时间(秒)
max_eventsnumber❌100最大接收事件数
max_durationnumber❌300最大连接持续时间(秒)
retry_attemptsnumber❌3连接失败重试次数

📤 输出格式

实时事件输出

{
  "type": "event",
  "event_number": 1,
  "event_type": "message",
  "data": "实时接收的数据",
  "event_id": "event-123",
  "timestamp": "2024-01-01T12:00:00Z"
}

最终汇总输出

{
  "type": "summary",
  "status": "completed",
  "total_events": 50,
  "connection_duration": 25.5,
  "events": [...],
  "summary": "SSE连接成功,接收到50个事件,耗时25.5秒",
  "timestamp": "2024-01-01T12:00:25Z"
}

错误输出

{
  "type": "error",
  "status": "failed",
  "error": "连接超时",
  "timestamp": "2024-01-01T12:00:30Z"
}

🔧 技术实现

核心特性

  • SSE协议支持: 完整实现SSE协议规范
  • 事件解析: 支持data:、event:、id:、retry:字段
  • 流式处理: 使用httpx的stream模式处理长连接
  • 异步支持: 支持异步事件处理和超时控制

依赖库

  • httpx>=0.25.0: HTTP客户端,支持流式请求
  • dify_plugin>=0.2.0: Dify插件框架

📝 使用示例

示例1:监听ChatGPT流式响应

URL: https://api.openai.com/v1/chat/completions
认证类型: bearer
认证令牌: sk-your-openai-api-key
请求头: |
  Content-Type: application/json
查询参数: |
  stream: true
  model: gpt-3.5-turbo

示例2:监听实时日志流

URL: https://your-log-server.com/logs/stream
认证类型: api_key
认证令牌: your-api-key
认证头名称: X-API-Key
查询参数: |
  level: info
  service: web-app
最大事件数: 1000
最大持续时间: 600

🤝 贡献

欢迎提交Issue和Pull Request来改进这个插件!

📄 许可证

MIT License