-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: enhance streaming support in text generation #6212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment was marked as outdated.
This comment was marked as outdated.
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
…responseMessageId
7ffc918 to
986f181
Compare
…string types in parsed XML
… parsed XML logging
- Introduced support for multiple response modes: "sync", "stream", and "websocket". - Updated `handleMessage` method in ElizaOS to accommodate new response modes. - Enhanced message streaming with `message_stream_chunk` and `message_stream_error` events. - Rename sendMessage to HandleMessage in ElizaOS api - Refactored API endpoints to validate and process the response mode parameter. - Added shared response handlers for consistent handling of different modes. - Updated tests to cover new response modes and ensure correct functionality. - Uniformize session and channel response format
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as outdated.
This comment was marked as outdated.
…environments - Introduced platform-specific streaming context managers using AsyncLocalStorage for Node.js and a stack-based approach for browsers. - Updated `useModel` to support automatic streaming based on active contexts. - Enhanced `DefaultMessageService` to utilize streaming context for real-time updates. - Refactored related interfaces and types to accommodate new streaming functionality. - Improved tests to validate streaming behavior and context isolation in parallel calls.
…d enhancing type handling - Replaced individual mock adapter implementations in tests with a shared `createMockAdapter` function for consistency and maintainability. - Updated type handling in tests to ensure proper type assertions, particularly for payloads in event emissions. - Introduced new test files for streaming context and runtime integration, enhancing coverage for streaming functionality and character handling. - Improved error handling tests for memory and character runtime integrations.
This comment was marked as outdated.
This comment was marked as outdated.
|
@BugBot run |
🚨 Bugbot couldn't runBugbot is not enabled for your user on this team. Ask your team administrator to increase your team's hard limit for Bugbot seats or add you to the allowlist in the Cursor dashboard. |
…mponents - Updated `MemoizedMessageContent` to include action status checks for improved rendering efficiency. - Introduced a new `STREAM_TIMEOUT_MS` constant to manage stream inactivity in `useSocketChat`. - Enhanced message processing logic to track seen message IDs and handle action messages more effectively. - Implemented timeout management for streaming messages to prevent memory leaks. - Added new streaming utilities for filtering and extracting content from XML responses. - Refactored `DefaultMessageService` to utilize the new streaming utilities for better response handling. - Improved tests for streaming behavior and edge cases in message processing.
This comment was marked as outdated.
This comment was marked as outdated.
…ities - Introduced the IStreamExtractor interface for consistent stream content extraction. - Added PassthroughExtractor and XmlTagExtractor implementations for flexible content handling. - Enhanced ResponseStreamExtractor and ActionStreamFilter to support new XML tag structure. - Updated tests to cover new extractor functionalities and edge cases. - Refactored existing streaming utilities to align with the new interface and improve maintainability.
This comment was marked as outdated.
This comment was marked as outdated.
Enregistrement.de.l.ecran.2025-12-17.a.14.02.52.mov |
0xbbjoker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work and PR. Tested with three llm plugins. Discord and telegram.
|
Claude finished @standujar's task —— View job PR Review: Streaming Support EnhancementTodo List:
Overall Assessment: STRONG APPROVAL ✅This is an excellent implementation of streaming support with proper architecture, comprehensive testing, and adherence to ElizaOS patterns. The breaking changes are well-documented with clear migration paths. Key Strengths✅ Comprehensive test coverage - 289 test files using Technical HighlightsStreaming Implementation (
|
Summary
This PR adds streaming support across ElizaOS and unifies the messaging API with multiple response modes.
Breaking Changes
elizaOS.sendMessage()→elizaOS.handleMessage()- Method renamedFeatures
Core (
packages/core)Text Streaming
stream: trueparam inruntime.useModel()returnsTextStreamResultstream: false- Explicitly disable streaming for JSON extraction callsextractXmlTagsFromStream()elizaOS.sendMessage()→elizaOS.handleMessage()TextStreamResult,TextStreamChunk, messaging typesStreaming Context Infrastructure (NEW)
StreamingContext- Async context interface withonStreamChunk,onStreamEnd,messageId, andabortSignalAsyncLocalStoragefor Node.js, stack-based for BrowserrunWithStreamingContext()- Execute code with streaming callbacks propagated through async boundariesabortSignalinStreamingContextContent Filtering Classes (NEW -
utils/streaming.ts)ResponseStreamExtractor- Parses initial LLM response, detects REPLY vs delegated strategy, streams<text>and<message>tagsActionStreamFilter- Auto-detects content type from first character ({/[=JSON,<=XML, else=text), filters accordinglyServer (
packages/server)sync|stream|websocket(default)response-handlers.tsfor channels & sessionsuser_message,chunk,done,errormessage_stream_chunk,message_stream_erroreventsAPI Client (
packages/api-client)ResponseMode,UserMessageData,AgentResponseContent,SessionStatusDatasendMessageSync()- convenience for sync modeMessageResponsewith unified formatClient (
packages/client)streamTimeoutsRefto handle stalled streamsstreamingMessagesRefMap for real-time text buildingMemoizedMessageContent(NEW) - React.memo optimization for message rendering withactionStatustrackingBug Fixes
responseMessageIdthoughtPreview/textPreview(string check)Files Changed
coreelizaos.ts,runtime.ts,utils.ts,types/model.ts,types/messaging.tscorestreaming-context.ts,streaming-context.node.ts(NEW)coreutils/streaming.ts(NEW - ResponseStreamExtractor, ActionStreamFilter)coreservices/default-message-service.ts,index.ts,index.node.tsserverapi/shared/response-handlers.ts,channels.ts,sessions.ts,socketio/index.tsapi-clienttypes/sessions.ts,services/sessions.tsclientsocketio-manager.ts,hooks/use-socket-chat.ts,components/chat.tsxTests
streaming.test.tsruntime-streaming.test.tsstreaming-context.test.tsmessage-service.test.tsruntime.test.tsresponse-handlers.test.tschannels-mode.test.tsmessage-stream-events.test.tsmessaging-types.test.tsUsage
Architecture
Client Timeout Flow (NEW)