refactor: simplify assistant message controls
This commit is contained in:
1 parent
6eb75ca559
commit
0c5fc1d331
5 files changed
+310
-197
No files matched your search
@@ -70,7 +70,7 @@ page layout until it is opened. Users can start, revisit, and delete conversatio
|
|||||||
conversation menu in the floating panel.
|
conversation menu in the floating panel.
|
||||||
|
|
||||||
Messages support copy, edit-and-resend, response regeneration and branch navigation, Markdown export,
|
Messages support copy, edit-and-resend, response regeneration and branch navigation, Markdown export,
|
||||||
helpful/not-helpful feedback, text-to-speech, and browser speech dictation when the browser supports it.
|
and helpful/not-helpful feedback.
|
||||||
Selecting text in a message exposes a quote action that carries the selected passage into the next prompt.
|
Selecting text in a message exposes a quote action that carries the selected passage into the next prompt.
|
||||||
Files returned by a compatible model can be downloaded directly from the message.
|
Files returned by a compatible model can be downloaded directly from the message.
|
||||||
Assistant responses render GitHub-flavored Markdown, including headings, links, lists, task lists, tables,
|
Assistant responses render GitHub-flavored Markdown, including headings, links, lists, task lists, tables,
|
||||||
@@ -85,9 +85,10 @@ Type `@` in the composer to add permission-checked context. The nested menu cont
|
|||||||
boards, widgets, and tools available to the current user. Homarr validates every referenced ID again on
|
boards, widgets, and tools available to the current user. Homarr validates every referenced ID again on
|
||||||
the server before adding it to the model context. Type `/` for common prompt shortcuts.
|
the server before adding it to the model context. Type `/` for common prompt shortcuts.
|
||||||
|
|
||||||
Each completed response includes expandable request details when the provider reports them: input,
|
Each completed response includes a circular context-window meter. Select it to open request details when
|
||||||
output, cached-input and reasoning tokens, context-window utilization, time to first output, total
|
the provider reports them: input, output, cached-input and reasoning tokens, used and remaining context,
|
||||||
duration, output speed, agent-step timing, and cost. OpenRouter-reported cost is labeled as reported.
|
time to first output, total duration, output speed, agent-step timing, and cost. OpenRouter-reported cost
|
||||||
|
is labeled as reported.
|
||||||
OpenRouter responses also show the routed provider, generation identifier, and upstream inference cost when
|
OpenRouter responses also show the routed provider, generation identifier, and upstream inference cost when
|
||||||
the endpoint supplies those fields.
|
the endpoint supplies those fields.
|
||||||
When a provider omits cost but model discovery includes prompt and completion pricing, Homarr labels the
|
When a provider omits cost but model discovery includes prompt and completion pricing, Homarr labels the
|
||||||
|
|||||||
@@ -405,14 +405,12 @@
|
|||||||
border-inline-start: 2px solid var(--mantine-color-default-border);
|
border-inline-start: 2px solid var(--mantine-color-default-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.reasoning summary,
|
.reasoning summary {
|
||||||
.telemetry summary {
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reasoning summary::-webkit-details-marker,
|
.reasoning summary::-webkit-details-marker {
|
||||||
.telemetry summary::-webkit-details-marker {
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,15 +505,72 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.telemetry {
|
.telemetry {
|
||||||
margin-top: 0.65rem;
|
margin-top: 0.45rem;
|
||||||
padding: 0.5rem 0.6rem;
|
padding-inline: 0.15rem;
|
||||||
border: 1px solid var(--mantine-color-default-border);
|
|
||||||
border-radius: var(--mantine-radius-md);
|
|
||||||
background: color-mix(in srgb, var(--mantine-color-default) 60%, transparent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.telemetrySummary {
|
.telemetryFacts {
|
||||||
user-select: none;
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modelBadge {
|
||||||
|
max-width: min(100%, 14rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextMeter {
|
||||||
|
display: grid;
|
||||||
|
width: 2.75rem;
|
||||||
|
height: 2.75rem;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
place-items: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
color: var(--mantine-color-text);
|
||||||
|
transition:
|
||||||
|
background-color 160ms ease,
|
||||||
|
transform 160ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextMeter:hover {
|
||||||
|
background: var(--mantine-color-default-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextMeter:active {
|
||||||
|
transform: scale(0.96);
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextMeter:focus-visible {
|
||||||
|
outline: 2px solid var(--mantine-primary-color-filled);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextMeterLabel {
|
||||||
|
font-size: 0.55rem;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.telemetryPopover {
|
||||||
|
max-height: min(32rem, calc(100dvh - 2rem));
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextStats {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextStats > div {
|
||||||
|
min-width: 0;
|
||||||
|
padding: 0.45rem 0.5rem;
|
||||||
|
border-radius: var(--mantine-radius-sm);
|
||||||
|
background: var(--mantine-color-body);
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextStats :global(.mantine-Text-root) {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.usageGrid {
|
.usageGrid {
|
||||||
@@ -813,8 +868,10 @@
|
|||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.activityBar,
|
.activityBar,
|
||||||
.floatingPanel {
|
.floatingPanel,
|
||||||
|
.contextMeter {
|
||||||
animation: none;
|
animation: none;
|
||||||
|
transition: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.viewport {
|
.viewport {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import {
|
|||||||
Group,
|
Group,
|
||||||
Loader,
|
Loader,
|
||||||
Popover,
|
Popover,
|
||||||
Progress,
|
RingProgress,
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
@@ -68,7 +68,6 @@ import {
|
|||||||
IconFileExport,
|
IconFileExport,
|
||||||
IconLink,
|
IconLink,
|
||||||
IconMessage,
|
IconMessage,
|
||||||
IconMicrophone,
|
|
||||||
IconPaperclip,
|
IconPaperclip,
|
||||||
IconPencil,
|
IconPencil,
|
||||||
IconHistory,
|
IconHistory,
|
||||||
@@ -78,7 +77,6 @@ import {
|
|||||||
IconRefresh,
|
IconRefresh,
|
||||||
IconRobot,
|
IconRobot,
|
||||||
IconSearch,
|
IconSearch,
|
||||||
IconSpeakerphone,
|
|
||||||
IconThumbDown,
|
IconThumbDown,
|
||||||
IconThumbUp,
|
IconThumbUp,
|
||||||
IconTool,
|
IconTool,
|
||||||
@@ -462,20 +460,6 @@ const AssistantMessageActions = () => {
|
|||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</ActionBarPrimitive.Copy>
|
</ActionBarPrimitive.Copy>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip label={t("speak")}>
|
|
||||||
<ActionBarPrimitive.Speak asChild>
|
|
||||||
<ActionIcon variant="subtle" color="gray" size="sm" aria-label={t("speak")}>
|
|
||||||
<IconSpeakerphone size={14} />
|
|
||||||
</ActionIcon>
|
|
||||||
</ActionBarPrimitive.Speak>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip label={t("stopSpeaking")}>
|
|
||||||
<ActionBarPrimitive.StopSpeaking asChild>
|
|
||||||
<ActionIcon variant="subtle" color="gray" size="sm" aria-label={t("stopSpeaking")}>
|
|
||||||
<IconPlayerStop size={14} />
|
|
||||||
</ActionIcon>
|
|
||||||
</ActionBarPrimitive.StopSpeaking>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip label={t("helpful")}>
|
<Tooltip label={t("helpful")}>
|
||||||
<ActionBarPrimitive.FeedbackPositive asChild>
|
<ActionBarPrimitive.FeedbackPositive asChild>
|
||||||
<ActionIcon variant="subtle" color="gray" size="sm" aria-label={t("helpful")}>
|
<ActionIcon variant="subtle" color="gray" size="sm" aria-label={t("helpful")}>
|
||||||
@@ -586,18 +570,39 @@ const formatCost = (cost: number) => {
|
|||||||
return `$${cost.toFixed(cost < 0.01 ? 4 : 3)}`;
|
return `$${cost.toFixed(cost < 0.01 ? 4 : 3)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getContextColor = (percentage: number) => {
|
||||||
|
if (percentage >= 90) return "red";
|
||||||
|
if (percentage >= 75) return "orange";
|
||||||
|
return "blue";
|
||||||
|
};
|
||||||
|
|
||||||
const RequestTelemetry = () => {
|
const RequestTelemetry = () => {
|
||||||
const t = useScopedI18n("common.assistant");
|
const t = useScopedI18n("common.assistant");
|
||||||
|
const [opened, setOpened] = useState(false);
|
||||||
const metadata = useAuiState((state) => state.message.metadata);
|
const metadata = useAuiState((state) => state.message.metadata);
|
||||||
const telemetry = getAssistantTelemetry(metadata);
|
const telemetry = getAssistantTelemetry(metadata);
|
||||||
const usage = getAssistantUsage(metadata);
|
const usage = getAssistantUsage(metadata);
|
||||||
if (!telemetry) return null;
|
if (!telemetry) return null;
|
||||||
|
|
||||||
|
const contextLength = telemetry.contextLength ?? 0;
|
||||||
|
const contextUsed = telemetry.contextUsed ?? 0;
|
||||||
|
const hasContextWindow = telemetry.contextLength !== undefined && telemetry.contextUsed !== undefined;
|
||||||
|
const contextPercentage = hasContextWindow
|
||||||
|
? Math.min(
|
||||||
|
100,
|
||||||
|
Math.max(0, Math.round((telemetry.contextUtilization ?? contextUsed / Math.max(contextLength, 1)) * 100)),
|
||||||
|
)
|
||||||
|
: 0;
|
||||||
|
const contextRemaining = hasContextWindow ? Math.max(contextLength - contextUsed, 0) : undefined;
|
||||||
|
const contextLabel = hasContextWindow
|
||||||
|
? `${t("usage.contextWindow")}: ${contextUsed.toLocaleString()} / ${contextLength.toLocaleString()} (${contextPercentage}%)`
|
||||||
|
: `${t("usage.contextWindow")}: ${t("usage.notReported")}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<details className={classes.telemetry}>
|
<Box className={classes.telemetry}>
|
||||||
<summary className={classes.telemetrySummary}>
|
<Group justify="space-between" align="center" gap="xs" wrap="nowrap">
|
||||||
<Group gap="xs" wrap="wrap">
|
<Group className={classes.telemetryFacts} gap="xs" wrap="wrap">
|
||||||
<Badge size="xs" variant="light" color="gray">
|
<Badge className={classes.modelBadge} size="xs" variant="light" color="gray">
|
||||||
{telemetry.modelId}
|
{telemetry.modelId}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge size="xs" variant="outline" color="gray">
|
<Badge size="xs" variant="outline" color="gray">
|
||||||
@@ -618,147 +623,218 @@ const RequestTelemetry = () => {
|
|||||||
{formatCost(telemetry.cost)}
|
{formatCost(telemetry.cost)}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
{usage?.totalTokens !== undefined && (
|
|
||||||
<Text size="xs" c="dimmed">
|
|
||||||
{usage.totalTokens.toLocaleString()} {t("usage.tokens")}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
<IconChevronDown size={13} />
|
|
||||||
</Group>
|
</Group>
|
||||||
</summary>
|
|
||||||
<Stack gap="sm" mt="xs">
|
<Popover
|
||||||
{telemetry.contextLength !== undefined && telemetry.contextUsed !== undefined && (
|
opened={opened}
|
||||||
<Box>
|
onChange={setOpened}
|
||||||
<Group justify="space-between" gap="xs">
|
width="min(20rem, calc(100vw - 1.5rem))"
|
||||||
<Text size="xs" fw={600}>
|
position="bottom-end"
|
||||||
{t("usage.contextWindow")}
|
shadow="md"
|
||||||
</Text>
|
withArrow
|
||||||
<Text size="xs" c="dimmed">
|
trapFocus
|
||||||
{telemetry.contextUsed.toLocaleString()} / {telemetry.contextLength.toLocaleString()}
|
returnFocus
|
||||||
</Text>
|
>
|
||||||
</Group>
|
<Popover.Target>
|
||||||
<Progress value={(telemetry.contextUtilization ?? 0) * 100} size="sm" mt={5} />
|
<UnstyledButton
|
||||||
</Box>
|
className={classes.contextMeter}
|
||||||
)}
|
aria-label={contextLabel}
|
||||||
<Box className={classes.usageGrid}>
|
aria-expanded={opened}
|
||||||
<div>
|
aria-haspopup="dialog"
|
||||||
<Text size="xs" c="dimmed">
|
title={contextLabel}
|
||||||
{t("usage.input")}
|
onClick={() => setOpened((value) => !value)}
|
||||||
</Text>
|
>
|
||||||
<Text size="sm" fw={600}>
|
<RingProgress
|
||||||
{usage?.inputTokens?.toLocaleString() ?? t("usage.notReported")}
|
size={40}
|
||||||
</Text>
|
thickness={4}
|
||||||
</div>
|
roundCaps
|
||||||
<div>
|
sections={
|
||||||
<Text size="xs" c="dimmed">
|
hasContextWindow ? [{ value: contextPercentage, color: getContextColor(contextPercentage) }] : []
|
||||||
{t("usage.output")}
|
}
|
||||||
</Text>
|
label={
|
||||||
<Text size="sm" fw={600}>
|
<Text className={classes.contextMeterLabel} ta="center" fw={700}>
|
||||||
{usage?.outputTokens?.toLocaleString() ?? t("usage.notReported")}
|
{hasContextWindow ? `${contextPercentage}%` : "–"}
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
}
|
||||||
<div>
|
/>
|
||||||
<Text size="xs" c="dimmed">
|
</UnstyledButton>
|
||||||
{t("usage.cached")}
|
</Popover.Target>
|
||||||
</Text>
|
<Popover.Dropdown className={classes.telemetryPopover}>
|
||||||
<Text size="sm" fw={600}>
|
<Stack gap="sm">
|
||||||
{usage?.cachedInputTokens?.toLocaleString() ?? t("usage.notReported")}
|
<Group justify="space-between" gap="xs">
|
||||||
</Text>
|
<div>
|
||||||
</div>
|
<Text size="sm" fw={700}>
|
||||||
<div>
|
{t("usage.contextWindow")}
|
||||||
<Text size="xs" c="dimmed">
|
|
||||||
{t("usage.reasoning")}
|
|
||||||
</Text>
|
|
||||||
<Text size="sm" fw={600}>
|
|
||||||
{usage?.reasoningTokens?.toLocaleString() ?? t("usage.notReported")}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Text size="xs" c="dimmed">
|
|
||||||
{t("usage.cacheWrite")}
|
|
||||||
</Text>
|
|
||||||
<Text size="sm" fw={600}>
|
|
||||||
{usage?.cacheWriteTokens?.toLocaleString() ?? t("usage.notReported")}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
</Box>
|
|
||||||
<Divider />
|
|
||||||
<Group gap="lg" align="flex-start">
|
|
||||||
<div>
|
|
||||||
<Text size="xs" c="dimmed">
|
|
||||||
{t("usage.firstOutput")}
|
|
||||||
</Text>
|
|
||||||
<Text size="sm" fw={600}>
|
|
||||||
{telemetry.timeToFirstOutputMs !== undefined
|
|
||||||
? formatDuration(telemetry.timeToFirstOutputMs)
|
|
||||||
: t("usage.notReported")}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Text size="xs" c="dimmed">
|
|
||||||
{t("usage.cost")}
|
|
||||||
</Text>
|
|
||||||
<Text size="sm" fw={600}>
|
|
||||||
{telemetry.cost !== undefined ? formatCost(telemetry.cost) : t("usage.notReported")}
|
|
||||||
</Text>
|
|
||||||
{telemetry.costType && (
|
|
||||||
<Text size="xs" c="dimmed">
|
|
||||||
{t(`usage.${telemetry.costType}`)}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{telemetry.upstreamCost !== undefined && (
|
|
||||||
<div>
|
|
||||||
<Text size="xs" c="dimmed">
|
|
||||||
{t("usage.upstreamCost")}
|
|
||||||
</Text>
|
|
||||||
<Text size="sm" fw={600}>
|
|
||||||
{formatCost(telemetry.upstreamCost)}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{telemetry.finishReason && (
|
|
||||||
<div>
|
|
||||||
<Text size="xs" c="dimmed">
|
|
||||||
{t("usage.finishReason")}
|
|
||||||
</Text>
|
|
||||||
<Text size="sm" fw={600}>
|
|
||||||
{telemetry.finishReason}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
{telemetry.steps.length > 0 && (
|
|
||||||
<Stack gap={4}>
|
|
||||||
<Text size="xs" fw={600}>
|
|
||||||
{t("usage.agentSteps")}
|
|
||||||
</Text>
|
|
||||||
{telemetry.steps.map((step) => (
|
|
||||||
<Box key={step.index} className={classes.stepRow}>
|
|
||||||
<Group justify="space-between" gap="xs">
|
|
||||||
<Text size="xs">
|
|
||||||
{t("usage.step", { number: step.index })}
|
|
||||||
{step.routedProvider ? ` · ${step.routedProvider}` : ""}
|
|
||||||
</Text>
|
</Text>
|
||||||
<Text size="xs" c="dimmed">
|
<Text size="xs" c="dimmed">
|
||||||
{formatDuration(step.durationMs)}
|
{t("usage.requestDetails")}
|
||||||
{step.outputTokensPerSecond !== undefined
|
|
||||||
? ` · ${step.outputTokensPerSecond.toFixed(1)} tok/s`
|
|
||||||
: ""}
|
|
||||||
{step.cost !== undefined ? ` · ${formatCost(step.cost)}` : ""}
|
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</div>
|
||||||
{step.generationId && (
|
<Badge size="sm" variant="light" color={getContextColor(contextPercentage)}>
|
||||||
<Text size="xs" c="dimmed" className={classes.generationId} title={step.generationId}>
|
{hasContextWindow ? `${contextPercentage}%` : t("usage.notReported")}
|
||||||
{t("usage.generation")}: {step.generationId}
|
</Badge>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Box className={classes.contextStats}>
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.used")}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
<Text size="sm" fw={600}>
|
||||||
|
{telemetry.contextUsed?.toLocaleString() ?? t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.remaining")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{contextRemaining?.toLocaleString() ?? t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.capacity")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{telemetry.contextLength?.toLocaleString() ?? t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
</Box>
|
</Box>
|
||||||
))}
|
|
||||||
</Stack>
|
<Divider />
|
||||||
)}
|
<Box className={classes.usageGrid}>
|
||||||
</Stack>
|
<div>
|
||||||
</details>
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.input")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{usage?.inputTokens?.toLocaleString() ?? t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.output")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{usage?.outputTokens?.toLocaleString() ?? t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.cached")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{usage?.cachedInputTokens?.toLocaleString() ?? t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.reasoning")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{usage?.reasoningTokens?.toLocaleString() ?? t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.cacheWrite")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{usage?.cacheWriteTokens?.toLocaleString() ?? t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.tokens")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{usage?.totalTokens?.toLocaleString() ?? t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
<Group gap="lg" align="flex-start">
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.firstOutput")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{telemetry.timeToFirstOutputMs !== undefined
|
||||||
|
? formatDuration(telemetry.timeToFirstOutputMs)
|
||||||
|
: t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.cost")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{telemetry.cost !== undefined ? formatCost(telemetry.cost) : t("usage.notReported")}
|
||||||
|
</Text>
|
||||||
|
{telemetry.costType && (
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t(`usage.${telemetry.costType}`)}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{telemetry.upstreamCost !== undefined && (
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.upstreamCost")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{formatCost(telemetry.upstreamCost)}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{telemetry.finishReason && (
|
||||||
|
<div>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t("usage.finishReason")}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={600}>
|
||||||
|
{telemetry.finishReason}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
{telemetry.steps.length > 0 && (
|
||||||
|
<Stack gap={4}>
|
||||||
|
<Text size="xs" fw={600}>
|
||||||
|
{t("usage.agentSteps")}
|
||||||
|
</Text>
|
||||||
|
{telemetry.steps.map((step) => (
|
||||||
|
<Box key={step.index} className={classes.stepRow}>
|
||||||
|
<Group justify="space-between" gap="xs">
|
||||||
|
<Text size="xs">
|
||||||
|
{t("usage.step", { number: step.index })}
|
||||||
|
{step.routedProvider ? ` · ${step.routedProvider}` : ""}
|
||||||
|
</Text>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{formatDuration(step.durationMs)}
|
||||||
|
{step.outputTokensPerSecond !== undefined
|
||||||
|
? ` · ${step.outputTokensPerSecond.toFixed(1)} tok/s`
|
||||||
|
: ""}
|
||||||
|
{step.cost !== undefined ? ` · ${formatCost(step.cost)}` : ""}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
{step.generationId && (
|
||||||
|
<Text size="xs" c="dimmed" className={classes.generationId} title={step.generationId}>
|
||||||
|
{t("usage.generation")}: {step.generationId}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</Popover.Dropdown>
|
||||||
|
</Popover>
|
||||||
|
</Group>
|
||||||
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1123,18 +1199,6 @@ const Composer = () => {
|
|||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</ComposerPrimitive.AddAttachment>
|
</ComposerPrimitive.AddAttachment>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip label={t("dictate")}>
|
|
||||||
<ComposerPrimitive.Dictate asChild>
|
|
||||||
<ActionIcon variant="subtle" color="gray" size="lg" aria-label={t("dictate")}>
|
|
||||||
<IconMicrophone size={17} />
|
|
||||||
</ActionIcon>
|
|
||||||
</ComposerPrimitive.Dictate>
|
|
||||||
</Tooltip>
|
|
||||||
<ComposerPrimitive.StopDictation asChild>
|
|
||||||
<ActionIcon variant="light" color="red" size="lg" aria-label={t("stopDictation")}>
|
|
||||||
<IconPlayerStop size={17} />
|
|
||||||
</ActionIcon>
|
|
||||||
</ComposerPrimitive.StopDictation>
|
|
||||||
</Group>
|
</Group>
|
||||||
<ComposerPrimitive.Input
|
<ComposerPrimitive.Input
|
||||||
className={classes.composerInput}
|
className={classes.composerInput}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import type {
|
|||||||
} from "@assistant-ui/react";
|
} from "@assistant-ui/react";
|
||||||
import {
|
import {
|
||||||
AssistantRuntimeProvider,
|
AssistantRuntimeProvider,
|
||||||
WebSpeechDictationAdapter,
|
|
||||||
WebSpeechSynthesisAdapter,
|
|
||||||
defineToolkit,
|
defineToolkit,
|
||||||
Tools,
|
Tools,
|
||||||
useAui,
|
useAui,
|
||||||
@@ -278,11 +276,6 @@ const AssistantThreadRuntime = () => {
|
|||||||
() => createAssistantAttachmentAdapter(modelCapabilities?.imageInput !== "unsupported"),
|
() => createAssistantAttachmentAdapter(modelCapabilities?.imageInput !== "unsupported"),
|
||||||
[modelCapabilities?.imageInput],
|
[modelCapabilities?.imageInput],
|
||||||
);
|
);
|
||||||
const speech = useMemo(() => new WebSpeechSynthesisAdapter(), []);
|
|
||||||
const dictation = useMemo(
|
|
||||||
() => (WebSpeechDictationAdapter.isSupported() ? new WebSpeechDictationAdapter() : undefined),
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
const feedback = useMemo(
|
const feedback = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
submit: ({ message, type }: { message: ThreadMessage; type: "positive" | "negative" }) => {
|
submit: ({ message, type }: { message: ThreadMessage; type: "positive" | "negative" }) => {
|
||||||
@@ -311,8 +304,6 @@ const AssistantThreadRuntime = () => {
|
|||||||
adapters: {
|
adapters: {
|
||||||
history,
|
history,
|
||||||
attachments,
|
attachments,
|
||||||
speech,
|
|
||||||
...(dictation ? { dictation } : {}),
|
|
||||||
feedback,
|
feedback,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2032,14 +2032,10 @@
|
|||||||
"cancelEdit": "Cancel",
|
"cancelEdit": "Cancel",
|
||||||
"updateMessage": "Update message",
|
"updateMessage": "Update message",
|
||||||
"regenerate": "Regenerate response",
|
"regenerate": "Regenerate response",
|
||||||
"speak": "Read response aloud",
|
|
||||||
"stopSpeaking": "Stop reading",
|
|
||||||
"helpful": "Helpful",
|
"helpful": "Helpful",
|
||||||
"notHelpful": "Not helpful",
|
"notHelpful": "Not helpful",
|
||||||
"feedbackError": "Your feedback could not be saved. Try again.",
|
"feedbackError": "Your feedback could not be saved. Try again.",
|
||||||
"exportMarkdown": "Export as Markdown",
|
"exportMarkdown": "Export as Markdown",
|
||||||
"dictate": "Dictate message",
|
|
||||||
"stopDictation": "Stop dictation",
|
|
||||||
"reasoning": "Reasoning",
|
"reasoning": "Reasoning",
|
||||||
"previousResponse": "Previous response",
|
"previousResponse": "Previous response",
|
||||||
"nextResponse": "Next response",
|
"nextResponse": "Next response",
|
||||||
@@ -2072,6 +2068,10 @@
|
|||||||
"usage": {
|
"usage": {
|
||||||
"tokens": "tokens",
|
"tokens": "tokens",
|
||||||
"contextWindow": "Context window",
|
"contextWindow": "Context window",
|
||||||
|
"requestDetails": "Request details",
|
||||||
|
"used": "Used",
|
||||||
|
"remaining": "Remaining",
|
||||||
|
"capacity": "Capacity",
|
||||||
"input": "Input",
|
"input": "Input",
|
||||||
"output": "Output",
|
"output": "Output",
|
||||||
"cached": "Cached input",
|
"cached": "Cached input",
|
||||||
|
|||||||
Reference in new issue
Block a user