Commit a0fb3e75 by sunqi02 Committed by 胡悦

chore: simplify send_test.sh and add DB agent load logging

- send_test.sh: no-arg mode sends test_request.json, with-arg mode sends single text message
- main.py: replace diagnostic prints with structured logger.info
- Fix agent_id 14 → 17 (meeting agent) in send_test.sh
1 parent 65cab8d8
......@@ -6,6 +6,8 @@ from fastapi import FastAPI, HTTPException, Request
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse, Response
logger = logging.getLogger(__name__)
from app.api.v1.router import api_router
from app.config.loader import ConfigLoader
from app.infrastructure.database import engine, SessionLocal
......@@ -66,6 +68,11 @@ async def lifespan(app: FastAPI):
# 从数据库加载 Agent 配置
agents = config_loader.load_agents_from_db(db)
logger.info(
"Agent 配置已从 DB 加载: %d 个, steward=%s",
len(agents),
next((k for k, v in agents.items() if v.is_steward), None),
)
session_service = ActiveSessionService(db=db)
......
......@@ -42,37 +42,40 @@ if [ -z "$1" ]; then
echo "=========================================="
else
# ── 有参数:读取 test_request.json 的 group+agents,替换 messages 为单条文本 ──
# ── 有参数:发送单条文本消息 ──
QUERY="$1"
GROUP_ID="${2:-EFD61E74ABE87CE0CE0C8D3529ED8B9E5194F219CF554649F1C4F9C615435A82}"
MSG_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
JSON_FILE="${SCRIPT_DIR}/test_request.json"
if [ ! -f "$JSON_FILE" ]; then
echo "错误: 找不到 ${JSON_FILE}"
exit 1
fi
echo "=========================================="
echo " 发送单条测试消息"
echo "=========================================="
echo ""
echo "提问: ${QUERY}"
echo "群组: ${GROUP_ID}"
echo ""
PAYLOAD=$(python3 -c "
import json, sys
with open('${JSON_FILE}') as f:
base = json.load(f)
base['messages'] = [{
'msg_id': 'm1',
'msg_time': '${MSG_TIME}',
'sender_id': 'user_001',
'sender_name': '测试用户',
'msg_type': 'text',
'msg_content': sys.argv[1],
'payload': {}
}]
print(json.dumps(base, ensure_ascii=False, indent=2))
print(json.dumps({
'group': {
'group_contact_id': '${GROUP_ID}',
'group_name': '测试群'
},
'agents': [
{'agent_id': 11, 'bot_id': 'ABE6E30E3476E955853410C13E38C1065194F219CF554649F1C4F9C615435A82', 'is_steward': True},
{'agent_id': 17, 'bot_id': 'd53d00b08f8b4e22844ecfd0bb12e343', 'is_steward': False}
],
'messages': [{
'msg_id': 'm1',
'msg_time': '${MSG_TIME}',
'sender_id': 'user_001',
'sender_name': '测试用户',
'msg_type': 'text',
'msg_content': sys.argv[1],
'payload': {}
}]
}, ensure_ascii=False, indent=2))
" "$QUERY")
echo "--- 请求体 ---"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!