feat: tools implementation

This commit is contained in:
cogwheel0
2025-08-19 20:26:19 +05:30
parent d3742944bc
commit 267a45cd9e
8 changed files with 189 additions and 14 deletions

View File

@@ -24,6 +24,9 @@ class ApiService {
late final ApiAuthInterceptor _authInterceptor;
// Removed legacy websocket/socket.io fields
// Public getter for dio instance
Dio get dio => _dio;
// Callback to notify when auth token becomes invalid
void Function()? onAuthTokenInvalid;
@@ -2415,7 +2418,7 @@ class ApiService {
required List<Map<String, dynamic>> messages,
required String model,
String? conversationId,
List<Map<String, dynamic>>? tools,
List<String>? toolIds,
bool enableWebSearch = false,
Map<String, dynamic>? modelItem,
}) {
@@ -2500,6 +2503,12 @@ class ApiService {
debugPrint('DEBUG: Web search enabled in SSE request');
}
// Add tool_ids if provided (Open-WebUI expects tool_ids as array of strings)
if (toolIds != null && toolIds.isNotEmpty) {
data['tool_ids'] = toolIds;
debugPrint('DEBUG: Including tool_ids in SSE request: $toolIds');
}
// Don't add session_id or id - they break SSE streaming!
// The server falls back to task-based async when these are present