Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
zMardone committed Jul 17, 2024
1 parent 9c013a8 commit 30d691c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 13 additions & 2 deletions app/celery.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
from celery import Celery

from typing import Dict
from typing import Dict, List

from langchain.docstore.document import Document

from app.store import IStorage
from app.indexer.indexer_file_manager import IndexerFileManager
from app.downloaders.s3 import S3FileDownloader

from app.handlers.nexus import NexusRESTClient
from app.text_splitters import TextSplitter, character_text_splitter

Expand Down Expand Up @@ -55,3 +58,11 @@ def index_file_data(content_base: Dict) -> bool:
)

return index_result


@celery.task(name="save_file")
def start_save(
storage: IStorage,
docs: List[Document]
) -> bool:
return storage.save(docs)
5 changes: 4 additions & 1 deletion app/indexer/content_bases.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from langchain.docstore.document import Document

from app.celery import start_save
from app.handlers.products import Product
from app.indexer import IDocumentIndexer
from app.store import IStorage
Expand All @@ -25,7 +26,9 @@ def index_documents(self, docs: List[Document]):
ids = [item["_id"] for item in results]
self.storage.delete(ids=ids)
print("start save")
return self.storage.save(docs)

task_status = start_save.delay(storage=self.storage, docs=docs)
return task_status.wait()

def index(self, texts: List, metadatas: dict):
results = self._search_docs_by_content_base_uuid(
Expand Down

0 comments on commit 30d691c

Please sign in to comment.