From 84aec160d38afce722a2ebaba1fcc6098cf0e9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=96=B9=E7=9A=84=E8=B5=9B=E5=8D=9A=E7=9C=9F?= =?UTF-8?q?=E5=90=9B?= Date: Wed, 28 Jan 2026 14:53:22 +0800 Subject: [PATCH] feat(config): add RECOMMENDED_QUESTIONS_ENABLED toggle Add system-level configuration to enable/disable LLM-generated recommended questions. When disabled, the API returns empty array instead of calling LLM, affecting both quick questions and post-message suggestions. - Add RECOMMENDED_QUESTIONS_ENABLED in config.py (default: true) - Add config check in ask_recommend_questions API endpoint --- backend/apps/chat/api/chat.py | 4 ++++ backend/common/core/config.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/backend/apps/chat/api/chat.py b/backend/apps/chat/api/chat.py index 773bbcca..2b8e6d4d 100644 --- a/backend/apps/chat/api/chat.py +++ b/backend/apps/chat/api/chat.py @@ -21,6 +21,7 @@ from apps.swagger.i18n import PLACEHOLDER_PREFIX from apps.system.schemas.permission import SqlbotPermission, require_permissions from common.core.deps import CurrentAssistant, SessionDep, CurrentUser, Trans +from common.core.config import settings from common.utils.command_utils import parse_quick_command from common.utils.data_format import DataFormat from common.audit.models.log_model import OperationType, OperationModules @@ -198,6 +199,9 @@ async def ask_recommend_questions(session: SessionDep, current_user: CurrentUser def _return_empty(): yield 'data:' + orjson.dumps({'content': '[]', 'type': 'recommended_question'}).decode() + '\n\n' + if not settings.RECOMMENDED_QUESTIONS_ENABLED: + return StreamingResponse(_return_empty(), media_type="text/event-stream") + try: record = get_chat_record_by_id(session, chat_record_id) diff --git a/backend/common/core/config.py b/backend/common/core/config.py index 1b3cc24e..aa0825a1 100644 --- a/backend/common/core/config.py +++ b/backend/common/core/config.py @@ -124,6 +124,9 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn | str: TABLE_EMBEDDING_COUNT: int = 10 DS_EMBEDDING_COUNT: int = 10 + # 推荐问题配置(LLM生成) + RECOMMENDED_QUESTIONS_ENABLED: bool = True + ORACLE_CLIENT_PATH: str = '/opt/sqlbot/db_client/oracle_instant_client' @field_validator('SQL_DEBUG', @@ -132,6 +135,7 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn | str: 'PARSE_REASONING_BLOCK_ENABLED', 'PG_POOL_PRE_PING', 'TABLE_EMBEDDING_ENABLED', + 'RECOMMENDED_QUESTIONS_ENABLED', mode='before') @classmethod def lowercase_bool(cls, v: Any) -> Any: