telygent-ui 0.1.13 → 0.1.14
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/package.json
CHANGED
|
@@ -344,14 +344,51 @@ const AssistantMessageBody = React.memo(function AssistantMessageBody({
|
|
|
344
344
|
item: ChatMessage;
|
|
345
345
|
isLatestMessage: boolean;
|
|
346
346
|
}) {
|
|
347
|
+
if (item.status === "thinking" || item.status === "tool_use") {
|
|
348
|
+
return (
|
|
349
|
+
<div className="mdx text-sm text-slate-700 max-w-none flex flex-col gap-2">
|
|
350
|
+
<p className="flex items-start gap-2 text-slate-500 leading-relaxed">
|
|
351
|
+
<span className="mt-0.5 h-3 w-3 flex-shrink-0 animate-pulse rounded-full bg-slate-400" />
|
|
352
|
+
<span>{item.content || "Thinking…"}</span>
|
|
353
|
+
</p>
|
|
354
|
+
{item.toolHistory && item.toolHistory.length > 0 && (
|
|
355
|
+
<div className="flex flex-col gap-1.5 pl-1">
|
|
356
|
+
{item.toolHistory.length > 3 && (
|
|
357
|
+
<p className="flex items-center gap-2 text-xs text-slate-400">
|
|
358
|
+
<Check className="h-3 w-3 flex-shrink-0 text-emerald-500" />
|
|
359
|
+
<span>{item.toolHistory.length - 3} tools completed</span>
|
|
360
|
+
</p>
|
|
361
|
+
)}
|
|
362
|
+
{item.toolHistory.slice(-3).map((entry, i, slice) => {
|
|
363
|
+
const isActive = i === slice.length - 1 && item.status === "tool_use";
|
|
364
|
+
return (
|
|
365
|
+
<div key={i} className="flex items-center gap-2 text-xs">
|
|
366
|
+
{isActive ? (
|
|
367
|
+
<span className="h-3 w-3 flex-shrink-0 animate-spin rounded-full border border-slate-300 border-t-slate-600" />
|
|
368
|
+
) : (
|
|
369
|
+
<Check className="h-3 w-3 flex-shrink-0 text-emerald-500" />
|
|
370
|
+
)}
|
|
371
|
+
<span className={cn(isActive ? "text-slate-600" : "text-slate-400 line-through")}>
|
|
372
|
+
{entry.toolContext}
|
|
373
|
+
</span>
|
|
374
|
+
<div className="flex gap-1">
|
|
375
|
+
{entry.toolNames.map((name) => (
|
|
376
|
+
<span key={name} className={cn("rounded px-1 py-0.5 font-mono text-[10px]", isActive ? "bg-slate-100 text-slate-500" : "bg-slate-50 text-slate-400")}>
|
|
377
|
+
{name}
|
|
378
|
+
</span>
|
|
379
|
+
))}
|
|
380
|
+
</div>
|
|
381
|
+
</div>
|
|
382
|
+
);
|
|
383
|
+
})}
|
|
384
|
+
</div>
|
|
385
|
+
)}
|
|
386
|
+
</div>
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
|
|
347
390
|
return (
|
|
348
391
|
<div className="mdx text-sm text-slate-700 max-w-none">
|
|
349
|
-
{item.status === "thinking" ? (
|
|
350
|
-
<p className="mb-3 flex items-center gap-2 text-xs text-slate-400">
|
|
351
|
-
<span className="h-3 w-3 animate-pulse rounded-full bg-slate-400" />
|
|
352
|
-
<span>Thinking…</span>
|
|
353
|
-
</p>
|
|
354
|
-
) : null}
|
|
355
392
|
{(item.visualizations && item.visualizations.length > 0) ||
|
|
356
393
|
(item.summaryCards && item.summaryCards.length > 0)
|
|
357
394
|
? renderMessageWithRichContent(
|
|
@@ -550,7 +587,7 @@ export function ChatInterface({
|
|
|
550
587
|
return false;
|
|
551
588
|
}
|
|
552
589
|
const latest = timeline[timeline.length - 1];
|
|
553
|
-
return latest.role === "assistant" && latest.status === "thinking";
|
|
590
|
+
return latest.role === "assistant" && (latest.status === "thinking" || latest.status === "tool_use");
|
|
554
591
|
}, [timeline]);
|
|
555
592
|
|
|
556
593
|
return (
|
|
@@ -27,10 +27,12 @@ export type ChatMessage = {
|
|
|
27
27
|
createdAt?: Date;
|
|
28
28
|
visualizations?: ChatVisualization[];
|
|
29
29
|
summaryCards?: ChatSummaryCard[];
|
|
30
|
-
phase?: "thinking" | "final" | "error";
|
|
30
|
+
phase?: "thinking" | "tool_use" | "final" | "error";
|
|
31
31
|
status?: string;
|
|
32
32
|
meta?: Record<string, unknown>;
|
|
33
33
|
toolCalls?: unknown[];
|
|
34
|
+
currentTool?: string;
|
|
35
|
+
toolHistory?: {toolNames: string[]; toolContext: string}[];
|
|
34
36
|
softCap?: number;
|
|
35
37
|
hardCap?: number;
|
|
36
38
|
};
|
|
@@ -47,13 +49,15 @@ export type SendMessageResult = {
|
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
export type ChatStreamEvent = {
|
|
50
|
-
phase: "thinking" | "final" | "error";
|
|
52
|
+
phase: "thinking" | "tool_use" | "final" | "error";
|
|
51
53
|
status: string;
|
|
52
54
|
content?: string;
|
|
53
55
|
conversationId?: string;
|
|
54
56
|
visualizations?: ChatVisualization[];
|
|
55
57
|
summaryCards?: ChatSummaryCard[];
|
|
56
58
|
meta?: Record<string, unknown>;
|
|
59
|
+
toolNames?: string[];
|
|
60
|
+
toolContext?: string;
|
|
57
61
|
tool_calls?: unknown[];
|
|
58
62
|
softCap?: number;
|
|
59
63
|
hardCap?: number;
|
|
@@ -108,6 +108,25 @@ export function useDatabaseChat(options: UseDatabaseChatOptions) {
|
|
|
108
108
|
continue;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
if (event.status === "tool_use") {
|
|
112
|
+
const entry = {toolNames: event.toolNames ?? [], toolContext: event.toolContext ?? ""};
|
|
113
|
+
setTimeline((prev) =>
|
|
114
|
+
prev.map((msg) =>
|
|
115
|
+
msg.id === assistantId
|
|
116
|
+
? {
|
|
117
|
+
...msg,
|
|
118
|
+
phase: event.phase,
|
|
119
|
+
status: event.status,
|
|
120
|
+
meta: event.meta,
|
|
121
|
+
currentTool: entry.toolNames[0] ?? "",
|
|
122
|
+
toolHistory: [...(msg.toolHistory ?? []), entry],
|
|
123
|
+
}
|
|
124
|
+
: msg
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
111
130
|
if (event.status === "final") {
|
|
112
131
|
updateMessage(assistantId, {
|
|
113
132
|
content: event.content ?? "",
|