@kwirthmagnify/kwirth-common-ai 0.5.66 → 0.5.67
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/front.js +41 -27
- package/package.json +1 -1
package/dist/front.js
CHANGED
|
@@ -95,38 +95,47 @@ const UsageLimitsEditor = (props) => {
|
|
|
95
95
|
props.onChange(Object.assign(Object.assign({}, limits), { [unit]: Object.assign(Object.assign({}, current), change) }));
|
|
96
96
|
};
|
|
97
97
|
const numberOrUndefined = (text) => text === '' ? undefined : +text;
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
/*
|
|
99
|
+
Compact on purpose. These rows used to be three paragraphs of prose and four full-height fields,
|
|
100
|
+
which pushed the Add/Update button below the fold — and that button is the one that applies the
|
|
101
|
+
form to the list, so a limit typed above it looked saved and was not. Height here is not a
|
|
102
|
+
cosmetic matter: it is what decides whether the control that commits the edit can be seen.
|
|
103
|
+
|
|
104
|
+
What was dropped is repetition, not meaning. The one thing an admin must not learn the hard way
|
|
105
|
+
— that a tokens or cost ceiling stops the NEXT call, because the amount is only known once the
|
|
106
|
+
model has answered — is still said, in one line, where the limit is set.
|
|
107
|
+
*/
|
|
108
|
+
return (react_1.default.createElement(material_1.Stack, { direction: 'column', spacing: 0.5, sx: { mt: 0.5 } },
|
|
109
|
+
react_1.default.createElement(material_1.Typography, { variant: 'caption', color: 'text.secondary' },
|
|
100
110
|
"Stop spending on ",
|
|
101
111
|
react_1.default.createElement("b", null, props.subject),
|
|
102
|
-
"
|
|
112
|
+
": a call goes out only if ",
|
|
103
113
|
react_1.default.createElement("b", null, "no"),
|
|
104
|
-
" enabled ceiling is reached \
|
|
105
|
-
react_1.default.createElement(material_1.Typography, { variant: 'caption', color: 'text.secondary' },
|
|
106
|
-
"\u26A0\uFE0F A ",
|
|
114
|
+
" enabled ceiling is reached. \u26A0\uFE0F A ",
|
|
107
115
|
react_1.default.createElement("b", null, "calls"),
|
|
108
|
-
" ceiling stops the call that would exceed it
|
|
109
|
-
react_1.default.createElement("b", null, "
|
|
110
|
-
" and
|
|
111
|
-
react_1.default.createElement("b", null, "cost"),
|
|
112
|
-
" are only known
|
|
116
|
+
" ceiling stops the call that would exceed it; ",
|
|
117
|
+
react_1.default.createElement("b", null, "tokens"),
|
|
118
|
+
" and",
|
|
119
|
+
react_1.default.createElement("b", null, " cost"),
|
|
120
|
+
" are only known after the answer, so those stop the ",
|
|
113
121
|
react_1.default.createElement("b", null, "next"),
|
|
114
|
-
"
|
|
122
|
+
" one."),
|
|
115
123
|
props.usage && props.durable === false &&
|
|
116
124
|
react_1.default.createElement(material_1.Typography, { variant: 'caption', color: 'warning.main' },
|
|
117
|
-
"\u26A0\uFE0F
|
|
125
|
+
"\u26A0\uFE0F Counters kept ",
|
|
118
126
|
react_1.default.createElement("b", null, "in memory"),
|
|
119
|
-
"
|
|
127
|
+
" (no SQL): they reset on every restart, and so do these limits."),
|
|
120
128
|
USAGE_ROWS.map(({ unit, label, of }) => {
|
|
121
129
|
var _a, _b, _c, _d, _e;
|
|
122
130
|
const w = (_a = limits[unit]) !== null && _a !== void 0 ? _a : { enabled: false };
|
|
123
131
|
// What has been spent goes in the helper text of its own window: next to the number it is
|
|
124
|
-
// measured against, which is the only place it answers anything.
|
|
132
|
+
// measured against, which is the only place it answers anything. It only costs height when
|
|
133
|
+
// there IS usage, which is when it earns it.
|
|
125
134
|
const spent = (amounts) => amounts ? `${formatSpent(of(amounts))} so far` : undefined;
|
|
126
135
|
return (react_1.default.createElement(material_1.Stack, { key: unit, direction: 'row', spacing: 1, alignItems: 'flex-start' },
|
|
127
|
-
react_1.default.createElement(material_1.FormControlLabel, { sx: { width: '
|
|
128
|
-
react_1.default.createElement(material_1.TextField, { value: (_b = w.daily) !== null && _b !== void 0 ? _b : '', onChange: e => patch(unit, { daily: numberOrUndefined(e.target.value) }), label: 'Per day', variant: 'standard', type: 'number', fullWidth: true, disabled: props.disabled || !w.enabled, inputProps: { min: 0 }, placeholder: 'no limit', helperText: spent((_c = props.usage) === null || _c === void 0 ? void 0 : _c.daily) }),
|
|
129
|
-
react_1.default.createElement(material_1.TextField, { value: (_d = w.monthly) !== null && _d !== void 0 ? _d : '', onChange: e => patch(unit, { monthly: numberOrUndefined(e.target.value) }), label: 'Per month', variant: 'standard', type: 'number', fullWidth: true, disabled: props.disabled || !w.enabled, inputProps: { min: 0 }, placeholder: 'no limit', helperText: spent((_e = props.usage) === null || _e === void 0 ? void 0 : _e.monthly) })));
|
|
136
|
+
react_1.default.createElement(material_1.FormControlLabel, { sx: { width: '150px', mr: 0, mt: 0.5 }, control: react_1.default.createElement(material_1.Checkbox, { size: 'small', checked: !!w.enabled, disabled: props.disabled, onChange: e => patch(unit, { enabled: e.target.checked }) }), label: react_1.default.createElement(material_1.Typography, { variant: 'body2' }, label) }),
|
|
137
|
+
react_1.default.createElement(material_1.TextField, { value: (_b = w.daily) !== null && _b !== void 0 ? _b : '', onChange: e => patch(unit, { daily: numberOrUndefined(e.target.value) }), label: 'Per day', variant: 'standard', type: 'number', fullWidth: true, size: 'small', disabled: props.disabled || !w.enabled, inputProps: { min: 0 }, placeholder: 'no limit', helperText: spent((_c = props.usage) === null || _c === void 0 ? void 0 : _c.daily), FormHelperTextProps: { sx: { mt: 0 } } }),
|
|
138
|
+
react_1.default.createElement(material_1.TextField, { value: (_d = w.monthly) !== null && _d !== void 0 ? _d : '', onChange: e => patch(unit, { monthly: numberOrUndefined(e.target.value) }), label: 'Per month', variant: 'standard', type: 'number', fullWidth: true, size: 'small', disabled: props.disabled || !w.enabled, inputProps: { min: 0 }, placeholder: 'no limit', helperText: spent((_e = props.usage) === null || _e === void 0 ? void 0 : _e.monthly), FormHelperTextProps: { sx: { mt: 0 } } })));
|
|
130
139
|
})));
|
|
131
140
|
};
|
|
132
141
|
const LlmSelector = ({ llms, value, onChange, label = 'LLM', size = 'small', fullWidth = true }) => {
|
|
@@ -209,11 +218,16 @@ const AiConfigLlm = (props) => {
|
|
|
209
218
|
setLlms(llms.filter((_, i) => i !== selectedIndex));
|
|
210
219
|
onNew();
|
|
211
220
|
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
221
|
+
/*
|
|
222
|
+
Height follows the content instead of being pinned at 78vh. A fixed height is what put the
|
|
223
|
+
Add/Update button below the fold on a short screen: the form grew, the dialog did not, and the
|
|
224
|
+
control that applies the form to the list scrolled out of sight.
|
|
225
|
+
*/
|
|
226
|
+
return (react_1.default.createElement(material_1.Dialog, { open: true, onClose: () => props.onClose(undefined), PaperProps: { sx: { width: '80vw', maxWidth: '900px', height: 'auto', maxHeight: '90vh' } } },
|
|
227
|
+
react_1.default.createElement(material_1.DialogTitle, { sx: { pb: 1 } }, "AI \u2014 LLM config"),
|
|
228
|
+
react_1.default.createElement(material_1.DialogContent, { style: { display: 'flex' } },
|
|
215
229
|
react_1.default.createElement(material_1.Box, { sx: { flex: 1, display: 'flex', flexDirection: 'column', boxSizing: 'border-box', maxWidth: '40%' } },
|
|
216
|
-
react_1.default.createElement(material_1.Box, { sx: { flex: 1, overflowY: 'auto', overflowX: 'hidden' } },
|
|
230
|
+
react_1.default.createElement(material_1.Box, { sx: { flex: 1, overflowY: 'auto', overflowX: 'hidden', maxHeight: '70vh' } },
|
|
217
231
|
react_1.default.createElement(material_1.List, { sx: { flexGrow: 1, mr: 2, width: '100%' } }, llms.map((llm, index) => (react_1.default.createElement(material_1.ListItemButton, { key: index, selected: selectedIndex === index, onClick: () => onLlmSelected(index) },
|
|
218
232
|
react_1.default.createElement(material_1.Stack, { direction: 'column' },
|
|
219
233
|
react_1.default.createElement(material_1.Typography, { sx: { fontWeight: selectedIndex === index ? 'bold' : 'normal' } }, llm.id),
|
|
@@ -233,10 +247,10 @@ const AiConfigLlm = (props) => {
|
|
|
233
247
|
react_1.default.createElement(material_1.InputLabel, null, "Model"),
|
|
234
248
|
react_1.default.createElement(material_1.Select, { value: model, onChange: e => setModel(e.target.value), variant: 'standard', fullWidth: true, displayEmpty: true }, (_b = props.providers.find(p => p.name === provider)) === null || _b === void 0 ? void 0 : _b.models.map((m, i) => (react_1.default.createElement(material_1.MenuItem, { key: i, value: m.id }, m.name))))))
|
|
235
249
|
: (react_1.default.createElement(material_1.TextField, { value: model, onChange: e => setModel(e.target.value), label: 'Model ID', placeholder: 'e.g. claude-sonnet-4-5, glm-5.2', variant: 'standard', fullWidth: true })),
|
|
236
|
-
react_1.default.createElement(material_1.TextField, { value: temperature, onChange: e => setTemperature(+e.target.value), label: 'Model temperature', variant: 'standard', type: 'number', fullWidth: true }),
|
|
237
250
|
react_1.default.createElement(material_1.Stack, { direction: 'row', spacing: 1 },
|
|
238
|
-
react_1.default.createElement(material_1.TextField, { value:
|
|
239
|
-
react_1.default.createElement(material_1.TextField, { value:
|
|
251
|
+
react_1.default.createElement(material_1.TextField, { value: temperature, onChange: e => setTemperature(+e.target.value), label: 'Temperature', variant: 'standard', type: 'number', sx: { width: '28%' } }),
|
|
252
|
+
react_1.default.createElement(material_1.TextField, { value: inputCostPerMillion, onChange: e => setInputCostPerMillion(e.target.value === '' ? '' : +e.target.value), label: 'Input cost /M', variant: 'standard', type: 'number', fullWidth: true, inputProps: { min: 0, step: 0.01 } }),
|
|
253
|
+
react_1.default.createElement(material_1.TextField, { value: outputCostPerMillion, onChange: e => setOutputCostPerMillion(e.target.value === '' ? '' : +e.target.value), label: 'Output cost /M', variant: 'standard', type: 'number', fullWidth: true, inputProps: { min: 0, step: 0.01 } })),
|
|
240
254
|
react_1.default.createElement(material_1.Stack, { direction: 'row', alignItems: 'center' },
|
|
241
255
|
react_1.default.createElement(material_1.Typography, { flex: 1 }, "Use provider API Key (or enter a specific one)"),
|
|
242
256
|
react_1.default.createElement(material_1.Checkbox, { checked: useProviderKey, onChange: e => setUseProviderKey(e.target.checked) })),
|
|
@@ -355,7 +369,7 @@ const AiConfigProvider = (props) => {
|
|
|
355
369
|
react_1.default.createElement(material_1.DialogTitle, null, "AI \u2014 Provider config"),
|
|
356
370
|
react_1.default.createElement(material_1.DialogContent, { style: { display: 'flex' } },
|
|
357
371
|
react_1.default.createElement(material_1.Box, { sx: { flex: 1, display: 'flex', flexDirection: 'column', boxSizing: 'border-box', maxWidth: '30%' } },
|
|
358
|
-
react_1.default.createElement(material_1.Box, { sx: { flex: 1, overflowY: 'auto', maxHeight: '
|
|
372
|
+
react_1.default.createElement(material_1.Box, { sx: { flex: 1, overflowY: 'auto', maxHeight: '70vh' } },
|
|
359
373
|
react_1.default.createElement(material_1.List, { sx: { mr: 1 } }, providers.map((p, index) => {
|
|
360
374
|
var _a;
|
|
361
375
|
return (react_1.default.createElement(material_1.ListItemButton, { key: index, selected: selectedIndex === index, onClick: () => onProviderSelected(p, index) },
|
|
@@ -366,7 +380,7 @@ const AiConfigProvider = (props) => {
|
|
|
366
380
|
" models loaded"))));
|
|
367
381
|
})))),
|
|
368
382
|
react_1.default.createElement(material_1.Box, { sx: { flex: 1, display: 'flex', alignItems: 'start', padding: '24px' } },
|
|
369
|
-
react_1.default.createElement(material_1.Stack, { spacing:
|
|
383
|
+
react_1.default.createElement(material_1.Stack, { spacing: 2, style: { width: '100%' } },
|
|
370
384
|
react_1.default.createElement(material_1.TextField, { label: 'Name', variant: 'standard', fullWidth: true, placeholder: 'e.g. huawei-maas, openai-prod', value: providerName, onChange: e => setProviderName(e.target.value), helperText: 'Unique identifier for this provider instance' }),
|
|
371
385
|
react_1.default.createElement(material_1.FormControl, { variant: 'standard', sx: { width: '100%' } },
|
|
372
386
|
react_1.default.createElement(material_1.InputLabel, null, "Type"),
|