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

fix: fix missing kb repo and enable F821 ruff rule #606

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion backend/app/models/api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions backend/app/models/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions backend/app/models/chat_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
4 changes: 2 additions & 2 deletions backend/app/models/chat_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions backend/app/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ 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",
},
)

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",
Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/evaluation_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/evaluation_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions backend/app/models/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/recommend_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion backend/app/rag/chat_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ dev-dependencies = [
]

[tool.ruff.lint]
ignore = ["E711", "E712", "F811", "F821", "F841"]
ignore = ["E711", "E712", "F811", "F841"]
6 changes: 4 additions & 2 deletions frontend/app/src/pages/docs/llm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ Default config:

To learn more about OpenRouter, please visit [OpenRouter](https://openrouter.ai/).

<!-- #### ZhipuAI BigModel
{/*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix errors on ci: cc @sykp241095

./src/pages/docs/llm.mdx
Unexpected character `!` (U+0021) before name, expected a character that can start a name, such as a letter, `$`, or `_` (note: to create a comment in MDX, use `{/* text */}`)

#### ZhipuAI BigModel
Default config:
Expand All @@ -91,7 +92,8 @@ Default config:
}
```
To learn more about BigModel, please visit [BigModel](https://open.bigmodel.cn/). -->
To learn more about BigModel, please visit [BigModel](https://open.bigmodel.cn/).
*/}

#### Ollama

Expand Down
Loading