Timothy Jaeryang Baek 3 月之前
父节点
当前提交
8e95e5267c
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 4 3
      backend/open_webui/utils/middleware.py
  2. 0 1
      src/lib/components/chat/Messages/Citations.svelte

+ 4 - 3
backend/open_webui/utils/middleware.py

@@ -248,6 +248,7 @@ async def chat_completion_tools_handler(
                         if tool_id
                         if tool_id
                         else f"{tool_function_name}"
                         else f"{tool_function_name}"
                     )
                     )
+
                     if tool.get("metadata", {}).get("citation", False) or tool.get(
                     if tool.get("metadata", {}).get("citation", False) or tool.get(
                         "direct", False
                         "direct", False
                     ):
                     ):
@@ -1375,7 +1376,7 @@ async def process_chat_response(
             return len(backtick_segments) > 1 and len(backtick_segments) % 2 == 0
             return len(backtick_segments) > 1 and len(backtick_segments) % 2 == 0
 
 
         # Handle as a background task
         # Handle as a background task
-        async def post_response_handler(response, events):
+        async def response_handler(response, events):
             def serialize_content_blocks(content_blocks, raw=False):
             def serialize_content_blocks(content_blocks, raw=False):
                 content = ""
                 content = ""
 
 
@@ -2434,9 +2435,9 @@ async def process_chat_response(
             if response.background is not None:
             if response.background is not None:
                 await response.background()
                 await response.background()
 
 
-        # background_tasks.add_task(post_response_handler, response, events)
+        # background_tasks.add_task(response_handler, response, events)
         task_id, _ = await create_task(
         task_id, _ = await create_task(
-            request, post_response_handler(response, events), id=metadata["chat_id"]
+            request, response_handler(response, events), id=metadata["chat_id"]
         )
         )
         return {"status": True, "task_id": task_id}
         return {"status": True, "task_id": task_id}
 
 

+ 0 - 1
src/lib/components/chat/Messages/Citations.svelte

@@ -43,7 +43,6 @@
 	}
 	}
 
 
 	$: {
 	$: {
-		console.log('sources', sources);
 		citations = sources.reduce((acc, source) => {
 		citations = sources.reduce((acc, source) => {
 			if (Object.keys(source).length === 0) {
 			if (Object.keys(source).length === 0) {
 				return acc;
 				return acc;