mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 20:35:19 +00:00
refac/fix: large file upload
This commit is contained in:
parent
6c0a5fa91c
commit
051b6daa82
1 changed files with 13 additions and 10 deletions
|
|
@ -1370,6 +1370,7 @@ def save_docs_to_vector_db(
|
||||||
prefix=RAG_EMBEDDING_CONTENT_PREFIX,
|
prefix=RAG_EMBEDDING_CONTENT_PREFIX,
|
||||||
user=user,
|
user=user,
|
||||||
)
|
)
|
||||||
|
log.info(f"embeddings generated {len(embeddings)} for {len(texts)} items")
|
||||||
|
|
||||||
items = [
|
items = [
|
||||||
{
|
{
|
||||||
|
|
@ -1387,6 +1388,7 @@ def save_docs_to_vector_db(
|
||||||
items=items,
|
items=items,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
log.info(f"added {len(items)} items to collection {collection_name}")
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
|
|
@ -1545,13 +1547,20 @@ def process_file(
|
||||||
log.debug(f"text_content: {text_content}")
|
log.debug(f"text_content: {text_content}")
|
||||||
Files.update_file_data_by_id(
|
Files.update_file_data_by_id(
|
||||||
file.id,
|
file.id,
|
||||||
{"status": "completed", "content": text_content},
|
{"content": text_content},
|
||||||
)
|
)
|
||||||
|
|
||||||
hash = calculate_sha256_string(text_content)
|
hash = calculate_sha256_string(text_content)
|
||||||
Files.update_file_hash_by_id(file.id, hash)
|
Files.update_file_hash_by_id(file.id, hash)
|
||||||
|
|
||||||
if not request.app.state.config.BYPASS_EMBEDDING_AND_RETRIEVAL:
|
if request.app.state.config.BYPASS_EMBEDDING_AND_RETRIEVAL:
|
||||||
|
Files.update_file_data_by_id(file.id, {"status": "completed"})
|
||||||
|
return {
|
||||||
|
"status": True,
|
||||||
|
"collection_name": None,
|
||||||
|
"filename": file.filename,
|
||||||
|
"content": text_content,
|
||||||
|
}
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
result = save_docs_to_vector_db(
|
result = save_docs_to_vector_db(
|
||||||
request,
|
request,
|
||||||
|
|
@ -1565,6 +1574,7 @@ def process_file(
|
||||||
add=(True if form_data.collection_name else False),
|
add=(True if form_data.collection_name else False),
|
||||||
user=user,
|
user=user,
|
||||||
)
|
)
|
||||||
|
log.info(f"added {len(docs)} items to collection {collection_name}")
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
Files.update_file_metadata_by_id(
|
Files.update_file_metadata_by_id(
|
||||||
|
|
@ -1582,13 +1592,6 @@ def process_file(
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
else:
|
|
||||||
return {
|
|
||||||
"status": True,
|
|
||||||
"collection_name": None,
|
|
||||||
"filename": file.filename,
|
|
||||||
"content": text_content,
|
|
||||||
}
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue