Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
StanGirard committed Sep 11, 2024
1 parent 080333f commit 30a7391
Show file tree
Hide file tree
Showing 70 changed files with 127 additions and 67 deletions.
2 changes: 1 addition & 1 deletion backend/api/quivr_api/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from colorlog import (
ColoredFormatter,
) # You need to install this package: pip install colorlog
)


def get_logger(logger_name, log_file="application.log"):
Expand Down
1 change: 1 addition & 0 deletions backend/api/quivr_api/middlewares/auth/auth_bearer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from fastapi import Depends, HTTPException, Request
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer

from quivr_api.middlewares.auth.jwt_token_handler import (
decode_access_token,
verify_token,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from jose import jwt
from jose.exceptions import JWTError

from quivr_api.modules.user.entity.user_identity import UserIdentity

SECRET_KEY = os.environ.get("JWT_SECRET_KEY")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from uuid import UUID

from pydantic import BaseModel, ConfigDict

from quivr_api.logger import get_logger

logger = get_logger(__name__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from uuid import UUID

from fastapi import APIRouter, Depends, Query

from quivr_api.middlewares.auth.auth_bearer import AuthBearer, get_current_user
from quivr_api.modules.analytics.entity.analytics import Range
from quivr_api.modules.analytics.service.analytics_service import AnalyticsService
Expand Down
3 changes: 2 additions & 1 deletion backend/api/quivr_api/modules/analytics/entity/analytics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from datetime import date
from enum import IntEnum
from typing import List

from pydantic import BaseModel
from datetime import date


class Range(IntEnum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from uuid import uuid4

from fastapi import APIRouter, Depends

from quivr_api.logger import get_logger
from quivr_api.middlewares.auth import AuthBearer, get_current_user
from quivr_api.modules.api_key.dto.outputs import ApiKeyInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime

from fastapi import HTTPException

from quivr_api.logger import get_logger
from quivr_api.modules.api_key.repository.api_key_interface import ApiKeysInterface
from quivr_api.modules.api_key.repository.api_keys import ApiKeys
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# noqa:
from .assistant_routes import assistant_router


__all__ = [
"assistant_router",
]
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from fastapi import APIRouter, Request, Depends
from fastapi import APIRouter, Depends, Request

from quivr_api.logger import get_logger
from quivr_api.middlewares.auth.auth_bearer import AuthBearer, get_current_user
from quivr_api.modules.user.entity.user_identity import UserIdentity


logger = get_logger(__name__)


Expand Down
Empty file.
32 changes: 32 additions & 0 deletions backend/api/quivr_api/modules/assistant/entity/task_entity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from datetime import datetime
from uuid import UUID

from sqlmodel import TIMESTAMP, Column, Field, SQLModel, text
from sqlmodel import UUID as PGUUID


class Task(SQLModel, table=True):
__tablename__ = "tasks" # type: ignore

id: UUID | None = Field(
default=None,
sa_column=Column(
PGUUID,
server_default=text("uuid_generate_v4()"),
primary_key=True,
),
)

pretty_id: str
user_id: UUID = Field(foreign_key="users.id")
status: str
creation_time: datetime | None = Field(
default=None,
sa_column=Column(
TIMESTAMP(timezone=False),
server_default=text("CURRENT_TIMESTAMP"),
),
)
# Json for answer_raw
answer_raw: dict | None = Field(default=None)
answer_pretty: str | None = Field(default=None)
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from abc import ABC, abstractmethod
from typing import List
from uuid import UUID

from quivr_api.modules.assistant.entity.task_entity import Task


class TasksInterface(ABC):
@abstractmethod
def create_task(self, task: Task) -> Task:
pass

@abstractmethod
def get_task_by_id(self, task_id: UUID) -> Task:
pass

@abstractmethod
def delete_task(self, task_id: UUID) -> None:
pass

@abstractmethod
def get_tasks_by_user_id(self, user_id: UUID) -> List[Task]:
pass
1 change: 0 additions & 1 deletion backend/api/quivr_api/modules/brain/controller/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .brain_routes import brain_router


__all__ = [
"brain_router",
]
1 change: 1 addition & 0 deletions backend/api/quivr_api/modules/brain/dto/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from uuid import UUID

from pydantic import BaseModel

from quivr_api.logger import get_logger
from quivr_api.modules.brain.entity.brain_entity import BrainType
from quivr_api.modules.brain.entity.integration_brain import IntegrationType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
SystemMessagePromptTemplate,
)
from langchain_core.prompts.prompt import PromptTemplate

from quivr_api.logger import get_logger
from quivr_api.modules.brain.knowledge_brain_qa import KnowledgeBrainQA
from quivr_api.modules.chat.dto.chats import ChatQuestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from langchain_community.chat_models import ChatLiteLLM
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder

from quivr_api.modules.brain.knowledge_brain_qa import KnowledgeBrainQA
from quivr_api.modules.chat.dto.chats import ChatQuestion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from langchain_openai import ChatOpenAI
from langgraph.graph import END, StateGraph
from langgraph.prebuilt import ToolExecutor, ToolInvocation

from quivr_api.logger import get_logger
from quivr_api.modules.brain.knowledge_brain_qa import KnowledgeBrainQA
from quivr_api.modules.chat.dto.chats import ChatQuestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from langchain_community.chat_models import ChatLiteLLM
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder

from quivr_api.logger import get_logger
from quivr_api.modules.brain.knowledge_brain_qa import KnowledgeBrainQA
from quivr_api.modules.chat.dto.chats import ChatQuestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough

from quivr_api.modules.brain.integrations.SQL.SQL_connector import SQLConnector
from quivr_api.modules.brain.knowledge_brain_qa import KnowledgeBrainQA
from quivr_api.modules.brain.repository.integration_brains import IntegrationBrain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
from langchain_core.pydantic_v1 import Field as FieldV1
from langchain_openai import ChatOpenAI
from langgraph.graph import END, StateGraph
from typing_extensions import TypedDict

from quivr_api.logger import get_logger
from quivr_api.modules.brain.knowledge_brain_qa import KnowledgeBrainQA
from quivr_api.modules.chat.dto.chats import ChatQuestion
from quivr_api.modules.chat.dto.outputs import GetChatHistoryOutput
from quivr_api.modules.chat.service.chat_service import ChatService
from quivr_api.modules.dependencies import get_service
from typing_extensions import TypedDict


# Post-processing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from uuid import UUID

from fastapi import Depends, HTTPException, status

from quivr_api.middlewares.auth.auth_bearer import get_current_user
from quivr_api.modules.brain.entity.brain_entity import RoleEnum
from quivr_api.modules.brain.service.brain_service import BrainService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from uuid import UUID

from fastapi import HTTPException

from quivr_api.logger import get_logger
from quivr_api.modules.brain.entity.brain_entity import (
BrainEntity,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import List, Tuple

from langchain_core.messages import AIMessage, BaseMessage, HumanMessage, SystemMessage

from quivr_api.modules.chat.dto.outputs import GetChatHistoryOutput


Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from fastapi import HTTPException
from quivr_api.modules.brain.dto.inputs import CreateBrainProperties
1 change: 1 addition & 0 deletions backend/api/quivr_api/modules/chat/dto/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from uuid import UUID

from pydantic import BaseModel

from quivr_api.modules.chat.dto.outputs import GetChatHistoryOutput
from quivr_api.modules.notification.entity.notification import Notification

Expand Down
8 changes: 4 additions & 4 deletions backend/api/quivr_api/modules/chat/entity/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from typing import List
from uuid import UUID

from quivr_api.modules.brain.entity.brain_entity import Brain
from quivr_api.modules.user.entity.user_identity import User
from sqlalchemy.ext.asyncio import AsyncAttrs
from sqlmodel import JSON, TIMESTAMP
from sqlmodel import JSON, TIMESTAMP, Column, Field, Relationship, SQLModel, text
from sqlmodel import UUID as PGUUID
from sqlmodel import Column, Field, Relationship, SQLModel, text

from quivr_api.modules.brain.entity.brain_entity import Brain
from quivr_api.modules.user.entity.user_identity import User


class Chat(SQLModel, table=True):
Expand Down
4 changes: 1 addition & 3 deletions backend/api/quivr_api/modules/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from langchain_community.embeddings.ollama import OllamaEmbeddings

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

# from quivr_api.modules.vector.service.vector_service import VectorService
# from quivr_api.modules.vectorstore.supabase import CustomSupabaseVectorStore
Expand All @@ -22,7 +21,6 @@
from quivr_api.models.settings import BrainSettings
from supabase.client import AsyncClient, Client, create_async_client, create_client


# Global variables to store the Supabase client and database instances
_supabase_client: Optional[Client] = None
_supabase_async_client: Optional[AsyncClient] = None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Annotated, List

from fastapi import APIRouter, Depends

from quivr_api.logger import get_logger
from quivr_api.middlewares.auth import AuthBearer, get_current_user
from quivr_api.modules.dependencies import get_service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from uuid import UUID

from fastapi import APIRouter, Depends

from quivr_api.middlewares.auth import AuthBearer
from quivr_api.modules.prompt.entity.prompt import (
CreatePromptProperties,
Expand Down
4 changes: 2 additions & 2 deletions backend/api/quivr_api/modules/prompt/entity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .prompt import (
CreatePromptProperties,
DeletePromptResponse,
Prompt,
PromptStatusEnum,
CreatePromptProperties,
PromptUpdatableProperties,
DeletePromptResponse,
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from fastapi import APIRouter, Depends, HTTPException, Request
from fastapi.responses import HTMLResponse
from msal import ConfidentialClientApplication

from quivr_api.logger import get_logger
from quivr_api.middlewares.auth import AuthBearer, get_current_user
from quivr_api.modules.sync.dto.inputs import SyncsUserInput, SyncUserUpdateInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import requests
from fastapi import APIRouter, Depends, HTTPException, Request
from fastapi.responses import HTMLResponse

from quivr_api.logger import get_logger
from quivr_api.middlewares.auth import AuthBearer, get_current_user
from quivr_api.modules.sync.dto.inputs import SyncsUserInput, SyncUserUpdateInput
Expand Down
1 change: 1 addition & 0 deletions backend/api/quivr_api/modules/sync/entity/notion_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field, field_validator

from quivr_api.modules.sync.entity.sync_models import NotionSyncFile


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
from typing import List, Sequence
from uuid import UUID

from sqlalchemy import or_
from sqlalchemy.exc import IntegrityError
from sqlmodel import col, select
from sqlmodel.ext.asyncio.session import AsyncSession

from quivr_api.logger import get_logger
from quivr_api.modules.dependencies import BaseRepository, get_supabase_client
from quivr_api.modules.notification.service.notification_service import (
Expand All @@ -10,10 +15,6 @@
from quivr_api.modules.sync.dto.inputs import SyncsActiveInput, SyncsActiveUpdateInput
from quivr_api.modules.sync.entity.sync_models import NotionSyncFile, SyncsActive
from quivr_api.modules.sync.repository.sync_interfaces import SyncInterface
from sqlalchemy import or_
from sqlalchemy.exc import IntegrityError
from sqlmodel import col, select
from sqlmodel.ext.asyncio.session import AsyncSession

notification_service = NotificationService()

Expand Down
4 changes: 2 additions & 2 deletions backend/api/quivr_api/modules/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .email_sender import EmailSenderTool
from .image_generator import ImageGeneratorTool
from .web_search import WebSearchTool
from .url_reader import URLReaderTool
from .email_sender import EmailSenderTool
from .web_search import WebSearchTool
1 change: 1 addition & 0 deletions backend/api/quivr_api/modules/tools/url_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from langchain_community.document_loaders import PlaywrightURLLoader
from langchain_core.tools import BaseTool
from pydantic import BaseModel

from quivr_api.logger import get_logger

logger = get_logger(__name__)
Expand Down
1 change: 1 addition & 0 deletions backend/api/quivr_api/modules/tools/web_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from langchain.pydantic_v1 import Field as FieldV1
from langchain_core.tools import BaseTool
from pydantic import BaseModel

from quivr_api.logger import get_logger

logger = get_logger(__name__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
from multiprocessing import get_logger

from quivr_api.modules.dependencies import get_supabase_client
from supabase.client import Client
import os

logger = get_logger()

Expand Down
Loading

0 comments on commit 30a7391

Please sign in to comment.