Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/questdb
Submodule questdb updated 297 files
6 changes: 0 additions & 6 deletions src/components/AIStatusIndicator/AssistantModes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,6 @@ export const AssistantModes: React.FC<AssistantModesProps> = ({
{item.name}
</CodeBadgeText>
</CodeBadge>
<ReasoningTextPart>
documentation
</ReasoningTextPart>
</>
) : (
<>
Expand All @@ -426,9 +423,6 @@ export const AssistantModes: React.FC<AssistantModesProps> = ({
{item.name}
</CodeBadgeText>
</CodeBadge>
<ReasoningTextPart>
documentation
</ReasoningTextPart>
</>
)}
</ReasoningText>
Expand Down
18 changes: 14 additions & 4 deletions src/utils/aiAssistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,14 @@ const REFERENCE_TOOLS = [
properties: {
category: {
type: "string" as const,
enum: ["functions", "operators", "sql", "concepts", "schema"],
enum: [
"functions",
"operators",
"sql",
"concepts",
"schema",
"cookbook",
],
description: "The category of documentation to retrieve",
},
items: {
Expand Down Expand Up @@ -434,9 +441,12 @@ export function createModelToolsClient(
}

const DOCS_INSTRUCTION_ANTHROPIC = `
CRITICAL: Always follow this two-phase documentation approach:
1. Use get_questdb_toc to see available functions/keywords/operators
2. Use get_questdb_documentation to get details for specific items you'll use`
CRITICAL: Always follow this documentation approach:
1. Use get_questdb_toc to see available functions, operators, SQL syntax, AND cookbook recipes
2. If user's request matches a cookbook recipe description, fetch it FIRST - recipes provide complete, tested SQL patterns
3. Use get_questdb_documentation for specific function/syntax details

When a cookbook recipe matches the user's intent, ALWAYS use it as the foundation and adapt column/table names and use case to their schema.`

const getUnifiedPrompt = (grantSchemaAccess?: boolean) => {
const base = `You are a SQL expert assistant specializing in QuestDB, a high-performance time-series database. You help users with:
Expand Down
16 changes: 13 additions & 3 deletions src/utils/questdbDocsRetrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export type DocCategory =
| "sql"
| "concepts"
| "schema"
| "cookbook"

export type ParsedDocItem = {
name: string
Expand All @@ -19,15 +20,17 @@ export function parseDocItem(item: string): ParsedDocItem | null {
return null
}

const parts = item.split(/\s+-\s+/)
const itemWithoutDesc = item.split(" :: ")[0].trim()

const parts = itemWithoutDesc.split(/\s+-\s+/)
if (parts.length >= 2) {
return {
name: parts[0].trim(),
section: parts.slice(1).join(" - ").trim(),
}
}

return { name: item.trim() }
return { name: itemWithoutDesc }
}

/**
Expand Down Expand Up @@ -104,7 +107,14 @@ export async function getQuestDBTableOfContents(): Promise<string> {
// Schema
if (toc.schema) {
result += "## Schema\n"
result += toc.schema.join(", ") + "\n"
result += toc.schema.join(", ") + "\n\n"
}

if (toc.cookbook) {
result += "## Cookbook SQL Recipes (Complete Working Examples)\n"
result +=
"These pages provide tested, production-ready SQL. When user's request matches a recipe, use it as the foundation and adapt column/table names and use case to their schema.\n\n"
result += toc.cookbook.join("\n") + "\n"
}

return result
Expand Down