@lastbrain/ai-ui-react 1.0.10 → 1.0.12
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/components/AiImageButton.d.ts.map +1 -1
- package/dist/components/AiImageButton.js +5 -2
- package/dist/components/AiInput.d.ts.map +1 -1
- package/dist/components/AiInput.js +20 -7
- package/dist/components/AiPromptPanel.d.ts +14 -1
- package/dist/components/AiPromptPanel.d.ts.map +1 -1
- package/dist/components/AiPromptPanel.js +516 -64
- package/dist/components/AiSelect.d.ts.map +1 -1
- package/dist/components/AiSelect.js +4 -1
- package/dist/components/AiSettingsButton.d.ts.map +1 -1
- package/dist/components/AiSettingsButton.js +1 -1
- package/dist/components/AiStatusButton.d.ts.map +1 -1
- package/dist/components/AiStatusButton.js +225 -38
- package/dist/components/AiTextarea.d.ts.map +1 -1
- package/dist/components/AiTextarea.js +35 -8
- package/dist/components/UsageToast.d.ts +14 -0
- package/dist/components/UsageToast.d.ts.map +1 -0
- package/dist/components/UsageToast.js +144 -0
- package/dist/examples/AiImageGenerator.d.ts +34 -0
- package/dist/examples/AiImageGenerator.d.ts.map +1 -0
- package/dist/examples/AiImageGenerator.js +85 -0
- package/dist/examples/AiPromptPanelAdvanced.d.ts +20 -0
- package/dist/examples/AiPromptPanelAdvanced.d.ts.map +1 -0
- package/dist/examples/AiPromptPanelAdvanced.js +222 -0
- package/dist/examples/ExternalIntegration.d.ts +2 -0
- package/dist/examples/ExternalIntegration.d.ts.map +1 -0
- package/dist/examples/ExternalIntegration.js +2 -0
- package/dist/hooks/useAiStatus.d.ts.map +1 -1
- package/dist/hooks/useAiStatus.js +3 -0
- package/dist/hooks/useModelManagement.d.ts +32 -0
- package/dist/hooks/useModelManagement.d.ts.map +1 -0
- package/dist/hooks/useModelManagement.js +135 -0
- package/dist/hooks/usePrompts.d.ts +1 -0
- package/dist/hooks/usePrompts.d.ts.map +1 -1
- package/dist/hooks/usePrompts.js +0 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/styles/inline.d.ts.map +1 -1
- package/dist/styles/inline.js +129 -63
- package/dist/utils/modelManagement.d.ts +29 -0
- package/dist/utils/modelManagement.d.ts.map +1 -0
- package/dist/utils/modelManagement.js +80 -0
- package/package.json +3 -2
- package/src/components/AiImageButton.tsx +13 -2
- package/src/components/AiInput.tsx +35 -27
- package/src/components/AiPromptPanel.tsx +1000 -143
- package/src/components/AiSelect.tsx +11 -0
- package/src/components/AiSettingsButton.tsx +4 -2
- package/src/components/AiStatusButton.tsx +424 -163
- package/src/components/AiTextarea.tsx +55 -28
- package/src/components/UsageToast.tsx +182 -0
- package/src/examples/AiImageGenerator.tsx +214 -0
- package/src/examples/AiPromptPanelAdvanced.tsx +381 -0
- package/src/examples/ExternalIntegration.ts +55 -0
- package/src/hooks/useAiStatus.ts +4 -0
- package/src/hooks/useModelManagement.ts +210 -0
- package/src/hooks/usePrompts.ts +1 -1
- package/src/index.ts +8 -0
- package/src/styles/inline.ts +139 -64
- package/src/utils/modelManagement.ts +130 -0
|
@@ -5,6 +5,7 @@ import type { BaseAiProps } from "../types";
|
|
|
5
5
|
import { useAiCallText } from "../hooks/useAiCallText";
|
|
6
6
|
import { useAiModels } from "../hooks/useAiModels";
|
|
7
7
|
import { AiPromptPanel } from "./AiPromptPanel";
|
|
8
|
+
import { UsageToast, useUsageToast } from "./UsageToast";
|
|
8
9
|
import { aiStyles } from "../styles/inline";
|
|
9
10
|
|
|
10
11
|
export interface AiSelectProps
|
|
@@ -31,6 +32,7 @@ export function AiSelect({
|
|
|
31
32
|
}: AiSelectProps) {
|
|
32
33
|
const [isOpen, setIsOpen] = useState(false);
|
|
33
34
|
const [isFocused, setIsFocused] = useState(false);
|
|
35
|
+
const { showUsageToast, toastData, toastKey, clearToast } = useUsageToast();
|
|
34
36
|
|
|
35
37
|
const { models } = useAiModels({ baseUrl, apiKeyId });
|
|
36
38
|
const { generateText, loading } = useAiCallText({ baseUrl, apiKeyId });
|
|
@@ -58,6 +60,7 @@ export function AiSelect({
|
|
|
58
60
|
if (result.text) {
|
|
59
61
|
onValue?.(result.text);
|
|
60
62
|
onToast?.({ type: "success", message: "AI suggestion ready" });
|
|
63
|
+
showUsageToast(result);
|
|
61
64
|
}
|
|
62
65
|
} catch (error) {
|
|
63
66
|
onToast?.({ type: "error", message: "Failed to generate suggestion" });
|
|
@@ -95,6 +98,14 @@ export function AiSelect({
|
|
|
95
98
|
models={models || []}
|
|
96
99
|
/>
|
|
97
100
|
)}
|
|
101
|
+
{Boolean(toastData) && (
|
|
102
|
+
<UsageToast
|
|
103
|
+
key={toastKey}
|
|
104
|
+
result={toastData}
|
|
105
|
+
position="bottom-right"
|
|
106
|
+
onComplete={clearToast}
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
98
109
|
</div>
|
|
99
110
|
);
|
|
100
111
|
}
|
|
@@ -66,10 +66,12 @@ export function AiSettingsButton({
|
|
|
66
66
|
<span>Tokens:</span>
|
|
67
67
|
<span>{status.balance?.total || 0}</span>
|
|
68
68
|
</div>
|
|
69
|
-
{status.storage?.
|
|
69
|
+
{status.storage?.allocated_mb !== undefined && (
|
|
70
70
|
<div data-ai-status-item>
|
|
71
71
|
<span>Storage:</span>
|
|
72
|
-
<span>
|
|
72
|
+
<span>
|
|
73
|
+
{status.storage.allocated_mb.toFixed(2)} MB
|
|
74
|
+
</span>
|
|
73
75
|
</div>
|
|
74
76
|
)}
|
|
75
77
|
</div>
|