Skip to content

Added Streaming output rendering functionality #7

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

Merged
merged 8 commits into from
Mar 6, 2025

Conversation

shahariaazam
Copy link
Member

This pull request introduces several changes to the chat functionality, focusing on adding support for streaming responses and refactoring the existing code to improve maintainability. The most important changes include the addition of streaming response handling, updates to the ChatService to support streaming, and modifications to the ChatContainer and ChatInput components to accommodate these new features.

Streaming Response Handling:

Code Refactoring:

Added streaming support for chat messages using a new `sendStreamMessage` method in `ChatService`. Introduced streaming payload settings and incremental rendering of assistant responses. Updated API client to support stream-based fetching and refined error handling.
Refactored chat message handling to ensure state updates by creating new message objects during streaming. Adjusted stream settings for improved responsiveness by reducing chunk size and delay. Added comments for clarity when initializing user and assistant messages.
Introduced `MessageHandlerConfig` for flexible response settings. Split message handling into streaming and synchronous workflows, allowing finer-grained control over chat behavior. Updated `ChatInput` to pass configuration dynamically based on the usage of streaming.
Moved `ChatContainer` prop and type definitions to the shared `chat.ts` types file for better modularity and reuse. This reduces redundancy and improves maintainability across components.
# Conflicts:
#	src/components/ChatContainer/ChatContainer.tsx
Refactored `handleMessageSubmit` to support both streaming and synchronous responses. Introduced new utility functions `handleStreamingResponse` and `handleSyncResponse` for better separation of concerns. Updated `ChatInput` and related props to incorporate streaming functionality.
Introduced a `StreamingToggle` button to toggle between streaming and non-streaming responses. Integrated the toggle functionality into `ChatInput` and `ChatContainer`, allowing dynamic control of streaming behavior via a new `onStreamingChange` handler. This enhances user customization in interacting with the chat system.
Updated button paddings, sizes, titles, and hover states for better UX across `ToolsToggle`, `StreamingToggle`, and `LLMProviderToggle`. Removed redundant test cases and streamlined imports by relocating `LLMProviderToggle`. These changes enhance maintainability and visual harmony.
@shahariaazam shahariaazam merged commit 92d204d into main Mar 6, 2025
3 checks passed
@shahariaazam shahariaazam deleted the streaming-output branch March 6, 2025 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant