@kwirthmagnify/kwirth-common-ai 0.5.6 → 0.5.8

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 CHANGED
@@ -60,7 +60,10 @@ const AiConfigLlm = (props) => {
60
60
  const [temperature, setTemperature] = (0, react_1.useState)(0);
61
61
  const [useProviderKey, setUseProviderKey] = (0, react_1.useState)(true);
62
62
  const [key, setKey] = (0, react_1.useState)('');
63
+ const [inputCostPerMillion, setInputCostPerMillion] = (0, react_1.useState)(0);
64
+ const [outputCostPerMillion, setOutputCostPerMillion] = (0, react_1.useState)(0);
63
65
  const onLlmSelected = (index) => {
66
+ var _a, _b;
64
67
  const l = llms[index];
65
68
  if (l) {
66
69
  setId(l.id);
@@ -69,6 +72,8 @@ const AiConfigLlm = (props) => {
69
72
  setTemperature(l.temperature);
70
73
  setUseProviderKey(l.useProviderKey);
71
74
  setKey(l.key);
75
+ setInputCostPerMillion((_a = l.inputCostPerMillion) !== null && _a !== void 0 ? _a : 0);
76
+ setOutputCostPerMillion((_b = l.outputCostPerMillion) !== null && _b !== void 0 ? _b : 0);
72
77
  setSelectedIndex(index);
73
78
  }
74
79
  };
@@ -80,9 +85,11 @@ const AiConfigLlm = (props) => {
80
85
  setTemperature(0);
81
86
  setUseProviderKey(false);
82
87
  setKey('');
88
+ setInputCostPerMillion(0);
89
+ setOutputCostPerMillion(0);
83
90
  };
84
91
  const onAdd = () => {
85
- const llm = { id, provider, model, temperature, useProviderKey, key };
92
+ const llm = { id, provider, model, temperature, useProviderKey, key, inputCostPerMillion: inputCostPerMillion === '' ? 0 : inputCostPerMillion, outputCostPerMillion: outputCostPerMillion === '' ? 0 : outputCostPerMillion };
86
93
  const updated = [...llms];
87
94
  if (selectedIndex !== null)
88
95
  updated[selectedIndex] = llm;
@@ -97,7 +104,7 @@ const AiConfigLlm = (props) => {
97
104
  setLlms(llms.filter((_, i) => i !== selectedIndex));
98
105
  onNew();
99
106
  };
100
- return (react_1.default.createElement(material_1.Dialog, { open: true, onClose: () => props.onClose(undefined), PaperProps: { sx: { width: '80vw', maxWidth: '800px', height: '55vh' } } },
107
+ return (react_1.default.createElement(material_1.Dialog, { open: true, onClose: () => props.onClose(undefined), PaperProps: { sx: { width: '80vw', maxWidth: '800px', height: '78vh' } } },
101
108
  react_1.default.createElement(material_1.DialogTitle, null, "AI \u2014 LLM config"),
102
109
  react_1.default.createElement(material_1.DialogContent, { style: { display: 'flex', height: '100%' } },
103
110
  react_1.default.createElement(material_1.Box, { sx: { flex: 1, display: 'flex', flexDirection: 'column', boxSizing: 'border-box', maxWidth: '40%' } },
@@ -117,6 +124,9 @@ const AiConfigLlm = (props) => {
117
124
  react_1.default.createElement(material_1.InputLabel, null, "Model"),
118
125
  react_1.default.createElement(material_1.Select, { value: model, onChange: e => setModel(e.target.value), variant: 'standard', fullWidth: true, displayEmpty: true }, (_a = props.providers.find(p => p.name === provider)) === null || _a === void 0 ? void 0 : _a.models.map((m, i) => (react_1.default.createElement(material_1.MenuItem, { key: i, value: m.id }, m.name))))),
119
126
  react_1.default.createElement(material_1.TextField, { value: temperature, onChange: e => setTemperature(+e.target.value), label: 'Model temperature', variant: 'standard', type: 'number', fullWidth: true }),
127
+ react_1.default.createElement(material_1.Stack, { direction: 'row', spacing: 1 },
128
+ react_1.default.createElement(material_1.TextField, { value: inputCostPerMillion, onChange: e => setInputCostPerMillion(e.target.value === '' ? '' : +e.target.value), label: 'Input cost / M tokens (\u20AC/$)', variant: 'standard', type: 'number', fullWidth: true, inputProps: { min: 0, step: 0.01 } }),
129
+ react_1.default.createElement(material_1.TextField, { value: outputCostPerMillion, onChange: e => setOutputCostPerMillion(e.target.value === '' ? '' : +e.target.value), label: 'Output cost / M tokens (\u20AC/$)', variant: 'standard', type: 'number', fullWidth: true, inputProps: { min: 0, step: 0.01 } })),
120
130
  react_1.default.createElement(material_1.Stack, { direction: 'row', alignItems: 'center' },
121
131
  react_1.default.createElement(material_1.Typography, { flex: 1 }, "Use provider API Key (or enter a specific one)"),
122
132
  react_1.default.createElement(material_1.Checkbox, { checked: useProviderKey, onChange: e => setUseProviderKey(e.target.checked) })),
package/dist/index.d.ts CHANGED
@@ -19,5 +19,7 @@ export interface ILlm {
19
19
  temperature: number;
20
20
  useProviderKey: boolean;
21
21
  key: string;
22
+ inputCostPerMillion?: number;
23
+ outputCostPerMillion?: number;
22
24
  data?: unknown;
23
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwirthmagnify/kwirth-common-ai",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "Shared AI/LLM types and utilities for Kwirth AI plugins",
5
5
  "scripts": {
6
6
  "build": "del .\\dist\\* /s /q 2>nul & tsc"