(
notebookContext: string,
integrations?: Array<{ id: string; name: string; type: string }>
)
| 107 | } |
| 108 | |
| 109 | export function buildSystemPrompt( |
| 110 | notebookContext: string, |
| 111 | integrations?: Array<{ id: string; name: string; type: string }> |
| 112 | ): string { |
| 113 | let prompt = `You are a data science assistant working inside a Deepnote notebook. You can add code blocks and markdown blocks to the notebook. |
| 114 | |
| 115 | ## Current notebook state |
| 116 | |
| 117 | ${notebookContext} |
| 118 | |
| 119 | ## Instructions |
| 120 | |
| 121 | - Use add_code_block to write and execute Python code. You will see the output. |
| 122 | - Use add_markdown_block to add explanations, section headers, or documentation. |
| 123 | - Analyze data step by step: load, explore, transform, visualize, summarize. |
| 124 | - If a code block errors, read the error and try a different approach. |
| 125 | - When you are done, provide a brief summary of what you did and found. |
| 126 | - Be concise in markdown blocks. Prefer code that shows results over long explanations.` |
| 127 | |
| 128 | if (integrations && integrations.length > 0) { |
| 129 | prompt += ` |
| 130 | |
| 131 | ## Available database integrations |
| 132 | |
| 133 | The following database integrations are configured and available. To query them, |
| 134 | use add_code_block with the deepnote-toolkit SQL helper: |
| 135 | |
| 136 | \`\`\`python |
| 137 | import deepnote_toolkit as dntk |
| 138 | df = dntk.execute_sql("SELECT * FROM users LIMIT 10", "SQL_<INTEGRATION_ID>") |
| 139 | \`\`\` |
| 140 | |
| 141 | Available integrations: |
| 142 | ${integrations.map(i => `- "${i.name}" (${i.type}, id: ${i.id})`).join('\n')}` |
| 143 | } |
| 144 | |
| 145 | return prompt |
| 146 | } |
| 147 | |
| 148 | export async function executeAgentBlock(block: AgentBlock, context: AgentBlockContext): Promise<AgentBlockResult> { |
| 149 | const openai = createOpenAI({ |
no outgoing calls
no test coverage detected