@deepnote/blocks 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +23 -0
- package/dist/index.d.cts +1191 -45
- package/dist/index.d.ts +1191 -45
- package/dist/index.js +23 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -76,6 +76,7 @@ const INPUT_BLOCK_TYPES = new Set([
|
|
|
76
76
|
"input-file"
|
|
77
77
|
]);
|
|
78
78
|
const executableBlockTypes = new Set([
|
|
79
|
+
"agent",
|
|
79
80
|
"code",
|
|
80
81
|
"sql",
|
|
81
82
|
"notebook-function",
|
|
@@ -299,6 +300,15 @@ const buttonBlockSchema = z.object({
|
|
|
299
300
|
deepnote_variable_name: z.string().optional()
|
|
300
301
|
}).default({})
|
|
301
302
|
});
|
|
303
|
+
const agentBlockSchema = z.object({
|
|
304
|
+
...executableBlockFields,
|
|
305
|
+
type: z.literal("agent"),
|
|
306
|
+
content: z.string().optional(),
|
|
307
|
+
metadata: executableBlockMetadataSchema.extend({
|
|
308
|
+
deepnote_variable_name: z.string().optional(),
|
|
309
|
+
deepnote_agent_model: z.string().optional()
|
|
310
|
+
}).default({})
|
|
311
|
+
});
|
|
302
312
|
const bigNumberBlockSchema = z.object({
|
|
303
313
|
...executableBlockFields,
|
|
304
314
|
type: z.literal("big-number"),
|
|
@@ -409,6 +419,7 @@ const deepnoteBlockSchema = z.discriminatedUnion("type", [
|
|
|
409
419
|
textCellBulletBlockSchema,
|
|
410
420
|
textCellTodoBlockSchema,
|
|
411
421
|
textCellCalloutBlockSchema,
|
|
422
|
+
agentBlockSchema,
|
|
412
423
|
codeBlockSchema,
|
|
413
424
|
sqlBlockSchema,
|
|
414
425
|
notebookFunctionBlockSchema,
|
|
@@ -743,6 +754,17 @@ function stripMarkdown(block) {
|
|
|
743
754
|
throw new UnsupportedBlockTypeError(`Stripping markdown from block type ${block.type} is not supported yet.`);
|
|
744
755
|
}
|
|
745
756
|
|
|
757
|
+
//#endregion
|
|
758
|
+
//#region src/blocks/agent-blocks.ts
|
|
759
|
+
function createPythonCodeForAgentBlock(block) {
|
|
760
|
+
const prompt = block.content ?? "";
|
|
761
|
+
if (!prompt.trim()) return "# [agent block] (empty system prompt)";
|
|
762
|
+
return `# [agent block] System prompt:\n${prompt.split("\n").map((line) => `# ${line}`).join("\n")}`;
|
|
763
|
+
}
|
|
764
|
+
function isAgentBlock(block) {
|
|
765
|
+
return block.type === "agent";
|
|
766
|
+
}
|
|
767
|
+
|
|
746
768
|
//#endregion
|
|
747
769
|
//#region src/blocks/python-utils.ts
|
|
748
770
|
function escapePythonString(value) {
|
|
@@ -1162,6 +1184,7 @@ function isVisualizationBlock(block) {
|
|
|
1162
1184
|
//#endregion
|
|
1163
1185
|
//#region src/python-code.ts
|
|
1164
1186
|
function createPythonCode(block, executionContext) {
|
|
1187
|
+
if (isAgentBlock(block)) return createPythonCodeForAgentBlock(block);
|
|
1165
1188
|
if (isCodeBlock(block)) return createPythonCodeForCodeBlock(block);
|
|
1166
1189
|
if (isSqlBlock(block)) return createPythonCodeForSqlBlock(block);
|
|
1167
1190
|
if (isInputTextBlock(block)) return createPythonCodeForInputTextBlock(block);
|