mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-20 01:21:50 +03:00
303ba72028
* add sqlalchemy models * add neon settings * add insert brain * abstract supabase from Brain class * abstract supabase from Brain class * abstract supabase from /models * update Database to Repository * update neon_tables to pg_tables * update chat, api-key and message * update vector class * update settings * update env vars for test * Update backend-tests.yml * fix test * fix fetch_user_requests_count() * fix fetch_user_requests_count() * fix increment_user_request_count * fix increment_user_request_count * fix asset upload_response message * fix pyright * fix brain_subscription * fix brain_subscription * fix brain_subscription * fix get user request stat * update create_brain_user * add delete brain vector and user * add delete brain vector and user * correctly call function --------- Co-authored-by: Noé Pion <noe.pion@onfido.com> Co-authored-by: raoufchebri <raouf@chebri.com> Co-authored-by: Stan Girard <girard.stanislas@gmail.com>
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
from typing import Annotated
|
|
|
|
from fastapi import Depends
|
|
from langchain.embeddings.openai import OpenAIEmbeddings
|
|
from models.databases.supabase.supabase import SupabaseDB
|
|
from pydantic import BaseSettings
|
|
from supabase.client import Client, create_client
|
|
from vectorstore.supabase import SupabaseVectorStore
|
|
|
|
|
|
class BrainRateLimiting(BaseSettings):
|
|
max_brain_size: int = 52428800
|
|
max_brain_per_user: int = 5
|
|
|
|
|
|
class BrainSettings(BaseSettings):
|
|
openai_api_key: str
|
|
anthropic_api_key: str
|
|
supabase_url: str
|
|
supabase_service_key: str
|
|
pg_database_url: str
|
|
resend_api_key: str = "null"
|
|
resend_email_address: str = "brain@mail.quivr.app"
|
|
|
|
|
|
class LLMSettings(BaseSettings):
|
|
private: bool = False
|
|
model_path: str = "./local_models/ggml-gpt4all-j-v1.3-groovy.bin"
|
|
|
|
|
|
def common_dependencies() -> dict:
|
|
settings = BrainSettings() # pyright: ignore reportPrivateUsage=none
|
|
embeddings = OpenAIEmbeddings(
|
|
openai_api_key=settings.openai_api_key
|
|
) # pyright: ignore reportPrivateUsage=none
|
|
supabase_client: Client = create_client(
|
|
settings.supabase_url, settings.supabase_service_key
|
|
)
|
|
documents_vector_store = SupabaseVectorStore(
|
|
supabase_client, embeddings, table_name="vectors"
|
|
)
|
|
summaries_vector_store = SupabaseVectorStore(
|
|
supabase_client, embeddings, table_name="summaries"
|
|
)
|
|
|
|
db = None
|
|
db = SupabaseDB(supabase_client)
|
|
|
|
return {
|
|
"supabase": supabase_client,
|
|
"db": db,
|
|
"embeddings": embeddings,
|
|
"documents_vector_store": documents_vector_store,
|
|
"summaries_vector_store": summaries_vector_store,
|
|
}
|
|
|
|
|
|
CommonsDep = Annotated[dict, Depends(common_dependencies)]
|