mirror of
https://github.com/open-webui/open-webui
synced 2024-11-07 00:59:52 +00:00
fix: embedding metadata issue
This commit is contained in:
parent
92605fd59f
commit
797afd0b72
@ -678,7 +678,19 @@ def save_docs_to_vector_db(
|
|||||||
raise ValueError(ERROR_MESSAGES.EMPTY_CONTENT)
|
raise ValueError(ERROR_MESSAGES.EMPTY_CONTENT)
|
||||||
|
|
||||||
texts = [doc.page_content for doc in docs]
|
texts = [doc.page_content for doc in docs]
|
||||||
metadatas = [{**doc.metadata, **(metadata if metadata else {})} for doc in docs]
|
metadatas = [
|
||||||
|
{
|
||||||
|
**doc.metadata,
|
||||||
|
**(metadata if metadata else {}),
|
||||||
|
"embedding_config": json.dumps(
|
||||||
|
{
|
||||||
|
"engine": app.state.config.RAG_EMBEDDING_ENGINE,
|
||||||
|
"model": app.state.config.RAG_EMBEDDING_MODEL,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
}
|
||||||
|
for doc in docs
|
||||||
|
]
|
||||||
|
|
||||||
# ChromaDB does not like datetime formats
|
# ChromaDB does not like datetime formats
|
||||||
# for meta-data so convert them to string.
|
# for meta-data so convert them to string.
|
||||||
@ -717,13 +729,7 @@ def save_docs_to_vector_db(
|
|||||||
"id": str(uuid.uuid4()),
|
"id": str(uuid.uuid4()),
|
||||||
"text": text,
|
"text": text,
|
||||||
"vector": embeddings[idx],
|
"vector": embeddings[idx],
|
||||||
"metadata": {
|
"metadata": metadatas[idx],
|
||||||
**metadatas[idx],
|
|
||||||
"embedding": {
|
|
||||||
"engine": app.state.config.RAG_EMBEDDING_ENGINE,
|
|
||||||
"model": app.state.config.RAG_EMBEDDING_MODEL,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
for idx, text in enumerate(texts)
|
for idx, text in enumerate(texts)
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user