You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
*
[`src/components/ChatContainer/ChatContainer.tsx`](diffhunk://#diff-c0bfccaf03a29a5059f6a47c6dd2cdd194fcb1e06fe8e0e188d700a86204f073R23):
Added a new state `useStreaming` and modified the `handleMessageSubmit`
function to handle streaming responses using the new
`handleStreamingResponse` and `handleSyncResponse` functions.
[[1]](diffhunk://#diff-c0bfccaf03a29a5059f6a47c6dd2cdd194fcb1e06fe8e0e188d700a86204f073R23)
[[2]](diffhunk://#diff-c0bfccaf03a29a5059f6a47c6dd2cdd194fcb1e06fe8e0e188d700a86204f073L101-L108)
[[3]](diffhunk://#diff-c0bfccaf03a29a5059f6a47c6dd2cdd194fcb1e06fe8e0e188d700a86204f073R109-R114)
[[4]](diffhunk://#diff-c0bfccaf03a29a5059f6a47c6dd2cdd194fcb1e06fe8e0e188d700a86204f073R124-R198)
[[5]](diffhunk://#diff-c0bfccaf03a29a5059f6a47c6dd2cdd194fcb1e06fe8e0e188d700a86204f073L163-R226)
*
[`src/components/ChatInput/ChatInput.tsx`](diffhunk://#diff-e56b5877d49403da7c452c9efab46ee9a6e3daa2be72e4aeca9bf085afd81b17R5-L24):
Updated the `onSubmit` function to accept a `MessageHandlerConfig`
parameter and handle streaming settings.
[[1]](diffhunk://#diff-e56b5877d49403da7c452c9efab46ee9a6e3daa2be72e4aeca9bf085afd81b17R5-L24)
[[2]](diffhunk://#diff-e56b5877d49403da7c452c9efab46ee9a6e3daa2be72e4aeca9bf085afd81b17L38-R58)
[[3]](diffhunk://#diff-e56b5877d49403da7c452c9efab46ee9a6e3daa2be72e4aeca9bf085afd81b17L50-L56)
*
[`src/services/ChatService.ts`](diffhunk://#diff-9dd13b51c673219aa9d6fb02c8bc1100134172df11c9c69008b0b299c0b3d53fR22-R27):
Added the `sendStreamMessage` function to handle streaming responses
from the API.
[[1]](diffhunk://#diff-9dd13b51c673219aa9d6fb02c8bc1100134172df11c9c69008b0b299c0b3d53fR22-R27)
[[2]](diffhunk://#diff-9dd13b51c673219aa9d6fb02c8bc1100134172df11c9c69008b0b299c0b3d53fR49-R112)
*
[`src/types/chat.ts`](diffhunk://#diff-149830263521dd5458cda6d3607035614de3c2d8c55a4784ac632891361601e7R13-R45):
Added new interfaces `StreamSettings` and `MessageHandlerConfig` to
support streaming configurations.
### Code Refactoring:
*
[`src/components/ChatContainer/ChatContainer.tsx`](diffhunk://#diff-c0bfccaf03a29a5059f6a47c6dd2cdd194fcb1e06fe8e0e188d700a86204f073R3-L21):
Refactored the `ChatContainerProps` interface to move it to the
`types/chat.ts` file.
*
[`src/services/APIClient.ts`](diffhunk://#diff-c541918b610d84d9d4591faecad3008e1a8a244d446b8b929f3e017ea97fd558R54-R69):
Added a new `fetchStream` method to handle streaming API requests.
0 commit comments