@marimo-team/islands 0.19.3-dev41 → 0.19.3-dev45
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/main.js +43 -135
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/chat/chat-utils.ts +0 -19
- package/src/components/editor/ai/completion-handlers.tsx +1 -1
- package/src/plugins/impl/chat/ChatPlugin.tsx +2 -4
- package/src/plugins/impl/chat/chat-ui.tsx +46 -187
- package/src/plugins/impl/chat/types.ts +5 -12
package/dist/main.js
CHANGED
|
@@ -71227,6 +71227,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
71227
71227
|
}), z = (0, import_react.useRef)(null), { data: G } = useAsyncData(async () => (await e.get_chat_history({})).messages, []), q = e.value.length > 0 ? e.value : G, { messages: LY, sendMessage: RY, setMessages: zY, status: BY, stop: VY, error: HY, regenerate: UY, clearError: WY } = useChat({
|
|
71228
71228
|
transport: new DefaultChatTransport({
|
|
71229
71229
|
fetch: async (r2, c2) => {
|
|
71230
|
+
var _a3;
|
|
71230
71231
|
if (c2 === void 0) return fetch(r2);
|
|
71231
71232
|
let d2 = JSON.parse(c2.body), f2 = c2.signal, h2 = {
|
|
71232
71233
|
max_tokens: M.current.max_tokens,
|
|
@@ -71238,98 +71239,49 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
71238
71239
|
};
|
|
71239
71240
|
try {
|
|
71240
71241
|
let r3 = d2.messages.map((e2) => {
|
|
71241
|
-
var
|
|
71242
|
+
var _a4;
|
|
71242
71243
|
return {
|
|
71243
71244
|
...e2,
|
|
71244
|
-
content: (
|
|
71245
|
+
content: (_a4 = e2.parts) == null ? void 0 : _a4.map((e3) => "text" in e3 ? e3.text : "").join("\n")
|
|
71245
71246
|
};
|
|
71246
|
-
})
|
|
71247
|
-
|
|
71248
|
-
|
|
71249
|
-
|
|
71250
|
-
|
|
71251
|
-
|
|
71252
|
-
|
|
71253
|
-
|
|
71254
|
-
|
|
71255
|
-
|
|
71256
|
-
error: e3
|
|
71257
|
-
});
|
|
71258
|
-
}
|
|
71259
|
-
z.current = null;
|
|
71260
|
-
};
|
|
71261
|
-
return f2 == null ? void 0 : f2.addEventListener("abort", r4), () => {
|
|
71262
|
-
f2 == null ? void 0 : f2.removeEventListener("abort", r4);
|
|
71263
|
-
};
|
|
71264
|
-
},
|
|
71265
|
-
cancel() {
|
|
71266
|
-
z.current = null;
|
|
71267
|
-
}
|
|
71268
|
-
});
|
|
71269
|
-
return e.send_prompt({
|
|
71270
|
-
messages: r3,
|
|
71271
|
-
config: h2
|
|
71272
|
-
}).catch((e2) => {
|
|
71273
|
-
var _a3;
|
|
71274
|
-
(_a3 = z.current) == null ? void 0 : _a3.error(e2), z.current = null;
|
|
71275
|
-
}), createUIMessageStreamResponse({
|
|
71276
|
-
stream: c4
|
|
71277
|
-
});
|
|
71278
|
-
}
|
|
71279
|
-
if (f2 == null ? void 0 : f2.aborted) return new Response("Aborted", {
|
|
71280
|
-
status: 499
|
|
71281
|
-
});
|
|
71282
|
-
let c3 = Date.now().toString();
|
|
71283
|
-
zY((e2) => [
|
|
71284
|
-
...e2,
|
|
71285
|
-
{
|
|
71286
|
-
id: c3,
|
|
71287
|
-
role: "assistant",
|
|
71288
|
-
parts: [
|
|
71289
|
-
{
|
|
71290
|
-
type: "text",
|
|
71291
|
-
text: ""
|
|
71247
|
+
}), c3 = new ReadableStream({
|
|
71248
|
+
start(e2) {
|
|
71249
|
+
z.current = e2;
|
|
71250
|
+
let r4 = () => {
|
|
71251
|
+
try {
|
|
71252
|
+
e2.close();
|
|
71253
|
+
} catch (e3) {
|
|
71254
|
+
Logger.debug("Controller may already be closed", {
|
|
71255
|
+
error: e3
|
|
71256
|
+
});
|
|
71292
71257
|
}
|
|
71293
|
-
|
|
71258
|
+
z.current = null;
|
|
71259
|
+
};
|
|
71260
|
+
return f2 == null ? void 0 : f2.addEventListener("abort", r4), () => {
|
|
71261
|
+
f2 == null ? void 0 : f2.removeEventListener("abort", r4);
|
|
71262
|
+
};
|
|
71263
|
+
},
|
|
71264
|
+
cancel() {
|
|
71265
|
+
z.current = null;
|
|
71294
71266
|
}
|
|
71295
|
-
|
|
71296
|
-
|
|
71267
|
+
});
|
|
71268
|
+
return e.send_prompt({
|
|
71297
71269
|
messages: r3,
|
|
71298
71270
|
config: h2
|
|
71299
|
-
})
|
|
71300
|
-
|
|
71301
|
-
|
|
71302
|
-
|
|
71303
|
-
|
|
71304
|
-
f2 == null ? void 0 : f2.removeEventListener("abort", c4);
|
|
71305
|
-
});
|
|
71271
|
+
}).catch((e2) => {
|
|
71272
|
+
var _a4;
|
|
71273
|
+
(_a4 = z.current) == null ? void 0 : _a4.error(e2), z.current = null;
|
|
71274
|
+
}), createUIMessageStreamResponse({
|
|
71275
|
+
stream: c3
|
|
71306
71276
|
});
|
|
71307
|
-
return v2 === null ? (Logger.error("Non-frontend-managed response is null", {
|
|
71308
|
-
response: v2
|
|
71309
|
-
}), new Response("Internal server error", {
|
|
71310
|
-
status: 500
|
|
71311
|
-
})) : (I.current.backendMessageId === null && I.current.frontendMessageIndex === null && zY((e2) => {
|
|
71312
|
-
let r4 = [
|
|
71313
|
-
...e2
|
|
71314
|
-
], d3 = r4.findIndex((e3) => e3.id === c3);
|
|
71315
|
-
return d3 !== -1 && (r4[d3] = {
|
|
71316
|
-
...r4[d3],
|
|
71317
|
-
parts: [
|
|
71318
|
-
{
|
|
71319
|
-
type: "text",
|
|
71320
|
-
text: v2
|
|
71321
|
-
}
|
|
71322
|
-
]
|
|
71323
|
-
}), r4;
|
|
71324
|
-
}), new Response(v2));
|
|
71325
71277
|
} catch (e2) {
|
|
71326
71278
|
if (I.current = {
|
|
71327
71279
|
backendMessageId: null,
|
|
71328
71280
|
frontendMessageIndex: null
|
|
71329
|
-
}, e2.name === "AbortError") return new Response("Aborted", {
|
|
71281
|
+
}, e2 instanceof Error && e2.name === "AbortError") return new Response("Aborted", {
|
|
71330
71282
|
status: 499
|
|
71331
71283
|
});
|
|
71332
|
-
let r3 = e2.message.split("failed with exception ").pop();
|
|
71284
|
+
let r3 = (_a3 = e2.message) == null ? void 0 : _a3.split("failed with exception ").pop();
|
|
71333
71285
|
return new Response(r3, {
|
|
71334
71286
|
status: 400
|
|
71335
71287
|
});
|
|
@@ -71341,7 +71293,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
71341
71293
|
y(void 0), S.current && (S.current.value = ""), Logger.debug("Finished streaming message:", r2), I.current = {
|
|
71342
71294
|
backendMessageId: null,
|
|
71343
71295
|
frontendMessageIndex: null
|
|
71344
|
-
}, e.
|
|
71296
|
+
}, e.setValue(r2.messages);
|
|
71345
71297
|
},
|
|
71346
71298
|
onError: (e2) => {
|
|
71347
71299
|
Logger.error("An error occurred:", e2), I.current = {
|
|
@@ -71350,52 +71302,13 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
71350
71302
|
};
|
|
71351
71303
|
}
|
|
71352
71304
|
});
|
|
71353
|
-
useEventListener(e.host, MarimoIncomingMessageEvent.TYPE, (
|
|
71354
|
-
let
|
|
71355
|
-
if (typeof
|
|
71356
|
-
|
|
71357
|
-
|
|
71358
|
-
|
|
71359
|
-
|
|
71360
|
-
r3.content && e2.enqueue(r3.content), r3.is_final && (e2.close(), z.current = null);
|
|
71361
|
-
return;
|
|
71362
|
-
}
|
|
71363
|
-
let d2 = c2;
|
|
71364
|
-
I.current.backendMessageId === null && zY((e2) => {
|
|
71365
|
-
let r3 = [
|
|
71366
|
-
...e2
|
|
71367
|
-
];
|
|
71368
|
-
for (let e3 = r3.length - 1; e3 >= 0; e3--) if (r3[e3].role === "assistant") {
|
|
71369
|
-
I.current = {
|
|
71370
|
-
backendMessageId: d2.message_id,
|
|
71371
|
-
frontendMessageIndex: e3
|
|
71372
|
-
};
|
|
71373
|
-
break;
|
|
71374
|
-
}
|
|
71375
|
-
return r3;
|
|
71376
|
-
});
|
|
71377
|
-
let f2 = I.current.frontendMessageIndex;
|
|
71378
|
-
I.current.backendMessageId === d2.message_id && f2 !== null && (zY((e2) => {
|
|
71379
|
-
let r3 = [
|
|
71380
|
-
...e2
|
|
71381
|
-
], c3 = f2;
|
|
71382
|
-
if (c3 < r3.length) {
|
|
71383
|
-
let e3 = r3[c3];
|
|
71384
|
-
e3.role === "assistant" && (r3[c3] = {
|
|
71385
|
-
...e3,
|
|
71386
|
-
parts: [
|
|
71387
|
-
{
|
|
71388
|
-
type: "text",
|
|
71389
|
-
text: d2.content
|
|
71390
|
-
}
|
|
71391
|
-
]
|
|
71392
|
-
});
|
|
71393
|
-
}
|
|
71394
|
-
return r3;
|
|
71395
|
-
}), d2.is_final && (I.current = {
|
|
71396
|
-
backendMessageId: null,
|
|
71397
|
-
frontendMessageIndex: null
|
|
71398
|
-
}));
|
|
71305
|
+
useEventListener(e.host, MarimoIncomingMessageEvent.TYPE, (e2) => {
|
|
71306
|
+
let r2 = e2.detail.message;
|
|
71307
|
+
if (typeof r2 != "object" || !r2 || !("type" in r2) || r2.type !== "stream_chunk") return;
|
|
71308
|
+
let c2 = z.current;
|
|
71309
|
+
if (!c2) return;
|
|
71310
|
+
let d2 = r2;
|
|
71311
|
+
d2.content && c2.enqueue(d2.content), d2.is_final && (c2.close(), z.current = null);
|
|
71399
71312
|
});
|
|
71400
71313
|
let GY = BY === "submitted" || BY === "streaming", KY = (r2) => {
|
|
71401
71314
|
let c2 = LY.findIndex((e2) => e2.id === r2);
|
|
@@ -71403,7 +71316,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
71403
71316
|
let d2 = LY.filter((e2) => e2.id !== r2);
|
|
71404
71317
|
e.delete_chat_message({
|
|
71405
71318
|
index: c2
|
|
71406
|
-
}), zY(d2), e.
|
|
71319
|
+
}), zY(d2), e.setValue(d2);
|
|
71407
71320
|
}
|
|
71408
71321
|
}, qY = Array.isArray(e.allowAttachments) && e.allowAttachments.length > 0 || e.allowAttachments === true, JY = {
|
|
71409
71322
|
triggerCompletionRegex: /^\/(\w+)?/,
|
|
@@ -71509,7 +71422,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
71509
71422
|
]
|
|
71510
71423
|
})
|
|
71511
71424
|
]
|
|
71512
|
-
}, e2.id);
|
|
71425
|
+
}, `${e2.id}-${r2}`);
|
|
71513
71426
|
}),
|
|
71514
71427
|
GY && (0, import_jsx_runtime.jsxs)("div", {
|
|
71515
71428
|
className: "flex items-center justify-center space-x-2 mb-4",
|
|
@@ -71975,8 +71888,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
71975
71888
|
allowAttachments: union([
|
|
71976
71889
|
boolean$2(),
|
|
71977
71890
|
string$2().array()
|
|
71978
|
-
])
|
|
71979
|
-
frontendManaged: boolean$2()
|
|
71891
|
+
])
|
|
71980
71892
|
})).withFunctions({
|
|
71981
71893
|
get_chat_history: rpc.input(object$1({})).output(object$1({
|
|
71982
71894
|
messages: messageSchema
|
|
@@ -71988,10 +71900,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
71988
71900
|
send_prompt: rpc.input(object$1({
|
|
71989
71901
|
messages: messageSchema,
|
|
71990
71902
|
config: configSchema
|
|
71991
|
-
})).output(
|
|
71992
|
-
string$2(),
|
|
71993
|
-
_null()
|
|
71994
|
-
]))
|
|
71903
|
+
})).output(unknown())
|
|
71995
71904
|
}).renderer((e) => {
|
|
71996
71905
|
var _a2;
|
|
71997
71906
|
return (0, import_jsx_runtime.jsx)(TooltipProvider, {
|
|
@@ -72001,7 +71910,6 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
72001
71910
|
showConfigurationControls: e.data.showConfigurationControls,
|
|
72002
71911
|
maxHeight: e.data.maxHeight,
|
|
72003
71912
|
allowAttachments: e.data.allowAttachments,
|
|
72004
|
-
frontendManaged: e.data.frontendManaged,
|
|
72005
71913
|
config: e.data.config,
|
|
72006
71914
|
get_chat_history: e.functions.get_chat_history,
|
|
72007
71915
|
delete_chat_history: e.functions.delete_chat_history,
|
|
@@ -101153,7 +101061,7 @@ Defaulting to \`null\`.`;
|
|
|
101153
101061
|
return Logger.warn("Failed to get version from mount config"), null;
|
|
101154
101062
|
}
|
|
101155
101063
|
}
|
|
101156
|
-
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.3-
|
|
101064
|
+
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.3-dev45"), showCodeInRunModeAtom = atom(true);
|
|
101157
101065
|
atom(null);
|
|
101158
101066
|
var VIRTUAL_FILE_REGEX = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g, VirtualFileTracker = class e {
|
|
101159
101067
|
constructor() {
|