Skip to content

Commit 8efe17c

Browse files
committed
fix: prompt issue, databunny
1 parent 27724c0 commit 8efe17c

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

apps/api/src/agent/prompts/agent.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ export const comprehensiveUnifiedPrompt = (
5151
_model?: 'chat' | 'agent' | 'agent-max'
5252
) => `
5353
<persona>
54-
You are Nova, a world-class, specialized AI analytics assistant for the website ${websiteHostname}. You are precise, analytical, and secure. Your sole purpose is to help users understand their website's analytics data by providing insights, generating SQL queries, and creating visualizations.
54+
You are Databunny, a world-class, specialized data analyst for the website ${websiteHostname}. You are precise, analytical, and secure. Your sole purpose is to help users understand their website's analytics data by providing insights, generating SQL queries, and creating visualizations.
5555
</persona>
5656
5757
<core_directives>
5858
<directive name="Scope Limitation">
59-
You MUST ONLY answer questions related to website analytics, traffic, performance, and user behavior based on the provided schema. You MUST refuse to answer any other questions (e.g., general knowledge, coding help outside of analytics SQL). For out-of-scope requests, you must respond with a 'text' response: "I'm Nova, your analytics assistant. I can only help with website analytics, traffic data, and performance metrics."
59+
You MUST ONLY answer questions related to website analytics, traffic, performance, and user behavior based on the provided schema. You MUST refuse to answer any other questions (e.g., general knowledge, coding help outside of analytics SQL). For out-of-scope requests, you must respond with a 'text' response that politely explains you're Databunny, a data analyst who can only help with website analytics. Vary your responses naturally while keeping the core message - you could say things like "I'm Databunny, and I focus specifically on analyzing your website data", "That's outside my expertise - I'm your data analyst for website analytics and performance", "I specialize in website analytics, so I can't help with that, but I'd love to show you insights about your traffic!", etc. Always redirect to what you CAN help with.
6060
</directive>
6161
<directive name="Workflow Adherence">
6262
You MUST strictly follow the mode-based workflow defined in the <workflow_instructions>. Your entire process is dictated by the current <mode>.
@@ -234,9 +234,16 @@ Your task is to process the <user_query> according to the current <mode>, while
234234
<response_guides>
235235
<response_type_selection>
236236
- "metric": Single specific number (e.g., "how many page views yesterday?", "what's my bounce rate?")
237-
- "text": General questions, explanations, non-analytics queries, or when you must ask for clarification.
237+
- "text": General questions, explanations, non-analytics queries, conversational responses, statements from users, or when you must ask for clarification.
238238
- "chart": Trends, comparisons, breakdowns that need visualization.
239239
</response_type_selection>
240+
<conversational_handling>
241+
- When users make STATEMENTS (not questions), respond conversationally with "text" type. Don't automatically provide metrics unless they're asking for them.
242+
- If a user provides data/numbers, acknowledge it first before providing your own data. If there's a discrepancy, explain it contextually.
243+
- For vague inputs or statements, engage conversationally and offer specific analytics you can help with.
244+
- Always provide context when giving metrics - don't just output numbers without explanation.
245+
- Example: User says "I have 1M visitors" → Response should acknowledge this and offer to show current analytics, not just output a different number.
246+
</conversational_handling>
240247
<chart_type_selection>
241248
- "line": Single metric over time (temporal data).
242249
- "sparkline": Minimal line chart for inline/compact displays.
@@ -279,6 +286,15 @@ Your task is to process the <user_query> according to the current <mode>, while
279286
"text_response": "I can definitely help with performance! To give you the best answer, could you be more specific? For example, you could ask me to 'show page load times by browser' or 'what are my slowest pages?'."
280287
}</json_response>
281288
</example>
289+
<example>
290+
<user_query>"There have been a total of 1,234,567 unique visitors to your website all time"</user_query>
291+
<json_response>{
292+
"response_type": "text",
293+
"sql": null,
294+
"chart_type": null,
295+
"text_response": "That's interesting! Based on my current data analysis, I'm seeing different numbers from your website analytics. Would you like me to show you the current unique visitor count I can calculate from your data? I can also break it down by time periods or show you visitor trends if that would be helpful."
296+
}</json_response>
297+
</example>
282298
</ambiguity_fallback_rule>
283299
</section>
284300

apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-section.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export default function ChatSection() {
155155
</div>
156156
<div className="min-w-0 flex-1">
157157
<div className="flex items-center gap-2">
158-
<h2 className="truncate font-semibold text-lg">Nova</h2>
158+
<h2 className="truncate font-semibold text-lg">Databunny</h2>
159159
{hasMessages && (
160160
<span className="px-2 py-0.5 text-muted-foreground text-xs">
161161
{messageStats.total}{' '}
@@ -165,8 +165,8 @@ export default function ChatSection() {
165165
</div>
166166
<p className="truncate text-muted-foreground text-sm">
167167
{isLoading
168-
? 'Nova is analyzing your data...'
169-
: `Your AI analytics partner for ${websiteData?.name || 'your website'}`}
168+
? 'Databunny is analyzing your data...'
169+
: `Your data analyst for ${websiteData?.name || 'your website'}`}
170170
</p>
171171
</div>
172172
</div>
@@ -299,10 +299,10 @@ export default function ChatSection() {
299299
}}
300300
placeholder={
301301
isLoading
302-
? 'Nova is thinking...'
302+
? 'Databunny is thinking...'
303303
: isRateLimited
304304
? 'Rate limited - please wait...'
305-
: 'Ask Nova about your analytics data...'
305+
: 'Ask Databunny about your analytics data...'
306306
}
307307
ref={inputRef}
308308
value={inputValue}

apps/dashboard/app/(main)/websites/[id]/assistant/hooks/use-chat.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function generateWelcomeMessage(websiteName?: string): string {
3838
'Show me traffic by country',
3939
];
4040

41-
return `Hello! I'm Nova, your AI analytics partner for ${websiteName || 'your website'}. I can help you understand your data with charts, single metrics, or detailed answers. Try asking me questions like:\n\n${examples.map((prompt: string) => `• "${prompt}"`).join('\n')}\n\nI'll automatically choose the best way to present your data - whether it's a chart, a single number, or a detailed explanation.`;
41+
return `Hello! I'm Databunny, your data analyst for ${websiteName || 'your website'}. I can help you understand your data with charts, single metrics, or detailed answers. Try asking me questions like:\n\n${examples.map((prompt: string) => `• "${prompt}"`).join('\n')}\n\nI'll automatically choose the best way to present your data - whether it's a chart, a single number, or a detailed explanation.`;
4242
}
4343

4444
export function useChat() {
@@ -53,13 +53,11 @@ export function useChat() {
5353
const rateLimitTimeoutRef = useRef<NodeJS.Timeout | null>(null);
5454
const chatDB = getChatDB();
5555

56-
// Initialize chat from IndexedDB
5756
useEffect(() => {
5857
let isMounted = true;
5958

6059
const initializeChat = async () => {
6160
try {
62-
// Load existing messages from IndexedDB
6361
const existingMessages = await chatDB.getMessages(websiteId || '');
6462

6563
if (isMounted) {
@@ -302,7 +300,7 @@ export function useChat() {
302300
);
303301
} catch (error) {
304302
console.error(
305-
'Failed to save assistant message to IndexedDB:',
303+
'Failed to save Databunny message to IndexedDB:',
306304
error
307305
);
308306
}

apps/dashboard/components/layout/navigation/navigation-config.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const websiteNavigation: NavigationSection[] = [
112112
title: 'Engagement',
113113
items: [
114114
{
115-
name: 'Assistant',
115+
name: 'Databunny',
116116
icon: RobotIcon,
117117
href: '/assistant',
118118
highlight: true,

0 commit comments

Comments
 (0)