Skip to content

Commit c7045be

Browse files
committed
Fix AI Q&A to use only dashboard data, add clear button
Backend changes: - Strengthen dashboard Q&A system prompt to explicitly prohibit tool use and require direct answers using only provided data Frontend changes: - Make frontend instruction even more explicit - Add clear button to chat history (appears when messages exist)
1 parent b38d245 commit c7045be

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ProspectorResources.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,9 @@ private List<ChatMessage> buildMessages(LlmConfig config, ChatRequest request) {
478478

479479
if (ctx.dashboardQnAMode) {
480480
systemPrompt.append("\nYou are answering questions about dashboard data. ");
481-
systemPrompt.append("Answer questions concisely based on the available data. ");
482-
systemPrompt.append("Only use execute_sql and get_schema_info tools if needed.\n\n");
481+
systemPrompt.append("IMPORTANT: Do NOT suggest running queries, retrieving data, or using tools. ");
482+
systemPrompt.append("You have all the information needed in the dashboard data below. ");
483+
systemPrompt.append("Answer questions directly and concisely (1-2 sentences) using ONLY the data provided.\n\n");
483484

484485
appendDashboardData(systemPrompt, ctx);
485486
}

exec/java-exec/src/main/resources/webapp/src/components/dashboard/AiQnAPanel.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818
import { useCallback, useEffect, useRef, useState } from 'react';
19-
import { Alert, InputNumber, Spin, Typography } from 'antd';
19+
import { Alert, Button, InputNumber, Spin, Typography } from 'antd';
2020
import Markdown from 'react-markdown';
2121
import rehypeRaw from 'rehype-raw';
2222
import { getAiStatus, streamChat } from '../../api/ai';
@@ -86,7 +86,7 @@ export default function AiQnAPanel({
8686
}).join('\n');
8787

8888
const briefingInstruction = dashboardData.length > 0
89-
? 'Analyze ONLY the dashboard data provided above. Do NOT suggest writing queries or exploring the database. Keep responses concise (1-2 sentences) with direct answers.'
89+
? 'You MUST answer using ONLY the dashboard data above. Do not mention retrieving, querying, or exploring data. You have all information needed. Answer directly in 1-2 sentences.'
9090
: 'Keep responses concise (1-2 sentences). Focus on direct answers.';
9191
const chatMessages: ChatMessage[] = [
9292
...messages,
@@ -184,6 +184,18 @@ export default function AiQnAPanel({
184184

185185
return (
186186
<div style={{ display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden' }}>
187+
{messages.length > 0 && (
188+
<div style={{ padding: '4px 8px', borderBottom: '1px solid var(--color-border, #f0f0f0)', textAlign: 'right' }}>
189+
<Button
190+
size="small"
191+
type="text"
192+
onClick={() => setMessages([])}
193+
style={{ fontSize: 12 }}
194+
>
195+
Clear
196+
</Button>
197+
</div>
198+
)}
187199
<div
188200
ref={scrollRef}
189201
style={{

0 commit comments

Comments
 (0)