mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 01:21:48 +03:00
1f21c6d7f3
# Description Move some folders to packages Remove unused code
22 lines
768 B
Python
22 lines
768 B
Python
from celery import shared_task
|
|
from models.brains import Brain
|
|
from models.settings import get_supabase_db
|
|
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, user_openai_api_key, file_sha1
|
|
):
|
|
neurons = Neurons()
|
|
doc = DocumentSerializable.from_json(doc_with_metadata)
|
|
created_vector = neurons.create_vector(doc, user_openai_api_key)
|
|
database = get_supabase_db()
|
|
database.set_file_sha_from_metadata(file_sha1)
|
|
|
|
created_vector_id = created_vector[0] # pyright: ignore reportPrivateUsage=none
|
|
|
|
brain = Brain(id=brain_id) # pyright: ignore
|
|
brain.create_brain_vector(created_vector_id, file_sha1)
|