fix: streaming

This commit is contained in:
cogwheel0
2025-09-26 01:38:00 +05:30
parent 748f2a43a8
commit 5f03610f35
4 changed files with 467 additions and 146 deletions

View File

@@ -2798,7 +2798,13 @@ class ApiService {
// Send message with SSE streaming
// Returns a record with (stream, messageId, sessionId)
({Stream<String> stream, String messageId, String sessionId}) sendMessage({
({
Stream<String> stream,
String messageId,
String sessionId,
String? socketSessionId,
})
sendMessage({
required List<Map<String, dynamic>> messages,
required String model,
String? conversationId,
@@ -2807,6 +2813,7 @@ class ApiService {
bool enableImageGeneration = false,
Map<String, dynamic>? modelItem,
String? sessionIdOverride,
String? socketSessionId,
List<Map<String, dynamic>>? toolServers,
Map<String, dynamic>? backgroundTasks,
String? responseMessageId,
@@ -2904,6 +2911,16 @@ class ApiService {
};
}
if (backgroundTasks != null && backgroundTasks.isNotEmpty) {
data['background_tasks'] = backgroundTasks;
}
if (socketSessionId != null && socketSessionId.isNotEmpty) {
data['session_id'] = socketSessionId;
}
data['id'] = messageId;
// No default reasoning parameters included; providers handle thinking UIs natively.
// Add tool_ids if provided (Open-WebUI expects tool_ids as array of strings)
@@ -3132,6 +3149,7 @@ class ApiService {
stream: streamController.stream,
messageId: messageId,
sessionId: sessionId,
socketSessionId: socketSessionId,
);
}