@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.cjs
CHANGED
|
@@ -102,6 +102,7 @@ const INPUT_BLOCK_TYPES = new Set([
|
|
|
102
102
|
"input-file"
|
|
103
103
|
]);
|
|
104
104
|
const executableBlockTypes = new Set([
|
|
105
|
+
"agent",
|
|
105
106
|
"code",
|
|
106
107
|
"sql",
|
|
107
108
|
"notebook-function",
|
|
@@ -325,6 +326,15 @@ const buttonBlockSchema = zod.z.object({
|
|
|
325
326
|
deepnote_variable_name: zod.z.string().optional()
|
|
326
327
|
}).default({})
|
|
327
328
|
});
|
|
329
|
+
const agentBlockSchema = zod.z.object({
|
|
330
|
+
...executableBlockFields,
|
|
331
|
+
type: zod.z.literal("agent"),
|
|
332
|
+
content: zod.z.string().optional(),
|
|
333
|
+
metadata: executableBlockMetadataSchema.extend({
|
|
334
|
+
deepnote_variable_name: zod.z.string().optional(),
|
|
335
|
+
deepnote_agent_model: zod.z.string().optional()
|
|
336
|
+
}).default({})
|
|
337
|
+
});
|
|
328
338
|
const bigNumberBlockSchema = zod.z.object({
|
|
329
339
|
...executableBlockFields,
|
|
330
340
|
type: zod.z.literal("big-number"),
|
|
@@ -435,6 +445,7 @@ const deepnoteBlockSchema = zod.z.discriminatedUnion("type", [
|
|
|
435
445
|
textCellBulletBlockSchema,
|
|
436
446
|
textCellTodoBlockSchema,
|
|
437
447
|
textCellCalloutBlockSchema,
|
|
448
|
+
agentBlockSchema,
|
|
438
449
|
codeBlockSchema,
|
|
439
450
|
sqlBlockSchema,
|
|
440
451
|
notebookFunctionBlockSchema,
|
|
@@ -769,6 +780,17 @@ function stripMarkdown(block) {
|
|
|
769
780
|
throw new UnsupportedBlockTypeError(`Stripping markdown from block type ${block.type} is not supported yet.`);
|
|
770
781
|
}
|
|
771
782
|
|
|
783
|
+
//#endregion
|
|
784
|
+
//#region src/blocks/agent-blocks.ts
|
|
785
|
+
function createPythonCodeForAgentBlock(block) {
|
|
786
|
+
const prompt = block.content ?? "";
|
|
787
|
+
if (!prompt.trim()) return "# [agent block] (empty system prompt)";
|
|
788
|
+
return `# [agent block] System prompt:\n${prompt.split("\n").map((line) => `# ${line}`).join("\n")}`;
|
|
789
|
+
}
|
|
790
|
+
function isAgentBlock(block) {
|
|
791
|
+
return block.type === "agent";
|
|
792
|
+
}
|
|
793
|
+
|
|
772
794
|
//#endregion
|
|
773
795
|
//#region src/blocks/python-utils.ts
|
|
774
796
|
function escapePythonString(value) {
|
|
@@ -1188,6 +1210,7 @@ function isVisualizationBlock(block) {
|
|
|
1188
1210
|
//#endregion
|
|
1189
1211
|
//#region src/python-code.ts
|
|
1190
1212
|
function createPythonCode(block, executionContext) {
|
|
1213
|
+
if (isAgentBlock(block)) return createPythonCodeForAgentBlock(block);
|
|
1191
1214
|
if (isCodeBlock(block)) return createPythonCodeForCodeBlock(block);
|
|
1192
1215
|
if (isSqlBlock(block)) return createPythonCodeForSqlBlock(block);
|
|
1193
1216
|
if (isInputTextBlock(block)) return createPythonCodeForInputTextBlock(block);
|