Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: kms 0.1 #3259

Draft
wants to merge 82 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
eaca4a0
remove sync/sync active simplify
AmineDiro Sep 17, 2024
3daef91
sync repository
AmineDiro Sep 17, 2024
5803fb9
sync service
AmineDiro Sep 17, 2024
13b288f
oauth2 state
AmineDiro Sep 18, 2024
ae70171
oauth2 refacto
AmineDiro Sep 18, 2024
c5d372b
ruff formatter vscode
AmineDiro Sep 18, 2024
b0e76e3
syncs + cleanupdb
AmineDiro Sep 18, 2024
339c6b6
sync list return knowledge info
AmineDiro Sep 19, 2024
625dfa2
brain dto join
AmineDiro Sep 20, 2024
08d7b33
sync knowledge
AmineDiro Sep 20, 2024
9bf4519
knowledge link to brain DONE
AmineDiro Sep 20, 2024
6d1dd8d
fixed sync children none
AmineDiro Sep 20, 2024
6e91583
link knowledge on creation
AmineDiro Sep 23, 2024
50a0800
merged n+1 query optimization
AmineDiro Sep 23, 2024
211fcaa
processor class worker
AmineDiro Sep 23, 2024
51421c0
working process knowledge
AmineDiro Sep 24, 2024
5b39026
all tests working
AmineDiro Sep 25, 2024
e99beab
merged main
AmineDiro Sep 25, 2024
0a8faaf
fixed tests
AmineDiro Sep 25, 2024
0654860
link brain appends unique brains
AmineDiro Sep 25, 2024
8fc8219
added sync status
AmineDiro Sep 25, 2024
c9d8a50
process file sync
AmineDiro Sep 25, 2024
ae3a5ef
worker tests working
AmineDiro Sep 25, 2024
da160ae
small refacto
AmineDiro Sep 25, 2024
e318ad6
rollback on error working
AmineDiro Sep 25, 2024
6c2ba27
rollback on error working
AmineDiro Sep 25, 2024
5a88bf0
knowledge sync
AmineDiro Sep 25, 2024
bb18d13
Merge pull request #3226 from QuivrHQ/feature/ent-67-backend-remove-s…
AmineDiro Sep 25, 2024
1d5761d
added test sync file in different brain
AmineDiro Sep 26, 2024
1b3915c
unlink from brain
AmineDiro Sep 26, 2024
74a8989
profiler for tests
AmineDiro Sep 26, 2024
d17d796
Merge pull request #3268 from QuivrHQ/feat/remove-km-kms
AmineDiro Sep 26, 2024
868058f
notifier update
AmineDiro Sep 26, 2024
970bbac
readme update
AmineDiro Sep 26, 2024
84b1901
updated readme
AmineDiro Sep 26, 2024
42a2dbb
readme
AmineDiro Sep 26, 2024
e9e0dbd
readme
AmineDiro Sep 26, 2024
5139294
Update README.md
AmineDiro Sep 26, 2024
4f36519
root list join on children only
AmineDiro Sep 27, 2024
c7491b8
serialization benchmark
AmineDiro Sep 27, 2024
f08f653
url tests
AmineDiro Sep 27, 2024
23a3c6d
Merge pull request #3269 from QuivrHQ/feat/notifier-kms
AmineDiro Sep 27, 2024
055a033
load tested kms
AmineDiro Sep 27, 2024
fa46f30
fix awaitable attr knowledge
AmineDiro Sep 27, 2024
8d0ca96
pool size as param + locust on_start/on_stop setup
AmineDiro Sep 28, 2024
edda350
Merge pull request #3272 from QuivrHQ/release/load-test-kms
AmineDiro Sep 30, 2024
ae5f6a8
sync init
AmineDiro Sep 30, 2024
95df919
sync status added
AmineDiro Sep 30, 2024
6cc61bc
Merge pull request #3281 from QuivrHQ/fix/sync-status-added
AmineDiro Sep 30, 2024
62ff887
Merge remote-tracking branch 'origin/fix/sync-status-added' into feat…
AmineDiro Sep 30, 2024
8d729de
get files last synced at
AmineDiro Sep 30, 2024
7fbfab8
sync knowledge service
AmineDiro Sep 30, 2024
f8db112
sync utils
AmineDiro Sep 30, 2024
0b7eecd
working update + tests
AmineDiro Oct 1, 2024
3ed0de5
test sync update single file
AmineDiro Oct 1, 2024
b99db0f
celery worker update syncs
AmineDiro Oct 1, 2024
4180026
celery worker time limits
AmineDiro Oct 1, 2024
53ba2bb
modify Readme.ms
AmineDiro Oct 1, 2024
22bd331
Merge pull request #3303 from QuivrHQ/feat/sync-knowledges
AmineDiro Oct 2, 2024
e8e5de5
merged main
AmineDiro Oct 4, 2024
713fa86
added field brains
AmineDiro Oct 4, 2024
fdf51c6
Merge pull request #3323 from QuivrHQ/feature/core-216-fix-add-all-br…
AmineDiro Oct 7, 2024
e7cdf6a
file size limit
Oct 7, 2024
1f826c9
Merge pull request #3332 from QuivrHQ/feat/kms-file-size-limit
AmineDiro Oct 7, 2024
233b496
fix update knowledge (#3334)
AmineDiro Oct 7, 2024
24f672f
fix arg length
AmineDiro Oct 7, 2024
b7f49d5
Merge pull request #3337 from QuivrHQ/fix/logger-args-len-sync
AmineDiro Oct 7, 2024
6075b83
update km date
AmineDiro Oct 7, 2024
1bb25eb
Merge pull request #3338 from QuivrHQ/fix/km-update-dat
AmineDiro Oct 7, 2024
aae36f4
sort knowledge, remove bulk_id
AmineDiro Oct 8, 2024
4c4cd6d
modified test
AmineDiro Oct 8, 2024
a81f553
updated benchmark with routes
AmineDiro Oct 8, 2024
9076729
Merge pull request #3348 from QuivrHQ/fix/sort-knowledge-update-brain
AmineDiro Oct 9, 2024
87a7116
Merge pull request #3350 from QuivrHQ/feat/locust-kms
AmineDiro Oct 9, 2024
fcf2b34
merged release/kms
AmineDiro Oct 14, 2024
2fe24d2
Merge pull request #3271 from QuivrHQ/feat/url-add-knowledge
AmineDiro Oct 14, 2024
4e88b7e
sort brain name and knowledge list local
AmineDiro Oct 16, 2024
b241103
Merge pull request #3379 from QuivrHQ/fix/sort-brain-list-km-only
AmineDiro Oct 16, 2024
505a765
fix: sync provider naming (#3380)
AmineDiro Oct 16, 2024
939d28d
fixed wrong parsing file extension
AmineDiro Oct 16, 2024
f899cd1
Merge pull request #3386 from QuivrHQ/fix/knowledge-parsing
AmineDiro Oct 17, 2024
fe16805
feat(frontend): display all knowledge in a kms (#3411)
Zewed Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ EXTERNAL_SUPABASE_URL=http://localhost:54321
SUPABASE_SERVICE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
PG_DATABASE_URL=postgresql://postgres:[email protected]:54322/postgres
PG_DATABASE_ASYNC_URL=postgresql+asyncpg://postgres:[email protected]:54322/postgres
SQLALCHEMY_POOL_SIZE=10
SQLALCHEMY_MAX_POOL_OVERFLOW=0
JWT_SECRET_KEY=super-secret-jwt-token-with-at-least-32-characters-long
AUTHENTICATE=true
TELEMETRY_ENABLED=true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,4 @@ backend/core/examples/chatbot/.chainlit/translations/en-US.json
.tox
Pipfile
*.pkl
backend/benchmarks/data.json
10 changes: 4 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.organizeImports.ruff": "explicit",
"source.fixAll": "explicit",
"source.unusedImports": "explicit",
"source.unusedImports": "explicit"
},
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
Expand All @@ -24,9 +25,7 @@
"source.fixAll": "explicit"
}
},
"python.analysis.extraPaths": [
"./backend"
],
"python.analysis.extraPaths": ["./backend"],
"python.defaultInterpreterPath": "python3",
"python.testing.pytestArgs": [
"-v",
Expand All @@ -43,6 +42,5 @@
"reportMissingImports": "error",
"reportUnusedImport": "warning",
"reportGeneralTypeIssues": "warning"
},
"makefile.configureOnOpen": false
}
}
5 changes: 4 additions & 1 deletion backend/api/quivr_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from quivr_api.modules.brain.entity.brain_entity import Brain
from quivr_api.modules.brain.entity.brain_user import BrainUserDB
from quivr_api.modules.knowledge.entity.knowledge import KnowledgeDB

from .modules.chat.entity.chat import Chat, ChatHistory
from .modules.sync.entity.sync_models import NotionSyncFile
from .modules.sync.entity.sync_models import NotionSyncFile, Sync
from .modules.user.entity.user_identity import User

__all__ = [
"Chat",
"ChatHistory",
"BrainUserDB",
"User",
"NotionSyncFile",
"KnowledgeDB",
"Brain",
"Sync",
]
7 changes: 5 additions & 2 deletions backend/api/quivr_api/models/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def set_once_user_properties(self, user_id: UUID, event_name, properties: dict):

class BrainSettings(BaseSettings):
model_config = SettingsConfigDict(validate_default=False)
pg_database_url: str
pg_database_async_url: str
openai_api_key: str = ""
azure_openai_embeddings_url: str = ""
supabase_url: str = ""
Expand All @@ -112,9 +114,10 @@ class BrainSettings(BaseSettings):
ollama_api_base_url: str | None = None
langfuse_public_key: str | None = None
langfuse_secret_key: str | None = None
pg_database_url: str
pg_database_async_url: str
sqlalchemy_pool_size: int = 5
sqlalchemy_max_pool_overflow: int = 5
embedding_dim: int = 1536
max_file_size: int = int(5e7)


class ResendSettings(BaseSettings):
Expand Down
73 changes: 0 additions & 73 deletions backend/api/quivr_api/models/sqlalchemy_repository.py

This file was deleted.

8 changes: 7 additions & 1 deletion backend/api/quivr_api/modules/brain/entity/brain_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from sqlmodel import TIMESTAMP, Column, Field, Relationship, SQLModel, text
from sqlmodel import UUID as PGUUID

from quivr_api.modules.brain.entity.brain_user import BrainUserDB
from quivr_api.modules.brain.entity.integration_brain import (
IntegrationDescriptionEntity,
IntegrationEntity,
Expand Down Expand Up @@ -69,7 +70,12 @@ class Brain(AsyncAttrs, SQLModel, table=True):
knowledges: List[KnowledgeDB] = Relationship(
back_populates="brains", link_model=KnowledgeBrain
)

users: List["User"] = Relationship( # type: ignore # noqa: F821
back_populates="brains",
link_model=BrainUserDB,
)
snippet_color: str | None = Field(default="#d0c6f2")
snippet_emoji: str | None = Field(default="🧠")
# TODO : add
# "meaning" "public"."vector",
# "tags" "public"."tags"[]
Expand Down
14 changes: 14 additions & 0 deletions backend/api/quivr_api/modules/brain/entity/brain_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from uuid import UUID

from sqlmodel import Field, SQLModel


class BrainUserDB(SQLModel, table=True):
__tablename__ = "brains_users" # type: ignore

brain_id: UUID = Field(
nullable=False, foreign_key="brains.brain_id", primary_key=True
)
user_id: UUID = Field(nullable=False, foreign_key="users.id", primary_key=True)
default_brain: bool
rights: str
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from quivr_api.logger import get_logger
from quivr_api.modules.brain.entity.brain_entity import (
BrainUser,
BrainUserDB,
MinimalUserBrainEntity,
)
from quivr_api.modules.brain.repository.interfaces.brains_users_interface import (
Expand Down Expand Up @@ -161,15 +161,15 @@ def get_user_default_brain_id(self, user_id: UUID) -> UUID | None:
return None
return UUID(response[0].get("brain_id"))

def get_brain_users(self, brain_id: UUID) -> list[BrainUser]:
def get_brain_users(self, brain_id: UUID) -> list[BrainUserDB]:
response = (
self.db.table("brains_users")
.select("id:brain_id, *")
.filter("brain_id", "eq", str(brain_id))
.execute()
)

return [BrainUser(**item) for item in response.data]
return [BrainUserDB(**item) for item in response.data]

def delete_brain_subscribers(self, brain_id: UUID):
results = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from uuid import UUID

from quivr_api.modules.brain.entity.brain_entity import (
BrainUser,
BrainUserDB,
MinimalUserBrainEntity,
)

Expand Down Expand Up @@ -56,7 +56,7 @@ def get_user_default_brain_id(self, user_id: UUID) -> UUID | None:
pass

@abstractmethod
def get_brain_users(self, brain_id: UUID) -> List[BrainUser]:
def get_brain_users(self, brain_id: UUID) -> List[BrainUserDB]:
"""
Get all users for a brain
"""
Expand Down Expand Up @@ -88,7 +88,7 @@ def update_brain_user_default_status(
@abstractmethod
def update_brain_user_rights(
self, brain_id: UUID, user_id: UUID, rights: str
) -> BrainUser:
) -> BrainUserDB:
"""
Update the rights for a user in a brain
"""
Expand Down
4 changes: 2 additions & 2 deletions backend/api/quivr_api/modules/brain/service/brain_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Optional, Tuple
from typing import Optional, Tuple
from uuid import UUID

from fastapi import HTTPException
Expand Down Expand Up @@ -54,7 +54,7 @@ def find_brain_from_question(
chat_id: UUID,
history,
vector_store: CustomSupabaseVectorStore,
) -> Tuple[Optional[BrainEntity], Dict[str, str]]:
) -> Tuple[Optional[BrainEntity], dict[str, str]]:
"""Find the brain to use for a question.

Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from quivr_api.logger import get_logger
from quivr_api.modules.brain.entity.brain_entity import (
BrainEntity,
BrainUser,
BrainUserDB,
MinimalUserBrainEntity,
RoleEnum,
)
Expand Down Expand Up @@ -74,7 +74,7 @@ def get_user_brains(self, user_id: UUID) -> list[MinimalUserBrainEntity]:

return results # type: ignore

def get_brain_users(self, brain_id: UUID) -> List[BrainUser]:
def get_brain_users(self, brain_id: UUID) -> List[BrainUserDB]:
return self.brain_user_repository.get_brain_users(brain_id)

def update_brain_user_rights(
Expand Down
15 changes: 7 additions & 8 deletions backend/api/quivr_api/modules/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
from fastapi import Depends
from langchain.embeddings.base import Embeddings
from langchain_community.embeddings.ollama import OllamaEmbeddings

# from langchain_community.vectorstores.supabase import SupabaseVectorStore
from langchain_openai import AzureOpenAIEmbeddings, OpenAIEmbeddings

# from quivr_api.modules.vector.service.vector_service import VectorService
# from quivr_api.modules.vectorstore.supabase import CustomSupabaseVectorStore
from sqlalchemy import Engine, create_engine
from sqlalchemy.ext.asyncio import create_async_engine
from sqlmodel import Session, text
Expand Down Expand Up @@ -61,16 +56,20 @@ def get_repository_cls(cls) -> Type[R]:
future=True,
# NOTE: pessimistic bound on
pool_pre_ping=True,
pool_size=10, # NOTE: no bouncer for now, if 6 process workers => 6
pool_size=1, # NOTE: no bouncer for now, if 6 process workers => 6
max_overflow=0,
pool_recycle=1800,
)
async_engine = create_async_engine(
settings.pg_database_async_url,
connect_args={"server_settings": {"application_name": "quivr-api-async"}},
connect_args={
"server_settings": {"application_name": "quivr-api-async"},
},
echo=True if os.getenv("ORM_DEBUG") else False,
future=True,
pool_pre_ping=True,
pool_size=5, # NOTE: no bouncer for now, if 6 process workers => 6
pool_size=settings.sqlalchemy_pool_size, # NOTE: no bouncer for now, if 6 process workers => 6
max_overflow=settings.sqlalchemy_max_pool_overflow,
pool_recycle=1800,
isolation_level="AUTOCOMMIT",
)
Expand Down
Loading
Loading