mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-19 04:12:03 +03:00
1d33fbd3eb
* feat(queue): added * feat(crawling): added queue * fix(crawler): fixed github * feat(docker): simplified docker compose * feat(celery): added worker * feat(files): now uploaded * feat(files): missing routes * feat(delete): added * feat(storage): added policy and migrations * feat(sqs): implemented * feat(redis): added queue name variable * fix(task): updated * style(env): emoved unused env * ci(tests): removed broken tests
29 lines
847 B
Python
29 lines
847 B
Python
from models.databases.repository import Repository
|
|
|
|
|
|
class File(Repository):
|
|
def __init__(self, supabase_client):
|
|
self.db = supabase_client
|
|
|
|
def set_file_vectors_ids(self, file_sha1):
|
|
response = (
|
|
self.db.table("vectors")
|
|
.select("id")
|
|
.filter("metadata->>file_sha1", "eq", file_sha1)
|
|
.execute()
|
|
)
|
|
return response.data
|
|
|
|
def get_brain_vectors_by_brain_id_and_file_sha1(self, brain_id, file_sha1):
|
|
self.set_file_vectors_ids(file_sha1)
|
|
# Check if file exists in that brain
|
|
response = (
|
|
self.db.table("brains_vectors")
|
|
.select("brain_id, vector_id")
|
|
.filter("brain_id", "eq", str(brain_id))
|
|
.filter("file_sha1", "eq", file_sha1)
|
|
.execute()
|
|
)
|
|
|
|
return response
|