@theoremjs/react 0.3.4-next.618.g0612421 → 0.3.4-next.620.g9fe1aff
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 +3 -3
- package/ui/TraceSpanDetail.js +38 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/react",
|
|
3
|
-
"version": "0.3.4-next.
|
|
3
|
+
"version": "0.3.4-next.620.g9fe1aff",
|
|
4
4
|
"description": "React bindings for Theorem: headless hooks + transport, an Astryx chat UI, and a Web-standard server handler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@stylexjs/stylex": "0.19.0",
|
|
61
61
|
"react": "^19.0.0",
|
|
62
62
|
"react-dom": "^19.0.0",
|
|
63
|
-
"@theoremjs/agents": "^0.3.4-next.
|
|
64
|
-
"@theoremjs/web": "^0.3.4-next.
|
|
63
|
+
"@theoremjs/agents": "^0.3.4-next.620.g9fe1aff",
|
|
64
|
+
"@theoremjs/web": "^0.3.4-next.620.g9fe1aff"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@astryxdesign/core": {
|
package/ui/TraceSpanDetail.js
CHANGED
|
@@ -137,13 +137,49 @@ function ProsePanel({ attribute, text }) {
|
|
|
137
137
|
return null;
|
|
138
138
|
return (_jsx(PanePanel, { ...label(attribute), children: _jsx(Prose, { text: text }) }));
|
|
139
139
|
}
|
|
140
|
+
/** Content folded under a title, with its count when it is a list. */
|
|
141
|
+
function Folded({ title, count, children, }) {
|
|
142
|
+
return (_jsx(Collapsible, { defaultIsOpen: false, trigger: _jsx(Text, { weight: "medium", children: count === undefined ? title : `${title} · ${String(count)}` }), children: _jsx(Card, { padding: 3, variant: "muted", style: { background: 'var(--color-background-surface)' }, children: children }) }));
|
|
143
|
+
}
|
|
144
|
+
/** The system prompt a model call was sent, part by part. */
|
|
145
|
+
function SystemInstructions({ node }) {
|
|
146
|
+
const parts = inlineContent(node.record, node.span.attributes['gen_ai.system_instructions']);
|
|
147
|
+
const texts = (Array.isArray(parts) ? parts.filter(isObject) : []).flatMap((part) => typeof part.content === 'string' && part.content ? [part.content] : []);
|
|
148
|
+
if (texts.length === 0)
|
|
149
|
+
return null;
|
|
150
|
+
return (_jsx(Folded, { title: label('gen_ai.system_instructions').title, children: _jsx(VStack, { gap: 3, children: keyedByContent(texts, (text) => text).map(({ item: text, key }) => (_jsx(Prose, { text: text }, key))) }) }));
|
|
151
|
+
}
|
|
152
|
+
/** The tools a model call was offered: each one's name, what it does, and what it takes. */
|
|
153
|
+
function ToolDefinitions({ node }) {
|
|
154
|
+
const value = storedValue(node, 'gen_ai.tool.definitions');
|
|
155
|
+
const tools = Array.isArray(value) ? value.filter(isObject) : [];
|
|
156
|
+
if (tools.length === 0)
|
|
157
|
+
return null;
|
|
158
|
+
return (_jsx(Folded, { title: label('gen_ai.tool.definitions').title, count: tools.length, children: _jsx(VStack, { gap: 3, children: keyedByContent(tools, (tool) => String(tool.name)).map(({ item: tool, key }) => (_jsxs(VStack, { gap: 1, children: [_jsx(Text, { weight: "medium", children: String(tool.name ?? '') }), typeof tool.description === 'string' ? (_jsx(Text, { color: "secondary", children: tool.description })) : null, tool.parameters === undefined ? null : _jsx(ShapedData, { value: tool.parameters })] }, key))) }) }));
|
|
159
|
+
}
|
|
160
|
+
/** What a model call was given besides its messages: the system prompt and the tools. */
|
|
161
|
+
function CallContext({ node }) {
|
|
162
|
+
return (_jsxs(_Fragment, { children: [_jsx(SystemInstructions, { node: node }), _jsx(ToolDefinitions, { node: node })] }));
|
|
163
|
+
}
|
|
164
|
+
/** A turn's first model call: the one whose system prompt and tools the turn opened with. */
|
|
165
|
+
function firstCall(node) {
|
|
166
|
+
for (const child of node.children) {
|
|
167
|
+
if ('gen_ai.system_instructions' in child.span.attributes)
|
|
168
|
+
return child;
|
|
169
|
+
const found = firstCall(child);
|
|
170
|
+
if (found)
|
|
171
|
+
return found;
|
|
172
|
+
}
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
140
175
|
function TurnIO({ node }) {
|
|
141
|
-
|
|
176
|
+
const call = firstCall(node);
|
|
177
|
+
return (_jsxs(_Fragment, { children: [call ? _jsx(CallContext, { node: call }) : null, _jsx(ProsePanel, { attribute: "gen_ai.input.messages", text: messageText(node, 'gen_ai.input.messages', 'user') }), _jsx(ProsePanel, { attribute: "gen_ai.output.messages", text: messageText(node, 'gen_ai.output.messages', 'assistant') })] }));
|
|
142
178
|
}
|
|
143
179
|
function CallIO({ node }) {
|
|
144
180
|
const input = messagesOf(node, 'gen_ai.input.messages');
|
|
145
181
|
const output = messagesOf(node, 'gen_ai.output.messages');
|
|
146
|
-
return (_jsxs(_Fragment, { children: [output.length > 0 ? (_jsx(PanePanel, { ...label('gen_ai.output.messages'), children: _jsx(MessageList, { messages: output }) })) : null, input.length > 0 ? (_jsx(
|
|
182
|
+
return (_jsxs(_Fragment, { children: [output.length > 0 ? (_jsx(PanePanel, { ...label('gen_ai.output.messages'), children: _jsx(MessageList, { messages: output }) })) : null, _jsx(CallContext, { node: node }), input.length > 0 ? (_jsx(Folded, { title: label('gen_ai.input.messages').title, count: input.length, children: _jsx(MessageList, { messages: input }) })) : null] }));
|
|
147
183
|
}
|
|
148
184
|
function ToolIO({ node }) {
|
|
149
185
|
const { attributes } = node.span;
|