mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 09:32:22 +03:00
d955e31f50
added explore button and removed unused feature openai key # 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):
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
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_per_user: int = 5
|
|
|
|
|
|
class BrainSettings(BaseSettings):
|
|
openai_api_key: str
|
|
supabase_url: str
|
|
supabase_service_key: str
|
|
pg_database_url: str = "not implemented"
|
|
resend_api_key: str = "null"
|
|
resend_email_address: str = "brain@mail.quivr.app"
|
|
|
|
|
|
class ContactsSettings(BaseSettings):
|
|
resend_contact_sales_from: str = "null"
|
|
resend_contact_sales_to: str = "null"
|
|
|
|
|
|
class LLMSettings(BaseSettings):
|
|
private: bool = False
|
|
model_path: str = "./local_models/ggml-gpt4all-j-v1.3-groovy.bin"
|
|
|
|
|
|
class ResendSettings(BaseSettings):
|
|
resend_api_key: str = "null"
|
|
|
|
|
|
def get_supabase_client() -> Client:
|
|
settings = BrainSettings() # pyright: ignore reportPrivateUsage=none
|
|
supabase_client: Client = create_client(
|
|
settings.supabase_url, settings.supabase_service_key
|
|
)
|
|
return supabase_client
|
|
|
|
|
|
def get_supabase_db() -> SupabaseDB:
|
|
supabase_client = get_supabase_client()
|
|
return SupabaseDB(supabase_client)
|
|
|
|
|
|
def get_embeddings() -> OpenAIEmbeddings:
|
|
settings = BrainSettings() # pyright: ignore reportPrivateUsage=none
|
|
embeddings = OpenAIEmbeddings(
|
|
openai_api_key=settings.openai_api_key
|
|
) # pyright: ignore reportPrivateUsage=none
|
|
return embeddings
|
|
|
|
|
|
def get_documents_vector_store() -> SupabaseVectorStore:
|
|
settings = BrainSettings() # pyright: ignore reportPrivateUsage=none
|
|
embeddings = get_embeddings()
|
|
supabase_client: Client = create_client(
|
|
settings.supabase_url, settings.supabase_service_key
|
|
)
|
|
documents_vector_store = SupabaseVectorStore(
|
|
supabase_client, embeddings, table_name="vectors"
|
|
)
|
|
return documents_vector_store
|