From 7c9abcadfece3d85e6c9cec836f5c005769fb584 Mon Sep 17 00:00:00 2001 From: qixinbo Date: Thu, 19 Mar 2026 17:40:08 +0800 Subject: [PATCH] fix: skill injected into system prompt --- backend/main.py | 10 ++++++++++ frontend/src/components/ChatInterface.tsx | 2 +- frontend/src/pages/Skills.tsx | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/main.py b/backend/main.py index b7ec825..8d91ae4 100644 --- a/backend/main.py +++ b/backend/main.py @@ -135,6 +135,11 @@ async def nanobot_chat(request: ChatRequest): elif request.route_mode == "chat": message = f"[System: Normal chat mode. Do NOT use the nl2sql tool]\n{message}" + # Inject instructions for selected skills + if request.skill_ids: + skill_list = ", ".join(request.skill_ids) + message = f"[System: You must prioritize using the following skills/tools to answer the user's request: {skill_list}]\n{message}" + response = await nanobot_service.process_message( message, session_id=request.session_id, @@ -186,6 +191,11 @@ async def nanobot_chat_stream(request: ChatRequest): elif request.route_mode == "chat": message = f"[System: Normal chat mode. Do NOT use the nl2sql tool]\n{message}" + # Inject instructions for selected skills + if request.skill_ids: + skill_list = ", ".join(request.skill_ids) + message = f"[System: You must prioritize using the following skills/tools to answer the user's request: {skill_list}]\n{message}" + current_task = asyncio.create_task( nanobot_service.process_message( message, diff --git a/frontend/src/components/ChatInterface.tsx b/frontend/src/components/ChatInterface.tsx index 56ea557..f80b669 100644 --- a/frontend/src/components/ChatInterface.tsx +++ b/frontend/src/components/ChatInterface.tsx @@ -264,7 +264,7 @@ export function ChatInterface() { const formattedMessages = data.messages .filter((m) => { if (m.role === 'system' || m.role === 'tool' || m.role === 'function') return false; - if (m.role === 'assistant' && m.tool_calls && m.tool_calls.length > 0 && !m.viz) return false; + if (m.role === 'assistant' && m.tool_calls && m.tool_calls.length > 0 && !m.viz && (!m.content || m.content.trim() === '')) return false; return true; }) .map((m, idx) => ({ diff --git a/frontend/src/pages/Skills.tsx b/frontend/src/pages/Skills.tsx index 8a7e0f4..82c3fff 100644 --- a/frontend/src/pages/Skills.tsx +++ b/frontend/src/pages/Skills.tsx @@ -227,7 +227,7 @@ export function Skills() { -
+