Browse Source

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 months ago
parent
commit
6751d68034
1 changed files with 9 additions and 8 deletions
  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"):
                 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
                 form_data["files"] = files
         except Exception as e:
         except Exception as e: