mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-24 20:03:41 +03:00
f48dab4a7d
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
20 lines
783 B
Python
20 lines
783 B
Python
from celery import shared_task
|
|
from models.settings import get_supabase_db
|
|
from modules.brain.service.brain_vector_service import BrainVectorService
|
|
from packages.embeddings.vectors import Neurons
|
|
from repository.files.upload_file import DocumentSerializable
|
|
|
|
|
|
@shared_task
|
|
def create_embedding_for_document(brain_id, doc_with_metadata, file_sha1):
|
|
neurons = Neurons()
|
|
doc = DocumentSerializable.from_json(doc_with_metadata)
|
|
created_vector = neurons.create_vector(doc)
|
|
database = get_supabase_db()
|
|
database.set_file_sha_from_metadata(file_sha1)
|
|
|
|
created_vector_id = created_vector[0] # pyright: ignore reportPrivateUsage=none
|
|
|
|
brain_vector_service = BrainVectorService(brain_id)
|
|
brain_vector_service.create_brain_vector(created_vector_id, file_sha1)
|