Skip to content

Commit 84aec16

Browse files
committed
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
1 parent bca72fc commit 84aec16

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

backend/apps/chat/api/chat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from apps.swagger.i18n import PLACEHOLDER_PREFIX
2222
from apps.system.schemas.permission import SqlbotPermission, require_permissions
2323
from common.core.deps import CurrentAssistant, SessionDep, CurrentUser, Trans
24+
from common.core.config import settings
2425
from common.utils.command_utils import parse_quick_command
2526
from common.utils.data_format import DataFormat
2627
from common.audit.models.log_model import OperationType, OperationModules
@@ -198,6 +199,9 @@ async def ask_recommend_questions(session: SessionDep, current_user: CurrentUser
198199
def _return_empty():
199200
yield 'data:' + orjson.dumps({'content': '[]', 'type': 'recommended_question'}).decode() + '\n\n'
200201

202+
if not settings.RECOMMENDED_QUESTIONS_ENABLED:
203+
return StreamingResponse(_return_empty(), media_type="text/event-stream")
204+
201205
try:
202206
record = get_chat_record_by_id(session, chat_record_id)
203207

backend/common/core/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn | str:
124124
TABLE_EMBEDDING_COUNT: int = 10
125125
DS_EMBEDDING_COUNT: int = 10
126126

127+
# 推荐问题配置(LLM生成)
128+
RECOMMENDED_QUESTIONS_ENABLED: bool = True
129+
127130
ORACLE_CLIENT_PATH: str = '/opt/sqlbot/db_client/oracle_instant_client'
128131

129132
@field_validator('SQL_DEBUG',
@@ -132,6 +135,7 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn | str:
132135
'PARSE_REASONING_BLOCK_ENABLED',
133136
'PG_POOL_PRE_PING',
134137
'TABLE_EMBEDDING_ENABLED',
138+
'RECOMMENDED_QUESTIONS_ENABLED',
135139
mode='before')
136140
@classmethod
137141
def lowercase_bool(cls, v: Any) -> Any:

0 commit comments

Comments
 (0)