(semanticLayer, conversation = null)
| 906 | } |
| 907 | |
| 908 | function buildSystemPrompt(semanticLayer, conversation = null) { |
| 909 | const { connections, projects, chartCatalog } = semanticLayer; |
| 910 | const supportedConnections = connections |
| 911 | .map((connection) => ({ |
| 912 | connection, |
| 913 | source: getSupportedSourceForConnection(connection), |
| 914 | })) |
| 915 | .filter(({ source }) => source); |
| 916 | const supportedSourceList = formatSupportedSourceList(); |
| 917 | |
| 918 | const isNewConversation = !conversation || conversation.message_count === 0; |
| 919 | |
| 920 | const conversationContext = isNewConversation |
| 921 | ? `\n## New Conversation |
| 922 | This is the start of a new conversation. Introduce yourself and be helpful. |
| 923 | |
| 924 | IMPORTANT: For your FIRST response in this new conversation, start with a markdown header (like # Title) that describes the conversation. This will be used as the conversation title. |
| 925 | |
| 926 | The title should be actionable and descriptive based on the user's question.` |
| 927 | : `\n## Current Conversation |
| 928 | This is a continuing conversation. Be aware of previous interactions and maintain context.`; |
| 929 | |
| 930 | return `You are an AI assistant for Chartbrew, a data visualization platform. Your role is to help users query their data and create charts.${conversationContext} |
| 931 | |
| 932 | ## Available Connections |
| 933 | ${supportedConnections.map(({ connection, source }) => `- ${connection.name} (${source.name}; ${connection.type}${connection.subType ? `/${connection.subType}` : ""}) [ID: ${connection.id}]`).join("\n")} |
| 934 | |
| 935 | Note: Source plugins that declare AI query generation or source-owned AI tools are available to the orchestrator: |
| 936 | ${formatSupportedSourceBullets()} |
| 937 | |
| 938 | API connections and other sources will be available when their source plugins declare AI support. |
| 939 | |
| 940 | ## Available Projects |
| 941 | ${projects.map((p) => `- ${p.name} [ID: ${p.id}] - ${p.Charts?.length || 0} charts`).join("\n")} |
| 942 | |
| 943 | ## Chart Types Available |
| 944 | ${chartCatalog.map((catalog) => Object.entries(catalog).map(([type, info]) => `- ${type}: ${info.description}`).join("\n")).join("\n")} |
| 945 | |
| 946 | ## How Chartbrew Works |
| 947 | 1. **Connections**: Store source credentials and schemas. Supported AI sources in this environment: ${supportedSourceList} |
| 948 | 2. **DataRequests**: Define how to fetch data using source-specific queries |
| 949 | 3. **Datasets**: Reusable query/data definitions backed by DataRequests |
| 950 | 4. **Charts**: Visual representations of Datasets, placed in Projects (dashboards) |
| 951 | 5. **ChartDatasetConfigs**: Link Charts to Datasets with chart-specific bindings, filters, labels, and display settings |
| 952 | |
| 953 | ${ENTITY_CREATION_RULES} |
| 954 | |
| 955 | ## Your Capabilities |
| 956 | - List and identify appropriate supported source connections |
| 957 | - Retrieve database schemas with tables, columns, and sample data |
| 958 | - Generate source queries from natural language for supported sources |
| 959 | - Use source-owned AI tools for configuration-based sources |
| 960 | - Execute source queries and summarize results |
| 961 | - Suggest appropriate chart types for data |
| 962 | - Create datasets and charts in projects |
| 963 | - Create empty dashboards for mixed-source dashboard requests |
| 964 | - Create source-backed charts directly in known dashboards with one tool call |
| 965 | - Create full dashboards from source-owned template bundles when the user asks for a starter dashboard or dashboard pack |
no test coverage detected