From 73a47c3107b207f5ae080928dca0cbe9ad71cc17 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 23 Jul 2025 10:49:36 +0800 Subject: [PATCH] perf: Enable assistant cache --- backend/apps/system/api/assistant.py | 1 - backend/apps/system/crud/assistant.py | 2 +- backend/apps/system/models/system_model.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/apps/system/api/assistant.py b/backend/apps/system/api/assistant.py index ee5477a5..0b1b7cd7 100644 --- a/backend/apps/system/api/assistant.py +++ b/backend/apps/system/api/assistant.py @@ -32,7 +32,6 @@ async def info(session: SessionDep, id: str, virtual: Optional[int] = Query(None db_model = await get_assistant_info(session=session, assistant_id=id) if not db_model: return AssistantValidator() - print(db_model) db_model = AssistantModel.model_validate(db_model) access_token_expires = timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES) assistantDict = { diff --git a/backend/apps/system/crud/assistant.py b/backend/apps/system/crud/assistant.py index 2c0176f7..fddf2247 100644 --- a/backend/apps/system/crud/assistant.py +++ b/backend/apps/system/crud/assistant.py @@ -17,7 +17,7 @@ from starlette.middleware.cors import CORSMiddleware from common.core.config import settings from common.utils.utils import string_to_numeric_hash -#@cache(namespace=CacheNamespace.EMBEDDED_INFO, cacheName=CacheName.ASSISTANT_INFO, keyExpression="assistant_id") +@cache(namespace=CacheNamespace.EMBEDDED_INFO, cacheName=CacheName.ASSISTANT_INFO, keyExpression="assistant_id") async def get_assistant_info(*, session: Session, assistant_id: int) -> AssistantModel | None: db_model = session.get(AssistantModel, assistant_id) return db_model diff --git a/backend/apps/system/models/system_model.py b/backend/apps/system/models/system_model.py index 5e73d12e..c743533d 100644 --- a/backend/apps/system/models/system_model.py +++ b/backend/apps/system/models/system_model.py @@ -47,7 +47,7 @@ class AssistantBaseModel(SQLModel): name: str = Field(max_length=255, nullable=False) type: int = Field(nullable=False, default=0) domain: str = Field(max_length=255, nullable=False) - description: str = Field(sa_type = Text(), nullable=True) + description: Optional[str] = Field(sa_type = Text(), nullable=True) configuration: Optional[str] = Field(sa_type = Text(), nullable=True) create_time: int = Field(default=0, sa_type=BigInteger())