浏览代码

Merge pull request #12506 from Ithanil/fix_web_result_source_ids

fix: fix web results all getting the same source id when bypassing embedding and retrieval
Timothy Jaeryang Baek 3 月之前
父节点
当前提交
6751d68034
共有 1 个文件被更改,包括 9 次插入8 次删除
  1. 9 8
      backend/open_webui/utils/middleware.py

+ 9 - 8
backend/open_webui/utils/middleware.py

@@ -409,14 +409,15 @@ async def chat_web_search_handler(
                         }
                     )
                 elif results.get("docs"):
-                    files.append(
-                        {
-                            "docs": results.get("docs", []),
-                            "name": searchQuery,
-                            "type": "web_search",
-                            "urls": results["filenames"],
-                        }
-                    )
+                    for doc_idx, doc in enumerate(results["docs"]):
+                        files.append(
+                            {
+                                "docs": [doc],
+                                "name": searchQuery,
+                                "type": "web_search",
+                                "urls": [results["filenames"][doc_idx]],
+                            }
+                        )
 
                 form_data["files"] = files
         except Exception as e: