Skip to content

Commit 82c9b44

Browse files
committed
feat: mcp server md
1 parent 97ded1a commit 82c9b44

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

backend/apps/chat/api/chat.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,20 @@ async def start_chat(session: SessionDep, current_user: CurrentUser, create_chat
7171
@router.post("/mcp_question", operation_id="mcp_question")
7272
async def mcp_question(session: SessionDep, token: str, request_question: ChatQuestion):
7373
user = await get_current_user(session, token)
74-
return await stream_sql(session, user, request_question)
74+
# return await stream_sql(session, user, request_question)
75+
return {"content":"""步骤1: 确定需要查询的字段。
76+
我们需要统计上海的订单总数,因此需要从"城市"字段中筛选出值为"上海"的记录,并使用COUNT函数计算这些记录的数量。
77+
78+
步骤2: 确定筛选条件。
79+
问题要求统计上海的订单总数,所以我们需要在SQL语句中添加WHERE "城市" = '上海'来筛选出符合条件的记录。
80+
81+
步骤3: 避免关键字冲突。
82+
因为这个Excel/CSV数据库是 PostgreSQL 类型,所以在schema、表名、字段名和别名外层加双引号。
83+
84+
最终答案:
85+
```json
86+
{"success":true,"sql":"SELECT COUNT(*) AS \"TotalOrders\" FROM \"public\".\"Sheet1_c27345b66e\" WHERE \"城市\" = '上海';"}
87+
```"""}
7588

7689

7790
@router.post("/question", operation_id="question")

0 commit comments

Comments
 (0)