Browse Source

Merge pull request #5728 from sp301415/dev

fix: Fix OpenAI batch embedding
Timothy Jaeryang Baek 7 months ago
parent
commit
3af50f08bd

+ 5 - 1
backend/open_webui/apps/rag/main.py

@@ -1112,13 +1112,17 @@ def store_docs_in_vector_db(
                 app.state.config.RAG_EMBEDDING_OPENAI_BATCH_SIZE,
                 app.state.config.RAG_EMBEDDING_OPENAI_BATCH_SIZE,
             )
             )
 
 
+            embedding_texts = embedding_function(
+                list(map(lambda x: x.replace("\n", " "), texts))
+            )
+
             VECTOR_DB_CLIENT.insert(
             VECTOR_DB_CLIENT.insert(
                 collection_name=collection_name,
                 collection_name=collection_name,
                 items=[
                 items=[
                     {
                     {
                         "id": str(uuid.uuid4()),
                         "id": str(uuid.uuid4()),
                         "text": text,
                         "text": text,
-                        "vector": embedding_function(text.replace("\n", " ")),
+                        "vector": embedding_texts[idx],
                         "metadata": metadatas[idx],
                         "metadata": metadatas[idx],
                     }
                     }
                     for idx, text in enumerate(texts)
                     for idx, text in enumerate(texts)

+ 0 - 2
backend/open_webui/apps/rag/utils.py

@@ -76,8 +76,6 @@ def query_doc(
             limit=k,
             limit=k,
         )
         )
 
 
-        print("result", result)
-
         log.info(f"query_doc:result {result}")
         log.info(f"query_doc:result {result}")
         return result
         return result
     except Exception as e:
     except Exception as e:

+ 0 - 4
backend/open_webui/apps/rag/vector/dbs/milvus.py

@@ -16,8 +16,6 @@ class MilvusClient:
         self.client = Client(uri=MILVUS_URI)
         self.client = Client(uri=MILVUS_URI)
 
 
     def _result_to_get_result(self, result) -> GetResult:
     def _result_to_get_result(self, result) -> GetResult:
-        print(result)
-
         ids = []
         ids = []
         documents = []
         documents = []
         metadatas = []
         metadatas = []
@@ -45,8 +43,6 @@ class MilvusClient:
         )
         )
 
 
     def _result_to_search_result(self, result) -> SearchResult:
     def _result_to_search_result(self, result) -> SearchResult:
-        print(result)
-
         ids = []
         ids = []
         distances = []
         distances = []
         documents = []
         documents = []