aura-web/src/pages/chat/components/messages/MetaViews.tsx

116 lines
3.9 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

import { Collapse, Tag } from 'antd';
import type { RetrievedSnippet, ToolCallTrace } from '../../../../api';
import Markdown from '../../../../components/Markdown';
export function ReasoningView({ reasoning }: { reasoning: string }) {
return (
<Collapse
size="small"
ghost
items={[
{
key: 'reasoning',
label: <span style={{ fontSize: 12, color: 'var(--color-text-secondary)' }}>🧠 </span>,
children: (
<div style={{ fontSize: 12, color: 'var(--color-text-secondary)', lineHeight: 1.6, maxHeight: 240, overflow: 'auto' }}>
<Markdown>{reasoning}</Markdown>
</div>
)
}
]}
/>
);
}
export function RetrievedView({ retrieved }: { retrieved: RetrievedSnippet[] }) {
return (
<Collapse
size="small"
ghost
items={[
{
key: 'rag',
label: <span style={{ fontSize: 12, color: '#6366f1' }}>🔍 RAG ({retrieved.length})</span>,
children: (
<div style={{ fontSize: 12 }}>
{retrieved.map((r, i) => (
<div
key={i}
style={{
padding: 8,
background: '#f6f8ff',
borderRadius: 6,
marginBottom: 6,
borderLeft: '3px solid #6366f1'
}}
>
<div style={{ color: '#6366f1', fontWeight: 600, marginBottom: 4 }}>
📄 {r.fileName} · #{r.chunkIndex} · score {r.score.toFixed(3)}
</div>
<div style={{ color: '#374151', whiteSpace: 'pre-wrap' }}>
{r.preview}
{r.preview.length >= 200 ? '…' : ''}
</div>
</div>
))}
</div>
)
}
]}
/>
);
}
export function ToolCallView({ calls, liveStyle }: { calls: ToolCallTrace[]; liveStyle?: boolean }) {
return (
<Collapse
size="small"
ghost
defaultActiveKey={liveStyle ? ['tc'] : undefined}
items={[
{
key: 'tc',
label: <span style={{ fontSize: 12, color: '#f97316' }}>🛠 ({calls.length})</span>,
children: (
<div style={{ fontSize: 12 }}>
{calls.map((t, i) => {
const isPending = (t.result as any)?.pending;
const isFailed = t.result?.ok === false;
return (
<div
key={i}
style={{
padding: 8,
background: '#fff7ed',
borderRadius: 6,
marginBottom: 6,
borderLeft: '3px solid #f97316'
}}
>
<div style={{ color: '#c2410c', fontWeight: 600, marginBottom: 4 }}>
{t.name} {isPending && <Tag color="processing"></Tag>}
{!isPending && t.result?.durationMs != null && <Tag>{t.result.durationMs}ms</Tag>}
{isFailed && <Tag color="error"></Tag>}
</div>
<div style={{ color: '#6b7280' }}>
<b>args:</b> {JSON.stringify(t.args)}
</div>
{!isPending && (
<div style={{ color: '#374151', marginTop: 4 }}>
<b>result:</b>{' '}
<code style={{ wordBreak: 'break-all' }}>
{JSON.stringify(t.result?.result ?? t.result?.error ?? t.result).slice(0, 500)}
</code>
</div>
)}
</div>
);
})}
</div>
)
}
]}
/>
);
}