@marimo-team/frontend 0.15.1-dev34 → 0.15.1-dev35
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/assets/{ConnectedDataExplorerComponent-BcJwEN2q.js → ConnectedDataExplorerComponent-BYxPTiA6.js} +1 -1
- package/dist/assets/{ImageComparisonComponent-CnwGwcTi.js → ImageComparisonComponent-DBpvpxlw.js} +1 -1
- package/dist/assets/{VegaLite-Cnk7Ozer.js → VegaLite-DzkGo9LJ.js} +1 -1
- package/dist/assets/{_baseEach-DJPM6ZzY.js → _baseEach-CnK_W3-W.js} +1 -1
- package/dist/assets/_baseMap-CIc0IDdl.js +1 -0
- package/dist/assets/{_baseUniq-CrXjB6JP.js → _baseUniq-DsEUejTO.js} +1 -1
- package/dist/assets/{_createAggregator-Cd0noqMc.js → _createAggregator-xSD3e6yX.js} +1 -1
- package/dist/assets/{any-language-editor-ZfVYrHPH.js → any-language-editor-CSLfx3Fo.js} +1 -1
- package/dist/assets/{architectureDiagram-KFL7JDKH-DuJCaD_M.js → architectureDiagram-KFL7JDKH-DDJcEe4E.js} +1 -1
- package/dist/assets/{blockDiagram-ZYB65J3Q-B0f3bVJ0.js → blockDiagram-ZYB65J3Q-DrajNxU6.js} +1 -1
- package/dist/assets/{c4Diagram-AAMF2YG6-3srX8_ui.js → c4Diagram-AAMF2YG6-DkbBAlkB.js} +1 -1
- package/dist/assets/channel-D2aPrBH4.js +1 -0
- package/dist/assets/{chunk-ANTBXLJU-CD8Ya77t.js → chunk-ANTBXLJU-CyFpCIAD.js} +1 -1
- package/dist/assets/{chunk-FHKO5MBM-34L0hhh_.js → chunk-FHKO5MBM-DaRG9EJ9.js} +1 -1
- package/dist/assets/{chunk-GLLZNHP4-CRWkmhQj.js → chunk-GLLZNHP4-C852Uilf.js} +1 -1
- package/dist/assets/{chunk-JBRWN2VN-CB8a_SQv.js → chunk-JBRWN2VN-DF6c2w7p.js} +1 -1
- package/dist/assets/{chunk-LXBSTHXV-YNRk01ob.js → chunk-LXBSTHXV-DJc1jClD.js} +1 -1
- package/dist/assets/{chunk-NRVI72HA-nFtyi9pH.js → chunk-NRVI72HA-BYzJjL14.js} +1 -1
- package/dist/assets/{chunk-OMD6QJNC-BXZ4Kapq.js → chunk-OMD6QJNC-DpzW6M54.js} +1 -1
- package/dist/assets/{chunk-WVR4S24B-ZnYlHppS.js → chunk-WVR4S24B-Ds_Fnulu.js} +1 -1
- package/dist/assets/{circle-play-k88jloBa.js → circle-play-ILK7D0lo.js} +1 -1
- package/dist/assets/classDiagram-3BZAVTQC-DAUNRz1h.js +1 -0
- package/dist/assets/classDiagram-v2-QTMF73CY-DAUNRz1h.js +1 -0
- package/dist/assets/clone-CYXehyk_.js +1 -0
- package/dist/assets/{compile-CDMtSySK.js → compile-Q6b1NW0Y.js} +1 -1
- package/dist/assets/{dagre-2BBEFEWP-Bfm20vyd.js → dagre-2BBEFEWP-DUplj_Iy.js} +1 -1
- package/dist/assets/{data-grid-overlay-editor-CwEfDFcK.js → data-grid-overlay-editor-BHVNUwJL.js} +1 -1
- package/dist/assets/{diagram-4IRLE6MV-A9psNOWP.js → diagram-4IRLE6MV-CqSPK4-w.js} +1 -1
- package/dist/assets/{diagram-GUPCWM2R-B23WLgai.js → diagram-GUPCWM2R-Yz9pe62o.js} +1 -1
- package/dist/assets/{diagram-RP2FKANI-CU5qL55k.js → diagram-RP2FKANI-DAvv4Av_.js} +1 -1
- package/dist/assets/{edit-page-DYm-s1ff.js → edit-page-hlKtRc6p.js} +4 -4
- package/dist/assets/{erDiagram-HZWUO2LU-D31RvIVf.js → erDiagram-HZWUO2LU-BIlDOHrw.js} +1 -1
- package/dist/assets/{flowDiagram-THRYKUMA-ClYGAL8Y.js → flowDiagram-THRYKUMA-w6HYIjcR.js} +1 -1
- package/dist/assets/{ganttDiagram-WV7ZQ7D5-Cmed9KL9.js → ganttDiagram-WV7ZQ7D5-CS1t__7-.js} +1 -1
- package/dist/assets/{gitGraphDiagram-OJR772UL-CWvdnGVc.js → gitGraphDiagram-OJR772UL-DCcukZnI.js} +1 -1
- package/dist/assets/{glide-data-editor-CFVz2aZ5.js → glide-data-editor-BoQ4MEIu.js} +4 -4
- package/dist/assets/{graph-OxTx0_rA.js → graph-DzywueYf.js} +1 -1
- package/dist/assets/{home-page-Dt3nnRSz.js → home-page-CTLf7o0o.js} +1 -1
- package/dist/assets/{index-D4HfKv3U.js → index-B8egTd_Y.js} +1 -1
- package/dist/assets/{index-DjT-1R5N.js → index-BNpIaqHq.js} +1 -1
- package/dist/assets/{index-BM1NAxco.js → index-BNuSEPHf.js} +1 -1
- package/dist/assets/{index-BOFl7de8.js → index-BOaSI40H.js} +1 -1
- package/dist/assets/{index-DLO62gfd.js → index-BVdia1-T.js} +1 -1
- package/dist/assets/{index-Baw8vWOg.js → index-BbrvgVGd.js} +1 -1
- package/dist/assets/{index-KCIhgRrL.js → index-BobSdMcV.js} +1 -1
- package/dist/assets/{index-BLXqwIOX.js → index-BsZupkBE.js} +1 -1
- package/dist/assets/{index-C0Q8e5FM.js → index-CTTXrsVd.js} +1 -1
- package/dist/assets/{index-Bd2C9zUZ.js → index-C_ZOWmXX.js} +1 -1
- package/dist/assets/{index-WltWzc1Z.js → index-CjvmeMRd.js} +1 -1
- package/dist/assets/{index-quG0To4_.js → index-DMgZFfTJ.js} +1 -1
- package/dist/assets/{index-CQFSXxPp.js → index-DMvScaq6.js} +133 -133
- package/dist/assets/{index-DsWckHTg.js → index-DNjb9MyH.js} +1 -1
- package/dist/assets/{index-DETsDEp1.js → index-DUumP-lt.js} +1 -1
- package/dist/assets/{index-4GKIL9qL.js → index-Dl6_NSX4.js} +1 -1
- package/dist/assets/{index-B-P7QUhF.js → index-DsMyERcC.js} +1 -1
- package/dist/assets/{index-DHlxJ27b.js → index-EaCZDGUn.js} +1 -1
- package/dist/assets/{index-BUwTI3go.js → index-gZP0fYKG.js} +1 -1
- package/dist/assets/{index-Bu3XvTHk.js → index-txir7kB2.js} +1 -1
- package/dist/assets/infoDiagram-6WOFNB3A-B1zwcYam.js +2 -0
- package/dist/assets/{journeyDiagram-FFXJYRFH-BLEcUGJo.js → journeyDiagram-FFXJYRFH-IwybgEnB.js} +1 -1
- package/dist/assets/{kanban-definition-KOZQBZVT-RanT6u8e.js → kanban-definition-KOZQBZVT-BnLxznwF.js} +1 -1
- package/dist/assets/{layout-D4n_CEl8.js → layout-lIKJEEeS.js} +1 -1
- package/dist/assets/{linear-BbPKk0w3.js → linear-DzfVWjvh.js} +1 -1
- package/dist/assets/{links-B7_BzQLv.js → links-yIZ6advT.js} +1 -1
- package/dist/assets/{mermaid-CUkYs7pX.js → mermaid-CEpdDmik.js} +4 -4
- package/dist/assets/{min-Yuyj_o4k.js → min-CH9RTxJs.js} +1 -1
- package/dist/assets/{mindmap-definition-LNHGMQRG-x4MjCJ_j.js → mindmap-definition-LNHGMQRG-BGOBqdZQ.js} +1 -1
- package/dist/assets/{number-overlay-editor-DeKR_mfB.js → number-overlay-editor-Bp8EEFG4.js} +1 -1
- package/dist/assets/{pieDiagram-DBDJKBY4-ZOMhJp-a.js → pieDiagram-DBDJKBY4-BH18DMec.js} +1 -1
- package/dist/assets/{quadrantDiagram-YPSRARAO-vZeyiYxN.js → quadrantDiagram-YPSRARAO-DyEaA3Tj.js} +1 -1
- package/dist/assets/{react-plotly-BV6-1ruP.js → react-plotly-BWJyJ31U.js} +1 -1
- package/dist/assets/{requirementDiagram-EGVEC5DT-DkgbH0oi.js → requirementDiagram-EGVEC5DT-BIDYwWds.js} +1 -1
- package/dist/assets/{run-page-0slxHZwl.js → run-page-CFGHZjjp.js} +1 -1
- package/dist/assets/{sankeyDiagram-HRAUVNP4-BuFPw2i8.js → sankeyDiagram-HRAUVNP4-CI7WE82z.js} +1 -1
- package/dist/assets/{sequenceDiagram-WFGC7UMF-BKGIaix6.js → sequenceDiagram-WFGC7UMF-CAt5_R3a.js} +1 -1
- package/dist/assets/{slides-component-DYhLRND3.js → slides-component-BE3m7wod.js} +1 -1
- package/dist/assets/{sortBy-C_bWmRoh.js → sortBy-D8wYLA9x.js} +1 -1
- package/dist/assets/{stateDiagram-UUKSUZ4H-Cm2zkw0M.js → stateDiagram-UUKSUZ4H-B9ghWYn7.js} +1 -1
- package/dist/assets/stateDiagram-v2-EYPG3UTE-DtL7XYtB.js +1 -0
- package/dist/assets/{storage-Dk-ciwQU.js → storage-BseyfFaj.js} +3 -3
- package/dist/assets/{terminal-DrDWxiEU.js → terminal-R2SnqHO_.js} +1 -1
- package/dist/assets/{time-DW3BCgky.js → time-CftJc27E.js} +1 -1
- package/dist/assets/{timeline-definition-3HZDQTIS-B_ZdpuLp.js → timeline-definition-3HZDQTIS-B8ej5Uev.js} +1 -1
- package/dist/assets/{tracing-BuGDnWcg.js → tracing-OU6KdAjg.js} +2 -2
- package/dist/assets/{trash-BKmRbRfw.js → trash-BX0buH-6.js} +1 -1
- package/dist/assets/{treemap-75Q7IDZK-BBbbCdps.js → treemap-75Q7IDZK-C6t8vi8s.js} +1 -1
- package/dist/assets/{vega-component-DogOWa6S.js → vega-component-a-Wve7v1.js} +1 -1
- package/dist/assets/{xychartDiagram-FDP5SA34-3B1j_9pq.js → xychartDiagram-FDP5SA34-DmTMju1m.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/__mocks__/notebook.ts +108 -0
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +119 -139
- package/src/components/editor/ai/completion-utils.ts +7 -33
- package/src/core/ai/context/__tests__/registry.test.ts +154 -0
- package/src/core/ai/context/__tests__/utils.test.ts +174 -0
- package/src/core/ai/context/context.ts +3 -1
- package/src/core/ai/context/providers/__tests__/__snapshots__/error.test.ts.snap +3 -0
- package/src/core/ai/context/providers/__tests__/__snapshots__/tables.test.ts.snap +8 -12
- package/src/core/ai/context/providers/__tests__/__snapshots__/variable.test.ts.snap +4 -20
- package/src/core/ai/context/providers/__tests__/error.test.ts +328 -0
- package/src/core/ai/context/providers/common.ts +1 -0
- package/src/core/ai/context/providers/error.ts +165 -0
- package/src/core/ai/context/providers/tables.ts +14 -6
- package/src/core/ai/context/providers/variable.ts +11 -2
- package/src/core/ai/context/utils.ts +49 -0
- package/src/core/cells/cells.ts +1 -1
- package/dist/assets/_baseMap-u5TY8JMW.js +0 -1
- package/dist/assets/channel-BIZI32eZ.js +0 -1
- package/dist/assets/classDiagram-3BZAVTQC-DfPpF-gd.js +0 -1
- package/dist/assets/classDiagram-v2-QTMF73CY-DfPpF-gd.js +0 -1
- package/dist/assets/clone-yHYNh3QG.js +0 -1
- package/dist/assets/infoDiagram-6WOFNB3A-BQOY1VMN.js +0 -2
- package/dist/assets/stateDiagram-v2-EYPG3UTE-DX5NRIHK.js +0 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import type { Completion } from "@codemirror/autocomplete";
|
|
4
|
+
import { cellErrorsAtom } from "@/core/cells/cells";
|
|
5
|
+
import type { CellId } from "@/core/cells/ids";
|
|
6
|
+
import type { MarimoError } from "@/core/kernel/messages";
|
|
7
|
+
import type { JotaiStore } from "@/core/state/jotai";
|
|
8
|
+
import { PluralWord } from "@/utils/pluralize";
|
|
9
|
+
import { type AIContextItem, AIContextProvider } from "../registry";
|
|
10
|
+
import { contextToXml } from "../utils";
|
|
11
|
+
import { Boosts } from "./common";
|
|
12
|
+
|
|
13
|
+
export interface ErrorContextItem extends AIContextItem {
|
|
14
|
+
type: "error";
|
|
15
|
+
data: {
|
|
16
|
+
type: "all-errors";
|
|
17
|
+
errors: Array<{
|
|
18
|
+
cellId: CellId;
|
|
19
|
+
cellName: string;
|
|
20
|
+
errorData: MarimoError[];
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function describeError(error: MarimoError): string {
|
|
26
|
+
if (error.type === "setup-refs") {
|
|
27
|
+
return "The setup cell cannot have references";
|
|
28
|
+
}
|
|
29
|
+
if (error.type === "cycle") {
|
|
30
|
+
return "This cell is in a cycle";
|
|
31
|
+
}
|
|
32
|
+
if (error.type === "multiple-defs") {
|
|
33
|
+
return `The variable '${error.name}' was defined by another cell`;
|
|
34
|
+
}
|
|
35
|
+
if (error.type === "import-star") {
|
|
36
|
+
return error.msg;
|
|
37
|
+
}
|
|
38
|
+
if (error.type === "ancestor-stopped") {
|
|
39
|
+
return error.msg;
|
|
40
|
+
}
|
|
41
|
+
if (error.type === "ancestor-prevented") {
|
|
42
|
+
return error.msg;
|
|
43
|
+
}
|
|
44
|
+
if (error.type === "exception") {
|
|
45
|
+
return error.msg;
|
|
46
|
+
}
|
|
47
|
+
if (error.type === "strict-exception") {
|
|
48
|
+
return error.msg;
|
|
49
|
+
}
|
|
50
|
+
if (error.type === "interruption") {
|
|
51
|
+
return "This cell was interrupted and needs to be re-run";
|
|
52
|
+
}
|
|
53
|
+
if (error.type === "syntax") {
|
|
54
|
+
return error.msg;
|
|
55
|
+
}
|
|
56
|
+
if (error.type === "unknown") {
|
|
57
|
+
return error.msg;
|
|
58
|
+
}
|
|
59
|
+
return "Unknown error";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const errorsTxt = new PluralWord("error", "errors");
|
|
63
|
+
export class ErrorContextProvider extends AIContextProvider<ErrorContextItem> {
|
|
64
|
+
readonly title = "Errors";
|
|
65
|
+
readonly mentionPrefix = "@";
|
|
66
|
+
readonly contextType = "error";
|
|
67
|
+
|
|
68
|
+
constructor(private store: JotaiStore) {
|
|
69
|
+
super();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getItems(): ErrorContextItem[] {
|
|
73
|
+
const errors = this.store.get(cellErrorsAtom);
|
|
74
|
+
if (errors.length === 0) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return [
|
|
79
|
+
{
|
|
80
|
+
uri: this.asURI("all"),
|
|
81
|
+
name: "Errors",
|
|
82
|
+
type: this.contextType,
|
|
83
|
+
data: {
|
|
84
|
+
type: "all-errors",
|
|
85
|
+
errors: errors.map((error) => ({
|
|
86
|
+
cellId: error.cellId,
|
|
87
|
+
cellName: error.cellName,
|
|
88
|
+
errorData: error.output.data,
|
|
89
|
+
})),
|
|
90
|
+
},
|
|
91
|
+
description: "All errors in the notebook",
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
// TODO: maybe handle single errors or grouped by types
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
formatCompletion(item: ErrorContextItem): Completion {
|
|
99
|
+
if (item.data.type === "all-errors") {
|
|
100
|
+
return {
|
|
101
|
+
label: "@Errors",
|
|
102
|
+
displayLabel: "Errors",
|
|
103
|
+
detail: `${item.data.errors.length} ${errorsTxt.pluralize(item.data.errors.length)}`,
|
|
104
|
+
boost: Boosts.ERROR,
|
|
105
|
+
type: "error",
|
|
106
|
+
apply: "@Errors",
|
|
107
|
+
section: "Errors",
|
|
108
|
+
info: () => {
|
|
109
|
+
const infoContainer = document.createElement("div");
|
|
110
|
+
infoContainer.classList.add(
|
|
111
|
+
"mo-cm-tooltip",
|
|
112
|
+
"docs-documentation",
|
|
113
|
+
"min-w-[200px]",
|
|
114
|
+
"flex",
|
|
115
|
+
"flex-col",
|
|
116
|
+
"gap-1",
|
|
117
|
+
"p-2",
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const headerDiv = document.createElement("div");
|
|
121
|
+
headerDiv.classList.add("flex", "flex-col", "gap-1");
|
|
122
|
+
|
|
123
|
+
const nameDiv = document.createElement("div");
|
|
124
|
+
nameDiv.classList.add("font-bold", "text-base");
|
|
125
|
+
nameDiv.textContent = "Errors";
|
|
126
|
+
headerDiv.append(nameDiv);
|
|
127
|
+
|
|
128
|
+
const descriptionDiv = document.createElement("div");
|
|
129
|
+
descriptionDiv.classList.add("text-sm", "text-muted-foreground");
|
|
130
|
+
descriptionDiv.textContent = `${item.data.errors.length} ${errorsTxt.pluralize(item.data.errors.length)}`;
|
|
131
|
+
headerDiv.append(descriptionDiv);
|
|
132
|
+
|
|
133
|
+
infoContainer.append(headerDiv);
|
|
134
|
+
|
|
135
|
+
return infoContainer;
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
label: "Error",
|
|
142
|
+
displayLabel: "Error",
|
|
143
|
+
boost: Boosts.ERROR,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
formatContext(item: ErrorContextItem): string {
|
|
148
|
+
const { data } = item;
|
|
149
|
+
|
|
150
|
+
const xmls = data.errors.map((err) => {
|
|
151
|
+
return contextToXml({
|
|
152
|
+
type: this.contextType,
|
|
153
|
+
data: {
|
|
154
|
+
name: err.cellName || `Cell ${err.cellId}`,
|
|
155
|
+
description: err.errorData
|
|
156
|
+
.map((err) => describeError(err))
|
|
157
|
+
.join("\n"),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const xml = xmls.join("\n\n");
|
|
163
|
+
return xml;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -5,6 +5,7 @@ import type { DatasetTablesMap } from "@/core/datasets/data-source-connections";
|
|
|
5
5
|
import type { DataTable } from "@/core/kernel/messages";
|
|
6
6
|
import type { AIContextItem } from "../registry";
|
|
7
7
|
import { AIContextProvider } from "../registry";
|
|
8
|
+
import { contextToXml } from "../utils";
|
|
8
9
|
import { Boosts } from "./common";
|
|
9
10
|
|
|
10
11
|
export interface TableContextItem extends AIContextItem {
|
|
@@ -32,8 +33,8 @@ export class TableContextProvider extends AIContextProvider<TableContextItem> {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
formatContext(item: TableContextItem): string {
|
|
35
|
-
const { data
|
|
36
|
-
const { columns, source, num_rows, num_columns } = data;
|
|
36
|
+
const { data } = item;
|
|
37
|
+
const { columns, source, num_rows, num_columns, name } = data;
|
|
37
38
|
const shape = [
|
|
38
39
|
num_rows == null ? undefined : `${num_rows} rows`,
|
|
39
40
|
num_columns == null ? undefined : `${num_columns} columns`,
|
|
@@ -41,16 +42,23 @@ export class TableContextProvider extends AIContextProvider<TableContextItem> {
|
|
|
41
42
|
.filter(Boolean)
|
|
42
43
|
.join(", ");
|
|
43
44
|
|
|
44
|
-
let
|
|
45
|
+
let details = "";
|
|
45
46
|
if (shape) {
|
|
46
|
-
|
|
47
|
+
details += `\nShape: ${shape}`;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
if (columns && columns.length > 0) {
|
|
50
|
-
|
|
51
|
+
details += `\nColumns:\n${columns.map((col) => ` - ${col.name}: ${col.type}`).join("\n")}`;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
return
|
|
54
|
+
return contextToXml({
|
|
55
|
+
type: this.contextType,
|
|
56
|
+
data: {
|
|
57
|
+
name: name,
|
|
58
|
+
source: source ?? "unknown",
|
|
59
|
+
},
|
|
60
|
+
details: details,
|
|
61
|
+
});
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
formatCompletion(item: TableContextItem): Completion {
|
|
@@ -5,6 +5,7 @@ import { createVariableInfoElement } from "@/core/codemirror/completion/variable
|
|
|
5
5
|
import type { DatasetTablesMap } from "@/core/datasets/data-source-connections";
|
|
6
6
|
import type { Variable, Variables } from "@/core/variables/types";
|
|
7
7
|
import { type AIContextItem, AIContextProvider } from "../registry";
|
|
8
|
+
import { contextToXml } from "../utils";
|
|
8
9
|
import { Boosts } from "./common";
|
|
9
10
|
|
|
10
11
|
export interface VariableContextItem extends AIContextItem {
|
|
@@ -65,8 +66,16 @@ export class VariableContextProvider extends AIContextProvider<VariableContextIt
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
formatContext(item: VariableContextItem): string {
|
|
68
|
-
const {
|
|
69
|
+
const { data } = item;
|
|
69
70
|
const { variable } = data;
|
|
70
|
-
return
|
|
71
|
+
return contextToXml({
|
|
72
|
+
type: this.contextType,
|
|
73
|
+
data: {
|
|
74
|
+
name: variable.name,
|
|
75
|
+
dataType: variable.dataType,
|
|
76
|
+
},
|
|
77
|
+
details:
|
|
78
|
+
variable.value == null ? undefined : JSON.stringify(variable.value),
|
|
79
|
+
});
|
|
71
80
|
}
|
|
72
81
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
export interface AiContextPayload {
|
|
4
|
+
type: string;
|
|
5
|
+
data: Record<string, unknown>;
|
|
6
|
+
details?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// XML escaping utility
|
|
10
|
+
function escapeXml(unsafe: string): string {
|
|
11
|
+
return (
|
|
12
|
+
unsafe
|
|
13
|
+
// We don't escape these characters because this is for an LLM and they can interpret this just fine.
|
|
14
|
+
// .replaceAll("&", "&")
|
|
15
|
+
// .replaceAll('"', """)
|
|
16
|
+
// .replaceAll("'", "'")
|
|
17
|
+
.replaceAll("<", "<")
|
|
18
|
+
.replaceAll(">", ">")
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Convert a single Context object to XML
|
|
23
|
+
export function contextToXml(context: AiContextPayload): string {
|
|
24
|
+
const { type, data, details } = context;
|
|
25
|
+
|
|
26
|
+
// Start with opening tag
|
|
27
|
+
let xml = `<${type}`;
|
|
28
|
+
|
|
29
|
+
// Add data as attributes
|
|
30
|
+
for (const [key, value] of Object.entries(data)) {
|
|
31
|
+
const escapedValue = escapeXml(String(value));
|
|
32
|
+
if (value !== undefined) {
|
|
33
|
+
xml += ` ${key}="${escapedValue}"`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Close the opening tag
|
|
38
|
+
xml += ">";
|
|
39
|
+
|
|
40
|
+
// Add details as content if present
|
|
41
|
+
if (details) {
|
|
42
|
+
xml += escapeXml(details);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Add closing tag
|
|
46
|
+
xml += `</${type}>`;
|
|
47
|
+
|
|
48
|
+
return xml;
|
|
49
|
+
}
|
package/src/core/cells/cells.ts
CHANGED
|
@@ -1489,7 +1489,7 @@ export const canUndoDeletesAtom = atom((get) =>
|
|
|
1489
1489
|
|
|
1490
1490
|
export const needsRunAtom = atom((get) => notebookNeedsRun(get(notebookAtom)));
|
|
1491
1491
|
|
|
1492
|
-
const cellErrorsAtom = atom((get) => {
|
|
1492
|
+
export const cellErrorsAtom = atom((get) => {
|
|
1493
1493
|
const { cellIds, cellRuntime, cellData } = get(notebookAtom);
|
|
1494
1494
|
const errors = cellIds.inOrderIds
|
|
1495
1495
|
.map((cellId) => {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as m}from"./_baseEach-DJPM6ZzY.js";import{x as s}from"./index-CQFSXxPp.js";function e(r,o){var a=-1,t=s(r)?Array(r.length):[];return m(r,function(n,f,i){t[++a]=o(n,f,i)}),t}export{e as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as s,C as o}from"./mermaid-CUkYs7pX.js";const n=(a,r)=>s.lang.round(o.parse(a)[r]);export{n as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as t,C as o}from"./chunk-JBRWN2VN-CB8a_SQv.js";import{_ as e}from"./mermaid-CUkYs7pX.js";import"./transform-B8bpuzxV.js";import"./chunk-GLLZNHP4-CRWkmhQj.js";import"./chunk-WVR4S24B-ZnYlHppS.js";import"./chunk-NRVI72HA-nFtyi9pH.js";import"./index-CQFSXxPp.js";import"./step-BwsUM5iJ.js";import"./timer-BwIYMJWC.js";var i={parser:t,get db(){return new o},renderer:s,styles:a,init:e(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{i as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as t,C as o}from"./chunk-JBRWN2VN-CB8a_SQv.js";import{_ as e}from"./mermaid-CUkYs7pX.js";import"./transform-B8bpuzxV.js";import"./chunk-GLLZNHP4-CRWkmhQj.js";import"./chunk-WVR4S24B-ZnYlHppS.js";import"./chunk-NRVI72HA-nFtyi9pH.js";import"./index-CQFSXxPp.js";import"./step-BwsUM5iJ.js";import"./timer-BwIYMJWC.js";var i={parser:t,get db(){return new o},renderer:s,styles:a,init:e(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{i as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as n}from"./_baseUniq-CrXjB6JP.js";function o(r){return n(r,4)}export{o as c};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{_ as a,l as i,I as s,d as p,K as n}from"./mermaid-CUkYs7pX.js";import{p as m}from"./treemap-75Q7IDZK-BBbbCdps.js";import"./index-CQFSXxPp.js";import"./transform-B8bpuzxV.js";import"./timer-BwIYMJWC.js";import"./step-BwsUM5iJ.js";import"./_baseEach-DJPM6ZzY.js";import"./_baseUniq-CrXjB6JP.js";import"./min-Yuyj_o4k.js";import"./_baseMap-u5TY8JMW.js";import"./clone-yHYNh3QG.js";import"./_createAggregator-Cd0noqMc.js";var d={parse:a(async r=>{const t=await m("info",r);i.debug(t)},"parse")},g={version:n.version+""},v={parser:d,db:{getVersion:a(()=>g.version,"getVersion")},renderer:{draw:a((r,t,o)=>{i.debug(`rendering info diagram
|
|
2
|
-
`+r);const e=s(t);p(e,100,400,!0),e.append("g").append("text").attr("x",100).attr("y",40).attr("class","version").attr("font-size",32).style("text-anchor","middle").text(`v${o}`)},"draw")}};export{v as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as t,b as a,a as e,S as o}from"./chunk-LXBSTHXV-YNRk01ob.js";import{_ as s}from"./mermaid-CUkYs7pX.js";import"./transform-B8bpuzxV.js";import"./chunk-WVR4S24B-ZnYlHppS.js";import"./chunk-NRVI72HA-nFtyi9pH.js";import"./index-CQFSXxPp.js";import"./step-BwsUM5iJ.js";import"./timer-BwIYMJWC.js";var i={parser:e,get db(){return new o(2)},renderer:a,styles:t,init:s(r=>{r.state||(r.state={}),r.state.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{i as diagram};
|