mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-23 12:58:18 -05:00
Create llmindex if doesnt exist on update run
This commit is contained in:
parent
c5f618d822
commit
51a7581860
@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import faiss
|
import faiss
|
||||||
import llama_index.core.settings as llama_settings
|
import llama_index.core.settings as llama_settings
|
||||||
@ -125,11 +126,15 @@ def update_llm_index(*, progress_bar_disable=False, rebuild=False):
|
|||||||
logger.warning("No documents found to index.")
|
logger.warning("No documents found to index.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if rebuild:
|
if (
|
||||||
|
rebuild
|
||||||
|
or not Path(settings.LLM_INDEX_DIR / "default__vector_store.json").exists()
|
||||||
|
):
|
||||||
|
# Rebuild index from scratch
|
||||||
|
logger.info("Rebuilding LLM index.")
|
||||||
embed_model = get_embedding_model()
|
embed_model = get_embedding_model()
|
||||||
llama_settings.Settings.embed_model = embed_model
|
llama_settings.Settings.embed_model = embed_model
|
||||||
storage_context = get_or_create_storage_context(rebuild=rebuild)
|
storage_context = get_or_create_storage_context(rebuild=True)
|
||||||
# Rebuild index from scratch
|
|
||||||
for document in tqdm.tqdm(documents, disable=progress_bar_disable):
|
for document in tqdm.tqdm(documents, disable=progress_bar_disable):
|
||||||
document_nodes = build_document_node(document)
|
document_nodes = build_document_node(document)
|
||||||
nodes.extend(document_nodes)
|
nodes.extend(document_nodes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user