File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ def __init__(
8585 self ._tools = {t .name : t for t in tools }
8686 self ._memory = memory
8787 self ._max_steps = max (1 , int (os .getenv ("AGENT_MAX_STEPS" , "5" )))
88- self ._max_latency_ms = max (1000 , int (os .getenv ("AGENT_MAX_LATENCY_MS" , "15000 " )))
88+ self ._max_latency_ms = max (1000 , int (os .getenv ("AGENT_MAX_LATENCY_MS" , "45000 " )))
8989 self ._min_confidence = float (os .getenv ("INTENT_MIN_CONFIDENCE" , "0.6" ))
9090
9191 def _select_tool (self , tool_name : ToolName ) -> Tool :
Original file line number Diff line number Diff line change @@ -1142,3 +1142,20 @@ async def py_admin_ingest(
11421142 status = 400
11431143 return JSONResponse ({"ok" : False , "error" : msg }, status_code = status )
11441144
1145+
1146+ @app .get ("/api/py/chat/suggested-questions" )
1147+ def chat_suggested_questions () -> JSONResponse :
1148+ """返回推荐问法列表,供前端展示(不再本地写死)。"""
1149+ return JSONResponse (
1150+ {
1151+ "ok" : True ,
1152+ "questions" : [
1153+ "《AI 编程可闭环协作》卷三讲什么?Harness 和签收是什么?" ,
1154+ "Tech Graph 是什么" ,
1155+ "冷/温/热 和 架构三层 区别?" ,
1156+ "简单介绍下刘新宁" ,
1157+ "AI Ink Brain 的架构是怎样的" ,
1158+ ],
1159+ }
1160+ )
1161+
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ import importlib
4+
5+ import pytest
6+ from fastapi .testclient import TestClient
7+
8+
9+ def test_chat_suggested_questions_returns_list (monkeypatch : pytest .MonkeyPatch ) -> None :
10+ monkeypatch .setenv ("SYNC_ADMIN_SECRET" , "secret-token-1234567890" )
11+ monkeypatch .setenv ("CHATBI_USE_AGENT" , "false" )
12+
13+ index = importlib .import_module ("api.index" )
14+ importlib .reload (index )
15+
16+ client = TestClient (index .app )
17+ res = client .get ("/api/py/chat/suggested-questions" )
18+
19+ assert res .status_code == 200
20+ data = res .json ()
21+ assert data ["ok" ] is True
22+ questions = data ["questions" ]
23+ assert isinstance (questions , list )
24+ assert len (questions ) >= 1
25+ assert all (isinstance (q , str ) and q .strip () for q in questions )
You can’t perform that action at this time.
0 commit comments