@apteva/apteva-kit 0.1.33 → 0.1.35
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +96 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -11
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1325,23 +1325,48 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1325
1325
|
] });
|
|
1326
1326
|
}
|
|
1327
1327
|
if (contentSegments && contentSegments.length > 0) {
|
|
1328
|
-
return
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1328
|
+
return null;
|
|
1329
|
+
}
|
|
1330
|
+
return renderTextContent(message.content);
|
|
1331
|
+
};
|
|
1332
|
+
const renderSegmentedContent = () => {
|
|
1333
|
+
if (!contentSegments || contentSegments.length === 0) {
|
|
1334
|
+
return null;
|
|
1335
|
+
}
|
|
1336
|
+
const elements = [];
|
|
1337
|
+
contentSegments.forEach((segment, index) => {
|
|
1338
|
+
if (segment.type === "text" && segment.content) {
|
|
1339
|
+
elements.push(
|
|
1340
|
+
/* @__PURE__ */ jsx11(
|
|
1341
|
+
"div",
|
|
1342
|
+
{
|
|
1343
|
+
className: "apteva-message-bubble apteva-message-assistant",
|
|
1344
|
+
children: /* @__PURE__ */ jsx11("div", { className: "apteva-message-content-assistant", children: renderTextContent(segment.content) })
|
|
1345
|
+
},
|
|
1346
|
+
`text-${index}`
|
|
1347
|
+
)
|
|
1348
|
+
);
|
|
1349
|
+
} else if (segment.type === "tool") {
|
|
1350
|
+
elements.push(
|
|
1351
|
+
/* @__PURE__ */ jsx11("div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ jsx11(
|
|
1333
1352
|
ToolCall,
|
|
1334
1353
|
{
|
|
1335
1354
|
name: segment.name,
|
|
1336
1355
|
status: segment.result !== void 0 ? "completed" : "running"
|
|
1337
1356
|
}
|
|
1338
|
-
) }, segment.id)
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
return renderTextContent(message.content);
|
|
1357
|
+
) }, segment.id)
|
|
1358
|
+
);
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
return elements;
|
|
1344
1362
|
};
|
|
1363
|
+
if (!isUser && contentSegments && contentSegments.length > 0) {
|
|
1364
|
+
return /* @__PURE__ */ jsxs8("div", { className: "apteva-message-segmented", children: [
|
|
1365
|
+
renderSegmentedContent(),
|
|
1366
|
+
message.widgets && message.widgets.length > 0 && /* @__PURE__ */ jsx11("div", { className: "apteva-message-widgets", children: /* @__PURE__ */ jsx11(Widgets, { widgets: message.widgets, onAction, layout: "stack" }) }),
|
|
1367
|
+
/* @__PURE__ */ jsx11("div", { className: "apteva-message-timestamp apteva-message-timestamp-assistant", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
1368
|
+
] });
|
|
1369
|
+
}
|
|
1345
1370
|
return /* @__PURE__ */ jsxs8(
|
|
1346
1371
|
"div",
|
|
1347
1372
|
{
|
|
@@ -2288,6 +2313,7 @@ var Chat = forwardRef(function Chat2({
|
|
|
2288
2313
|
onFileUpload,
|
|
2289
2314
|
onComplete,
|
|
2290
2315
|
onError,
|
|
2316
|
+
onToolCall,
|
|
2291
2317
|
onToolResult,
|
|
2292
2318
|
// UI
|
|
2293
2319
|
placeholder,
|
|
@@ -2480,6 +2506,7 @@ ${widgetContext}` : widgetContext;
|
|
|
2480
2506
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: chunk.tool_name });
|
|
2481
2507
|
toolInputBuffer = "";
|
|
2482
2508
|
setChatToolName(chunk.tool_name);
|
|
2509
|
+
onToolCall?.(chunk.tool_name, chunk.tool_id);
|
|
2483
2510
|
updateMessage();
|
|
2484
2511
|
}
|
|
2485
2512
|
break;
|
|
@@ -2699,6 +2726,7 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2699
2726
|
} else if (chunk.type === "tool_call" && chunk.tool_name) {
|
|
2700
2727
|
lastToolName = chunk.tool_name;
|
|
2701
2728
|
setCurrentToolName(chunk.tool_name);
|
|
2729
|
+
onToolCall?.(chunk.tool_name, chunk.tool_id || "");
|
|
2702
2730
|
accumulatedContent = "";
|
|
2703
2731
|
setStreamedContent("");
|
|
2704
2732
|
} else if (chunk.type === "tool_result") {
|