Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
2f6e6831
Unverified
Commit
2f6e6831
authored
Apr 09, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Apr 09, 2024
Browse files
Merge pull request #1476 from buroa/dev
fix: support batching chromadb
parents
1448c32f
0bae789d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
backend/apps/rag/main.py
backend/apps/rag/main.py
+9
-3
No files found.
backend/apps/rag/main.py
View file @
2f6e6831
...
...
@@ -15,6 +15,7 @@ from typing import List
from
sentence_transformers
import
SentenceTransformer
from
chromadb.utils
import
embedding_functions
from
chromadb.utils.batch_utils
import
create_batches
from
langchain_community.document_loaders
import
(
WebBaseLoader
,
...
...
@@ -331,9 +332,14 @@ def store_docs_in_vector_db(docs, collection_name, overwrite: bool = False) -> b
embedding_function
=
app
.
state
.
sentence_transformer_ef
,
)
collection
.
add
(
documents
=
texts
,
metadatas
=
metadatas
,
ids
=
[
str
(
uuid
.
uuid1
())
for
_
in
texts
]
)
for
batch
in
create_batches
(
api
=
CHROMA_CLIENT
,
ids
=
[
str
(
uuid
.
uuid1
())
for
_
in
texts
],
metadatas
=
metadatas
,
documents
=
texts
,
):
collection
.
add
(
*
batch
)
return
True
except
Exception
as
e
:
log
.
exception
(
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment