feat: Add stop session functionality to chat API and UI
- Implemented a new API endpoint to stop ongoing chat sessions, allowing users to cancel message generation. - Enhanced InputField component to include a stop button, enabling users to halt the assistant's response generation. - Updated chat view to manage the assistant message ID and loading state effectively during stop events. - Improved event handling in the backend to support stop events, ensuring proper session management and user feedback.
This commit is contained in:
@@ -59,6 +59,9 @@ const (
|
||||
|
||||
// Session events
|
||||
EventSessionTitle EventType = "session_title" // 会话标题更新
|
||||
|
||||
// Control events
|
||||
EventStop EventType = "stop" // 停止对话生成
|
||||
)
|
||||
|
||||
// Event represents an event in the system
|
||||
|
||||
@@ -201,3 +201,10 @@ type SessionTitleData struct {
|
||||
SessionID string `json:"session_id"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
// StopData represents stop generation request data
|
||||
type StopData struct {
|
||||
SessionID string `json:"session_id"`
|
||||
MessageID string `json:"message_id"`
|
||||
Reason string `json:"reason,omitempty"` // Optional reason for stopping
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user