diff --git a/backend/app/models/api_key.py b/backend/app/models/api_key.py index 1db0997d..e7d494f3 100644 --- a/backend/app/models/api_key.py +++ b/backend/app/models/api_key.py @@ -19,7 +19,7 @@ class BaseApiKey(UpdatableBaseModel): class ApiKey(BaseApiKey, table=True): id: Optional[int] = Field(default=None, primary_key=True) hashed_secret: str = Field(max_length=255, unique=True) - user: "User" = SQLRelationship( + user: "User" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "ApiKey.user_id == User.id", diff --git a/backend/app/models/chat.py b/backend/app/models/chat.py index 2e619b47..d0bbf531 100644 --- a/backend/app/models/chat.py +++ b/backend/app/models/chat.py @@ -24,7 +24,7 @@ class ChatVisibility(int, enum.Enum): class Chat(UUIDBaseModel, UpdatableBaseModel, table=True): title: str = Field(max_length=256) engine_id: int = Field(foreign_key="chat_engines.id", nullable=True) - engine: "ChatEngine" = SQLRelationship( + engine: "ChatEngine" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "Chat.engine_id == ChatEngine.id", @@ -34,7 +34,7 @@ class Chat(UUIDBaseModel, UpdatableBaseModel, table=True): engine_options: Dict | str = Field(default={}, sa_column=Column(JSON)) deleted_at: Optional[datetime] = Field(default=None, sa_column=Column(DateTime)) user_id: UUID = Field(foreign_key="users.id", nullable=True) - user: "User" = SQLRelationship( + user: "User" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "Chat.user_id == User.id", diff --git a/backend/app/models/chat_engine.py b/backend/app/models/chat_engine.py index ccb1ba05..3c5d7bd2 100644 --- a/backend/app/models/chat_engine.py +++ b/backend/app/models/chat_engine.py @@ -18,19 +18,19 @@ class ChatEngine(UpdatableBaseModel, table=True): name: str = Field(max_length=256) engine_options: Dict = Field(default={}, sa_column=Column(JSON)) llm_id: Optional[int] = Field(foreign_key="llms.id", nullable=True) - llm: "LLM" = SQLRelationship( + llm: "LLM" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "foreign_keys": "ChatEngine.llm_id", }, ) fast_llm_id: Optional[int] = Field(foreign_key="llms.id", nullable=True) - fast_llm: "LLM" = SQLRelationship( + fast_llm: "LLM" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "foreign_keys": "ChatEngine.fast_llm_id", }, ) reranker_id: Optional[int] = Field(foreign_key="reranker_models.id", nullable=True) - reranker: "RerankerModel" = SQLRelationship( + reranker: "RerankerModel" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "foreign_keys": "ChatEngine.reranker_id", }, diff --git a/backend/app/models/chat_message.py b/backend/app/models/chat_message.py index 613b758d..7e397608 100644 --- a/backend/app/models/chat_message.py +++ b/backend/app/models/chat_message.py @@ -32,14 +32,14 @@ class ChatMessage(UpdatableBaseModel, table=True): ) finished_at: Optional[datetime] = Field(default=None, sa_column=Column(DateTime)) chat_id: UUID = Field(foreign_key="chats.id") - chat: "Chat" = SQLRelationship( + chat: "Chat" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "ChatMessage.chat_id == Chat.id", }, ) user_id: UUID = Field(foreign_key="users.id", nullable=True) - user: "User" = SQLRelationship( + user: "User" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "ChatMessage.user_id == User.id", diff --git a/backend/app/models/document.py b/backend/app/models/document.py index a0df28db..77b3c84d 100644 --- a/backend/app/models/document.py +++ b/backend/app/models/document.py @@ -48,7 +48,7 @@ class Document(UpdatableBaseModel, table=True): # TODO: add kg_index_status, kg_index_result column, unify the index status. data_source_id: int = Field(foreign_key="data_sources.id", nullable=True) - data_source: "DataSource" = SQLRelationship( + data_source: "DataSource" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "Document.data_source_id == DataSource.id", @@ -56,7 +56,7 @@ class Document(UpdatableBaseModel, table=True): ) knowledge_base_id: int = Field(foreign_key="knowledge_bases.id", nullable=True) - knowledge_base: "KnowledgeBase" = SQLRelationship( + knowledge_base: "KnowledgeBase" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "Document.knowledge_base_id == KnowledgeBase.id", diff --git a/backend/app/models/evaluation_dataset.py b/backend/app/models/evaluation_dataset.py index c453242c..8f7b216b 100644 --- a/backend/app/models/evaluation_dataset.py +++ b/backend/app/models/evaluation_dataset.py @@ -17,7 +17,7 @@ class EvaluationDataset(UpdatableBaseModel, table=True): name: str = Field(max_length=255) user_id: UUID = Field(foreign_key="users.id", nullable=True) - user: "User" = SQLRelationship( + user: "User" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "EvaluationDataset.user_id == User.id", diff --git a/backend/app/models/evaluation_task.py b/backend/app/models/evaluation_task.py index cf0b592b..f84cc318 100644 --- a/backend/app/models/evaluation_task.py +++ b/backend/app/models/evaluation_task.py @@ -27,7 +27,7 @@ class EvaluationTask(UpdatableBaseModel, table=True): name: str = Field(max_length=255) user_id: UUID = Field(foreign_key="users.id", nullable=True) - user: "User" = SQLRelationship( + user: "User" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "EvaluationTask.user_id == User.id", diff --git a/backend/app/models/feedback.py b/backend/app/models/feedback.py index a6e76af7..aa4e7a52 100644 --- a/backend/app/models/feedback.py +++ b/backend/app/models/feedback.py @@ -32,21 +32,21 @@ class BaseFeedback(UpdatableBaseModel): class Feedback(BaseFeedback, table=True): id: Optional[int] = Field(default=None, primary_key=True) chat_id: UUID = Field(foreign_key="chats.id") - chat: "Chat" = SQLRelationship( + chat: "Chat" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "Feedback.chat_id == Chat.id", }, ) chat_message_id: int = Field(foreign_key="chat_messages.id") - chat_message: "ChatMessage" = SQLRelationship( + chat_message: "ChatMessage" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "Feedback.chat_message_id == ChatMessage.id", }, ) user_id: UUID = Field(foreign_key="users.id", nullable=True) - user: "User" = SQLRelationship( + user: "User" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "Feedback.user_id == User.id", diff --git a/backend/app/models/recommend_question.py b/backend/app/models/recommend_question.py index fc449625..37e4e64d 100644 --- a/backend/app/models/recommend_question.py +++ b/backend/app/models/recommend_question.py @@ -14,7 +14,7 @@ class RecommendQuestion(UpdatableBaseModel, table=True): id: Optional[int] = Field(default=None, primary_key=True) questions: List = Field(default=[], sa_column=Column(JSON)) chat_message_id: int = Field(foreign_key="chat_messages.id", index=True) - chat_message: "ChatMessage" = SQLRelationship( + chat_message: "ChatMessage" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "RecommendQuestion.chat_message_id == ChatMessage.id", diff --git a/backend/app/models/upload.py b/backend/app/models/upload.py index 8f3d2ea8..3c84c776 100644 --- a/backend/app/models/upload.py +++ b/backend/app/models/upload.py @@ -19,7 +19,7 @@ class Upload(UpdatableBaseModel, table=True): path: str = Field(max_length=255) mime_type: MimeTypes = Field(sa_column=Column(String(128), nullable=False)) user_id: UUID = Field(foreign_key="users.id", nullable=True) - user: "User" = SQLRelationship( + user: "User" = SQLRelationship( # noqa:F821 sa_relationship_kwargs={ "lazy": "joined", "primaryjoin": "Upload.user_id == User.id", diff --git a/backend/app/rag/chat_config.py b/backend/app/rag/chat_config.py index f7ff3c6b..b2ed15d5 100644 --- a/backend/app/rag/chat_config.py +++ b/backend/app/rag/chat_config.py @@ -20,7 +20,7 @@ RerankerModel as DBRerankerModel, KnowledgeBase, ) -from app.repositories import chat_engine_repo +from app.repositories import chat_engine_repo, knowledge_base_repo from app.rag.default_prompt import ( DEFAULT_INTENT_GRAPH_KNOWLEDGE, DEFAULT_NORMAL_GRAPH_KNOWLEDGE, diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 560b776d..68654781 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -78,4 +78,4 @@ dev-dependencies = [ ] [tool.ruff.lint] -ignore = ["E711", "E712", "F811", "F821", "F841"] +ignore = ["E711", "E712", "F811", "F841"] diff --git a/frontend/app/src/pages/docs/llm.mdx b/frontend/app/src/pages/docs/llm.mdx index feeec75b..697b7d82 100644 --- a/frontend/app/src/pages/docs/llm.mdx +++ b/frontend/app/src/pages/docs/llm.mdx @@ -80,7 +80,8 @@ Default config: To learn more about OpenRouter, please visit [OpenRouter](https://openrouter.ai/). - +To learn more about BigModel, please visit [BigModel](https://open.bigmodel.cn/). +*/} #### Ollama