streaming
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStreaming - Complete API Reference
流式传输 - 完整API参考
Configure response streaming, typing indicators, and real-time message delivery.
配置响应流式传输、输入指示器与实时消息推送。
Chat Commands
聊天命令
View Settings
查看设置
/streaming Show current settings
/streaming status Streaming status/streaming 显示当前设置
/streaming status 流式传输状态Configure Streaming
配置流式传输
/streaming enable Enable streaming
/streaming disable Disable streaming
/streaming chunk-size 50 Set chunk size (chars)
/streaming delay 100 Set delay between chunks (ms)/streaming enable 启用流式传输
/streaming disable 禁用流式传输
/streaming chunk-size 50 设置 chunk 大小(字符数)
/streaming delay 100 设置 chunk 间延迟(毫秒)Typing Indicators
输入指示器
/streaming typing on Enable typing indicators
/streaming typing off Disable typing indicators
/streaming typing duration 3000 Typing duration (ms)/streaming typing on 启用输入指示器
/streaming typing off 禁用输入指示器
/streaming typing duration 3000 输入持续时长(毫秒)Platform Settings
平台设置
/streaming platforms Show platform limits
/streaming platform telegram chunk 100 Set per-platform/streaming platforms 查看平台限制
/streaming platform telegram chunk 100 设置平台专属配置TypeScript API Reference
TypeScript API参考
Create Streaming Config
创建流式传输配置
typescript
import { createStreamingConfig } from 'clodds/streaming';
const streaming = createStreamingConfig({
// Enable streaming
enabled: true,
// Chunk settings
minChunkSize: 20, // Min chars per chunk
maxChunkSize: 200, // Max chars per chunk
chunkDelayMs: 50, // Delay between chunks
// Typing indicators
showTyping: true,
typingDurationMs: 3000,
// Platform-specific limits
platformLimits: {
telegram: { maxMessageLength: 4096, maxChunkSize: 100 },
discord: { maxMessageLength: 2000, maxChunkSize: 150 },
slack: { maxMessageLength: 40000, maxChunkSize: 200 },
},
});typescript
import { createStreamingConfig } from 'clodds/streaming';
const streaming = createStreamingConfig({
// 启用流式传输
enabled: true,
// Chunk 设置
minChunkSize: 20, // 每个 chunk 的最小字符数
maxChunkSize: 200, // 每个 chunk 的最大字符数
chunkDelayMs: 50, // Chunk 间延迟
// 输入指示器
showTyping: true,
typingDurationMs: 3000,
// 平台专属限制
platformLimits: {
telegram: { maxMessageLength: 4096, maxChunkSize: 100 },
discord: { maxMessageLength: 2000, maxChunkSize: 150 },
slack: { maxMessageLength: 40000, maxChunkSize: 200 },
},
});Enable/Disable
启用/禁用
typescript
// Enable streaming
streaming.enable();
// Disable streaming
streaming.disable();
// Check status
const enabled = streaming.isEnabled();typescript
// 启用流式传输
streaming.enable();
// 禁用流式传输
streaming.disable();
// 检查状态
const enabled = streaming.isEnabled();Configure Chunks
配置Chunk
typescript
// Set chunk size
streaming.setChunkSize(100);
// Set delay
streaming.setChunkDelay(75);
// Get current settings
const settings = streaming.getSettings();
console.log(`Chunk size: ${settings.chunkSize}`);
console.log(`Delay: ${settings.chunkDelayMs}ms`);typescript
// 设置 chunk 大小
streaming.setChunkSize(100);
// 设置延迟
streaming.setChunkDelay(75);
// 获取当前设置
const settings = streaming.getSettings();
console.log(`Chunk size: ${settings.chunkSize}`);
console.log(`Delay: ${settings.chunkDelayMs}ms`);Platform Settings
平台设置
typescript
// Set platform-specific limit
streaming.setPlatformLimit('telegram', {
maxMessageLength: 4096,
maxChunkSize: 80,
});
// Get platform limits
const limits = streaming.getPlatformLimits();typescript
// 设置平台专属限制
streaming.setPlatformLimit('telegram', {
maxMessageLength: 4096,
maxChunkSize: 80,
});
// 获取平台限制
const limits = streaming.getPlatformLimits();Typing Indicators
输入指示器
typescript
// Enable typing
streaming.enableTyping();
// Disable typing
streaming.disableTyping();
// Set duration
streaming.setTypingDuration(5000);typescript
// 启用输入指示器
streaming.enableTyping();
// 禁用输入指示器
streaming.disableTyping();
// 设置持续时长
streaming.setTypingDuration(5000);Platform Limits
平台限制
| Platform | Max Message | Recommended Chunk |
|---|---|---|
| Telegram | 4,096 chars | 80-100 |
| Discord | 2,000 chars | 100-150 |
| Slack | 40,000 chars | 150-200 |
| 65,536 chars | 100-150 | |
| WebChat | Unlimited | 150-200 |
| 平台 | 最大消息长度 | 推荐Chunk大小 |
|---|---|---|
| Telegram | 4,096 字符 | 80-100 |
| Discord | 2,000 字符 | 100-150 |
| Slack | 40,000 字符 | 150-200 |
| 65,536 字符 | 100-150 | |
| WebChat | 无限制 | 150-200 |
Best Practices
最佳实践
- Smaller chunks for mobile — Better UX on slow connections
- Adjust delay for readability — 50-100ms feels natural
- Disable for short responses — Don't stream "OK"
- Monitor performance — Streaming adds overhead
- 移动端使用更小的chunk —— 在慢速网络下提供更好的用户体验
- 调整延迟以提升可读性 —— 50-100毫秒的延迟感觉自然
- 短响应禁用流式传输 —— 不要对“OK”这类短消息使用流式传输
- 监控性能 —— 流式传输会增加系统开销