diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index e74bc9fbc0..a5f09e591b 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -1255,6 +1255,7 @@ async def chat_web_search_handler( "messages": messages, "prompt": user_message, "type": "web_search", + "chat_id": extra_params.get("__chat_id__"), }, user, ) @@ -1585,6 +1586,7 @@ async def chat_image_generation_handler( { "model": form_data["model"], "messages": form_data["messages"], + "chat_id": metadata.get("chat_id"), }, user, ) @@ -1691,6 +1693,7 @@ async def chat_completion_files_handler( "model": body["model"], "messages": body["messages"], "type": "retrieval", + "chat_id": body.get("metadata", {}).get("chat_id"), }, user, ) diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index 1529600368..f622a90562 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -864,7 +864,8 @@ export const generateQueries = async ( model: string, messages: object[], prompt: string, - type: string = 'web_search' + type: string = 'web_search', + chat_id?: string ) => { let error = null; @@ -879,7 +880,8 @@ export const generateQueries = async ( model: model, messages: messages, prompt: prompt, - type: type + type: type, + ...(chat_id && { chat_id: chat_id }) }) }) .then(async (res) => { @@ -933,7 +935,8 @@ export const generateAutoCompletion = async ( model: string, prompt: string, messages?: object[], - type: string = 'search query' + type: string = 'search query', + chat_id?: string ) => { const controller = new AbortController(); let error = null; @@ -951,7 +954,8 @@ export const generateAutoCompletion = async ( prompt: prompt, ...(messages && { messages: messages }), type: type, - stream: false + stream: false, + ...(chat_id && { chat_id: chat_id }) }) }) .then(async (res) => { @@ -1675,7 +1679,7 @@ export interface ModelMeta { profile_image_url?: string; } -export interface ModelParams {} +export interface ModelParams { } export type GlobalModelConfig = ModelConfig[];