@lastbrain/ai-ui-react 1.0.11 → 1.0.14
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/AiInput.d.ts.map +1 -1
- package/dist/components/AiInput.js +1 -1
- package/dist/components/AiPromptPanel.d.ts +14 -1
- package/dist/components/AiPromptPanel.d.ts.map +1 -1
- package/dist/components/AiPromptPanel.js +255 -7
- 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 +106 -11
- 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/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 +10 -1
- package/dist/utils/modelManagement.d.ts +29 -0
- package/dist/utils/modelManagement.d.ts.map +1 -0
- package/dist/utils/modelManagement.js +82 -0
- package/package.json +2 -2
- package/src/components/AiInput.tsx +3 -0
- package/src/components/AiPromptPanel.tsx +502 -24
- package/src/components/AiSettingsButton.tsx +4 -2
- package/src/components/AiStatusButton.tsx +185 -39
- 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/index.ts +8 -0
- package/src/styles/inline.ts +10 -1
- package/src/utils/modelManagement.ts +134 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiInput.d.ts","sourceRoot":"","sources":["../../src/components/AiInput.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAoB,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAO5C,MAAM,WAAW,YACf,SACE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EACzB,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IACxD,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC7B;AAED,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,MAAgB,EAChB,OAAO,EACP,KAAK,EACL,MAAM,EACN,QAAgB,EAChB,OAAO,EACP,OAAO,EACP,QAAQ,EACR,SAAS,EACT,GAAG,UAAU,EACd,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"AiInput.d.ts","sourceRoot":"","sources":["../../src/components/AiInput.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAoB,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAO5C,MAAM,WAAW,YACf,SACE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EACzB,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IACxD,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC7B;AAED,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,MAAgB,EAChB,OAAO,EACP,KAAK,EACL,MAAM,EACN,QAAgB,EAChB,OAAO,EACP,OAAO,EACP,QAAQ,EACR,SAAS,EACT,GAAG,UAAU,EACd,EAAE,YAAY,2CAyKd"}
|
|
@@ -100,5 +100,5 @@ export function AiInput({ baseUrl, apiKeyId, uiMode = "modal", context, model, p
|
|
|
100
100
|
...(disabled || loading
|
|
101
101
|
? { opacity: 0.5, cursor: "not-allowed" }
|
|
102
102
|
: {}),
|
|
103
|
-
}, onClick: hasConfiguration ? handleQuickGenerate : handleOpenPanel, onMouseEnter: () => setIsButtonHovered(true), onMouseLeave: () => setIsButtonHovered(false), disabled: disabled || loading, type: "button", title: hasConfiguration ? "Generate with AI" : "Setup AI", children: loading ? (_jsx("svg", { style: aiStyles.spinner, width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: _jsx("path", { d: "M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83" }) })) : (_jsx(Sparkles, { size: 16 })) }), isOpen && (_jsx(AiPromptPanel, { isOpen: isOpen, onClose: handleClosePanel, onSubmit: handleSubmit, uiMode: uiMode, models: models || [], sourceText: inputValue || undefined })), Boolean(toastData) && (_jsx(UsageToast, { result: toastData, position: "bottom-right", onComplete: clearToast }, toastKey))] }));
|
|
103
|
+
}, onClick: hasConfiguration ? handleQuickGenerate : handleOpenPanel, onMouseEnter: () => setIsButtonHovered(true), onMouseLeave: () => setIsButtonHovered(false), disabled: disabled || loading, type: "button", title: hasConfiguration ? "Generate with AI" : "Setup AI", children: loading ? (_jsx("svg", { style: aiStyles.spinner, width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: _jsx("path", { d: "M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83" }) })) : (_jsx(Sparkles, { size: 16 })) }), isOpen && (_jsx(AiPromptPanel, { isOpen: isOpen, onClose: handleClosePanel, onSubmit: handleSubmit, uiMode: uiMode, models: models || [], sourceText: inputValue || undefined, apiKey: apiKeyId, baseUrl: baseUrl, enableModelManagement: true })), Boolean(toastData) && (_jsx(UsageToast, { result: toastData, position: "bottom-right", onComplete: clearToast }, toastKey))] }));
|
|
104
104
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { ModelRef } from "@lastbrain/ai-ui-core";
|
|
3
3
|
import type { UiMode } from "../types";
|
|
4
|
+
import { type AIModel } from "../hooks/useModelManagement";
|
|
4
5
|
export interface AiPromptPanelProps {
|
|
5
6
|
isOpen: boolean;
|
|
6
7
|
onClose: () => void;
|
|
@@ -9,6 +10,12 @@ export interface AiPromptPanelProps {
|
|
|
9
10
|
models?: ModelRef[];
|
|
10
11
|
sourceText?: string;
|
|
11
12
|
children?: (props: AiPromptPanelRenderProps) => ReactNode;
|
|
13
|
+
enableModelManagement?: boolean;
|
|
14
|
+
availableModels?: AIModel[];
|
|
15
|
+
userModels?: string[];
|
|
16
|
+
onModelToggle?: (modelId: string, isActive: boolean) => Promise<void>;
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
baseUrl?: string;
|
|
12
19
|
}
|
|
13
20
|
export interface AiPromptPanelRenderProps {
|
|
14
21
|
models?: ModelRef[];
|
|
@@ -19,6 +26,12 @@ export interface AiPromptPanelRenderProps {
|
|
|
19
26
|
sourceText?: string;
|
|
20
27
|
handleSubmit: () => void;
|
|
21
28
|
handleClose: () => void;
|
|
29
|
+
enableModelManagement?: boolean;
|
|
30
|
+
availableModels?: AIModel[];
|
|
31
|
+
userModels?: string[];
|
|
32
|
+
showAllModels?: boolean;
|
|
33
|
+
setShowAllModels?: (show: boolean) => void;
|
|
34
|
+
onModelToggle?: (modelId: string, isActive: boolean) => Promise<void>;
|
|
22
35
|
}
|
|
23
|
-
export declare function AiPromptPanel({ isOpen, onClose, onSubmit, uiMode: _uiMode, models, sourceText, children, }: AiPromptPanelProps): import("react/jsx-runtime").JSX.Element | null;
|
|
36
|
+
export declare function AiPromptPanel({ isOpen, onClose, onSubmit, uiMode: _uiMode, models, sourceText, children, enableModelManagement, availableModels, userModels, onModelToggle, apiKey, baseUrl, }: AiPromptPanelProps): import("react/jsx-runtime").JSX.Element | null;
|
|
24
37
|
//# sourceMappingURL=AiPromptPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiPromptPanel.d.ts","sourceRoot":"","sources":["../../src/components/AiPromptPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"AiPromptPanel.d.ts","sourceRoot":"","sources":["../../src/components/AiPromptPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOvC,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAE/E,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,SAAS,CAAC;IAE1D,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;IAExB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,OAAO,EACP,QAAQ,EACR,MAAM,EAAE,OAAiB,EACzB,MAAW,EACX,UAAU,EACV,QAAQ,EACR,qBAA6B,EAC7B,eAAoB,EACpB,UAAe,EACf,aAAa,EACb,MAAM,EACN,OAAO,GACR,EAAE,kBAAkB,kDAmpCpB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useEffect, useRef, useLayoutEffect, } from "react";
|
|
4
|
-
import { BookOpen, Search, Sparkles, Star, Tag } from "lucide-react";
|
|
4
|
+
import { BookOpen, Search, Sparkles, Star, Tag, Settings } from "lucide-react";
|
|
5
5
|
import { aiStyles } from "../styles/inline";
|
|
6
6
|
import { usePrompts, } from "../hooks/usePrompts";
|
|
7
|
-
|
|
7
|
+
import { useModelManagement } from "../hooks/useModelManagement";
|
|
8
|
+
export function AiPromptPanel({ isOpen, onClose, onSubmit, uiMode: _uiMode = "modal", models = [], sourceText, children, enableModelManagement = false, availableModels = [], userModels = [], onModelToggle, apiKey, baseUrl, }) {
|
|
8
9
|
const [selectedModel, setSelectedModel] = useState("");
|
|
9
10
|
const [prompt, setPrompt] = useState("");
|
|
10
11
|
const [promptId, setPromptId] = useState(undefined);
|
|
@@ -20,7 +21,57 @@ export function AiPromptPanel({ isOpen, onClose, onSubmit, uiMode: _uiMode = "mo
|
|
|
20
21
|
const [isClosing, setIsClosing] = useState(false);
|
|
21
22
|
const promptRef = useRef(null);
|
|
22
23
|
const closeTimeoutRef = useRef(null);
|
|
24
|
+
// États pour la gestion des modèles
|
|
25
|
+
const [showAllModels, setShowAllModels] = useState(false);
|
|
26
|
+
const [isModelManagementOpen, setIsModelManagementOpen] = useState(false);
|
|
27
|
+
const [loadingModels, setLoadingModels] = useState([]);
|
|
23
28
|
const { prompts, loading: promptsLoading, fetchPrompts, incrementStat, } = usePrompts();
|
|
29
|
+
// Hook de gestion des modèles (automatique si enableModelManagement et pas de props externes)
|
|
30
|
+
const autoModelManagement = useModelManagement({
|
|
31
|
+
apiKey,
|
|
32
|
+
baseUrl,
|
|
33
|
+
category: "text", // Par défaut pour AiPromptPanel
|
|
34
|
+
autoFetch: enableModelManagement && availableModels.length === 0 && !!apiKey,
|
|
35
|
+
});
|
|
36
|
+
// Utiliser soit les props externes soit la gestion automatique
|
|
37
|
+
const effectiveAvailableModels = availableModels.length > 0
|
|
38
|
+
? availableModels
|
|
39
|
+
: autoModelManagement.availableModels;
|
|
40
|
+
const effectiveUserModels = userModels.length > 0 ? userModels : autoModelManagement.userModels;
|
|
41
|
+
const effectiveToggleModel = onModelToggle || autoModelManagement.toggleModel;
|
|
42
|
+
// Gestion des modèles
|
|
43
|
+
const handleModelToggle = async (modelId, isActive) => {
|
|
44
|
+
if (!effectiveToggleModel)
|
|
45
|
+
return;
|
|
46
|
+
setLoadingModels((prev) => [...prev, modelId]);
|
|
47
|
+
try {
|
|
48
|
+
await effectiveToggleModel(modelId, isActive);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error("Erreur lors du changement de modèle:", error);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
setLoadingModels((prev) => prev.filter((id) => id !== modelId));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const getFilteredModels = () => {
|
|
58
|
+
if (!enableModelManagement || effectiveAvailableModels.length === 0) {
|
|
59
|
+
// Mode classique : transformer les ModelRef en AIModel
|
|
60
|
+
return models.map((m) => ({
|
|
61
|
+
id: m.id,
|
|
62
|
+
name: m.name,
|
|
63
|
+
category: m.type === "image" ? "image" : "text",
|
|
64
|
+
provider: "Unknown",
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
const textModels = effectiveAvailableModels.filter((m) => m.category === "text");
|
|
68
|
+
if (showAllModels) {
|
|
69
|
+
return textModels;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return textModels.filter((m) => effectiveUserModels.includes(m.id));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
24
75
|
// Fetch prompts when modal opens
|
|
25
76
|
useEffect(() => {
|
|
26
77
|
if (isOpen && models.length > 0) {
|
|
@@ -136,6 +187,13 @@ export function AiPromptPanel({ isOpen, onClose, onSubmit, uiMode: _uiMode = "mo
|
|
|
136
187
|
sourceText,
|
|
137
188
|
handleSubmit,
|
|
138
189
|
handleClose,
|
|
190
|
+
// Nouvelles props pour la gestion des modèles
|
|
191
|
+
enableModelManagement,
|
|
192
|
+
availableModels: effectiveAvailableModels,
|
|
193
|
+
userModels: effectiveUserModels,
|
|
194
|
+
showAllModels,
|
|
195
|
+
setShowAllModels,
|
|
196
|
+
onModelToggle: handleModelToggle,
|
|
139
197
|
};
|
|
140
198
|
if (children) {
|
|
141
199
|
return (_jsx("div", { style: aiStyles.modal, onKeyDown: handleKeyDown, children: children(renderProps) }));
|
|
@@ -195,10 +253,74 @@ export function AiPromptPanel({ isOpen, onClose, onSubmit, uiMode: _uiMode = "mo
|
|
|
195
253
|
overflow: "auto",
|
|
196
254
|
whiteSpace: "pre-wrap",
|
|
197
255
|
wordBreak: "break-word",
|
|
198
|
-
}, children: sourceText })] })),
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
256
|
+
}, children: sourceText })] })), _jsx("div", { style: aiStyles.modalInputGroup, children: enableModelManagement ? (
|
|
257
|
+
// Version avancée avec gestion des modèles
|
|
258
|
+
_jsxs("div", { style: { marginBottom: "16px" }, children: [_jsxs("div", { style: {
|
|
259
|
+
display: "flex",
|
|
260
|
+
justifyContent: "space-between",
|
|
261
|
+
alignItems: "center",
|
|
262
|
+
marginBottom: "8px",
|
|
263
|
+
}, children: [_jsx("label", { htmlFor: "model-select", style: aiStyles.modalLabel, children: "AI Model" }), _jsxs("div", { style: {
|
|
264
|
+
display: "flex",
|
|
265
|
+
alignItems: "center",
|
|
266
|
+
gap: "8px",
|
|
267
|
+
}, children: [effectiveAvailableModels.length > 0 && (_jsxs("button", { onClick: () => setShowAllModels(!showAllModels), style: {
|
|
268
|
+
padding: "4px 8px",
|
|
269
|
+
fontSize: "12px",
|
|
270
|
+
color: "#8b5cf6",
|
|
271
|
+
background: "#8b5cf610",
|
|
272
|
+
border: "1px solid #8b5cf630",
|
|
273
|
+
borderRadius: "6px",
|
|
274
|
+
cursor: "pointer",
|
|
275
|
+
transition: "all 0.2s",
|
|
276
|
+
}, onMouseEnter: (e) => {
|
|
277
|
+
e.currentTarget.style.background = "#8b5cf620";
|
|
278
|
+
}, onMouseLeave: (e) => {
|
|
279
|
+
e.currentTarget.style.background = "#8b5cf610";
|
|
280
|
+
}, children: [showAllModels ? "Mes modèles" : "Tous les modèles", !showAllModels &&
|
|
281
|
+
effectiveAvailableModels.filter((m) => m.category === "text" &&
|
|
282
|
+
!effectiveUserModels.includes(m.id)).length > 0 && (_jsxs("span", { style: {
|
|
283
|
+
marginLeft: "4px",
|
|
284
|
+
padding: "2px 6px",
|
|
285
|
+
fontSize: "10px",
|
|
286
|
+
background: "#8b5cf6",
|
|
287
|
+
color: "white",
|
|
288
|
+
borderRadius: "10px",
|
|
289
|
+
}, children: ["+", effectiveAvailableModels.filter((m) => m.category === "text" &&
|
|
290
|
+
!effectiveUserModels.includes(m.id)).length] }))] })), _jsx("button", { onClick: () => setIsModelManagementOpen(true), style: {
|
|
291
|
+
padding: "4px 8px",
|
|
292
|
+
fontSize: "12px",
|
|
293
|
+
color: "#8b5cf6",
|
|
294
|
+
background: "#8b5cf610",
|
|
295
|
+
border: "1px solid #8b5cf630",
|
|
296
|
+
borderRadius: "6px",
|
|
297
|
+
cursor: "pointer",
|
|
298
|
+
transition: "all 0.2s",
|
|
299
|
+
display: "flex",
|
|
300
|
+
alignItems: "center",
|
|
301
|
+
gap: "4px",
|
|
302
|
+
}, onMouseEnter: (e) => {
|
|
303
|
+
e.currentTarget.style.background = "#8b5cf620";
|
|
304
|
+
}, onMouseLeave: (e) => {
|
|
305
|
+
e.currentTarget.style.background = "#8b5cf610";
|
|
306
|
+
}, children: _jsx(Settings, { size: 12 }) })] })] }), _jsxs("select", { id: "model-select", value: activeModelId, onChange: (e) => setSelectedModel(e.target.value), onFocus: () => setModelFocused(true), onBlur: () => setModelFocused(false), style: {
|
|
307
|
+
...aiStyles.select,
|
|
308
|
+
...(modelFocused && aiStyles.selectFocus),
|
|
309
|
+
}, children: [getFilteredModels().length === 0 && (_jsx("option", { value: "", children: "Loading models..." })), getFilteredModels().map((model) => {
|
|
310
|
+
const isActive = effectiveUserModels.includes(model.id);
|
|
311
|
+
return (_jsxs("option", { value: model.id, style: {
|
|
312
|
+
opacity: showAllModels && !isActive ? 0.6 : 1,
|
|
313
|
+
}, children: [model.name, showAllModels && isActive && " ✓", showAllModels && !isActive && " (Désactivé)"] }, model.id));
|
|
314
|
+
})] }), showAllModels && onModelToggle && (_jsx("div", { style: {
|
|
315
|
+
fontSize: "11px",
|
|
316
|
+
color: "#6b7280",
|
|
317
|
+
marginTop: "4px",
|
|
318
|
+
}, children: "\uD83D\uDCA1 Cliquez sur \"\u2699\uFE0F\" pour activer/d\u00E9sactiver les mod\u00E8les" }))] })) : (
|
|
319
|
+
// Version classique
|
|
320
|
+
_jsxs(_Fragment, { children: [_jsx("label", { htmlFor: "model-select", style: aiStyles.modalLabel, children: "AI Model" }), _jsxs("select", { id: "model-select", value: activeModelId, onChange: (e) => setSelectedModel(e.target.value), onFocus: () => setModelFocused(true), onBlur: () => setModelFocused(false), style: {
|
|
321
|
+
...aiStyles.select,
|
|
322
|
+
...(modelFocused && aiStyles.selectFocus),
|
|
323
|
+
}, children: [models.length === 0 && (_jsx("option", { value: "", children: "Loading models..." })), models.map((model) => (_jsx("option", { value: model.id, children: model.name }, model.id)))] })] })) }), _jsxs("div", { style: aiStyles.modalInputGroup, children: [_jsxs("div", { style: {
|
|
202
324
|
display: "flex",
|
|
203
325
|
justifyContent: "space-between",
|
|
204
326
|
alignItems: "center",
|
|
@@ -382,5 +504,131 @@ export function AiPromptPanel({ isOpen, onClose, onSubmit, uiMode: _uiMode = "mo
|
|
|
382
504
|
...(!selectedModel || !prompt.trim()
|
|
383
505
|
? aiStyles.buttonDisabled
|
|
384
506
|
: {}),
|
|
385
|
-
}, children: sourceText ? "Transform with AI" : "Generate with AI" })] })] })
|
|
507
|
+
}, children: sourceText ? "Transform with AI" : "Generate with AI" })] })] }), enableModelManagement && isModelManagementOpen && (_jsxs("div", { style: {
|
|
508
|
+
...aiStyles.modal,
|
|
509
|
+
zIndex: 1001, // Au-dessus du modal principal
|
|
510
|
+
}, children: [_jsx("div", { style: {
|
|
511
|
+
...aiStyles.modalOverlay,
|
|
512
|
+
backgroundColor: "rgba(0, 0, 0, 0.7)",
|
|
513
|
+
}, onClick: () => setIsModelManagementOpen(false) }), _jsxs("div", { style: {
|
|
514
|
+
...aiStyles.modalContent,
|
|
515
|
+
maxWidth: "600px",
|
|
516
|
+
maxHeight: "80vh",
|
|
517
|
+
overflow: "auto",
|
|
518
|
+
}, children: [_jsxs("div", { style: aiStyles.modalHeader, children: [_jsx("h2", { style: aiStyles.modalTitle, children: "Gestion des mod\u00E8les IA" }), _jsx("button", { style: aiStyles.modalCloseButton, onClick: () => setIsModelManagementOpen(false), "aria-label": "Close", children: "\u00D7" })] }), _jsxs("div", { style: aiStyles.modalBody, children: [_jsx("div", { style: { marginBottom: "16px" }, children: _jsx("p", { style: {
|
|
519
|
+
fontSize: "14px",
|
|
520
|
+
color: "#6b7280",
|
|
521
|
+
margin: "0 0 16px 0",
|
|
522
|
+
}, children: "Activez ou d\u00E9sactivez les mod\u00E8les selon vos besoins" }) }), _jsx("div", { style: {
|
|
523
|
+
display: "flex",
|
|
524
|
+
flexDirection: "column",
|
|
525
|
+
gap: "12px",
|
|
526
|
+
}, children: effectiveAvailableModels
|
|
527
|
+
.filter((model) => model.category === "text")
|
|
528
|
+
.map((modelData) => {
|
|
529
|
+
const isActive = effectiveUserModels.includes(modelData.id);
|
|
530
|
+
const isLoading = loadingModels.includes(modelData.id);
|
|
531
|
+
return (_jsxs("div", { style: {
|
|
532
|
+
display: "flex",
|
|
533
|
+
alignItems: "center",
|
|
534
|
+
justifyContent: "space-between",
|
|
535
|
+
padding: "16px",
|
|
536
|
+
border: "1px solid #e5e7eb",
|
|
537
|
+
borderRadius: "8px",
|
|
538
|
+
backgroundColor: isActive ? "#f0fdf4" : "#ffffff",
|
|
539
|
+
transition: "all 0.2s",
|
|
540
|
+
}, children: [_jsxs("div", { style: {
|
|
541
|
+
display: "flex",
|
|
542
|
+
alignItems: "center",
|
|
543
|
+
gap: "12px",
|
|
544
|
+
}, children: [_jsx("div", { style: {
|
|
545
|
+
width: "12px",
|
|
546
|
+
height: "12px",
|
|
547
|
+
borderRadius: "50%",
|
|
548
|
+
backgroundColor: isActive ? "#10b981" : "#d1d5db",
|
|
549
|
+
} }), _jsxs("div", { children: [_jsxs("div", { style: {
|
|
550
|
+
display: "flex",
|
|
551
|
+
alignItems: "center",
|
|
552
|
+
gap: "8px",
|
|
553
|
+
marginBottom: "4px",
|
|
554
|
+
}, children: [_jsx("span", { style: {
|
|
555
|
+
fontWeight: "500",
|
|
556
|
+
color: "#111827",
|
|
557
|
+
}, children: modelData.name }), modelData.isPro && (_jsx("span", { style: {
|
|
558
|
+
padding: "2px 8px",
|
|
559
|
+
fontSize: "11px",
|
|
560
|
+
backgroundColor: "#8b5cf6",
|
|
561
|
+
color: "white",
|
|
562
|
+
borderRadius: "12px",
|
|
563
|
+
fontWeight: "500",
|
|
564
|
+
}, children: "PRO" }))] }), modelData.description && (_jsx("p", { style: {
|
|
565
|
+
fontSize: "13px",
|
|
566
|
+
color: "#6b7280",
|
|
567
|
+
margin: "0 0 4px 0",
|
|
568
|
+
}, children: modelData.description })), _jsxs("div", { style: {
|
|
569
|
+
display: "flex",
|
|
570
|
+
alignItems: "center",
|
|
571
|
+
gap: "16px",
|
|
572
|
+
fontSize: "12px",
|
|
573
|
+
color: "#9ca3af",
|
|
574
|
+
}, children: [_jsxs("span", { children: ["Fournisseur: ", modelData.provider] }), modelData.costPer1M && (_jsxs("span", { children: ["Co\u00FBt: $", modelData.costPer1M, "/1M tokens"] }))] })] })] }), _jsx("button", { onClick: () => handleModelToggle(modelData.id, !isActive), disabled: isLoading, style: {
|
|
575
|
+
padding: "8px 16px",
|
|
576
|
+
fontSize: "13px",
|
|
577
|
+
fontWeight: "500",
|
|
578
|
+
borderRadius: "6px",
|
|
579
|
+
border: "1px solid",
|
|
580
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
581
|
+
transition: "all 0.2s",
|
|
582
|
+
minWidth: "80px",
|
|
583
|
+
...(isActive
|
|
584
|
+
? {
|
|
585
|
+
backgroundColor: "#fef2f2",
|
|
586
|
+
borderColor: "#fecaca",
|
|
587
|
+
color: "#dc2626",
|
|
588
|
+
}
|
|
589
|
+
: {
|
|
590
|
+
backgroundColor: "#f0fdf4",
|
|
591
|
+
borderColor: "#bbf7d0",
|
|
592
|
+
color: "#16a34a",
|
|
593
|
+
}),
|
|
594
|
+
opacity: isLoading ? 0.6 : 1,
|
|
595
|
+
}, onMouseEnter: (e) => {
|
|
596
|
+
if (!isLoading) {
|
|
597
|
+
if (isActive) {
|
|
598
|
+
e.currentTarget.style.backgroundColor =
|
|
599
|
+
"#fee2e2";
|
|
600
|
+
}
|
|
601
|
+
else {
|
|
602
|
+
e.currentTarget.style.backgroundColor =
|
|
603
|
+
"#dcfce7";
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}, onMouseLeave: (e) => {
|
|
607
|
+
if (!isLoading) {
|
|
608
|
+
if (isActive) {
|
|
609
|
+
e.currentTarget.style.backgroundColor =
|
|
610
|
+
"#fef2f2";
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
e.currentTarget.style.backgroundColor =
|
|
614
|
+
"#f0fdf4";
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}, children: isLoading ? (_jsx("div", { style: {
|
|
618
|
+
display: "flex",
|
|
619
|
+
alignItems: "center",
|
|
620
|
+
justifyContent: "center",
|
|
621
|
+
gap: "4px",
|
|
622
|
+
}, children: _jsx("div", { style: {
|
|
623
|
+
width: "12px",
|
|
624
|
+
height: "12px",
|
|
625
|
+
border: "2px solid currentColor",
|
|
626
|
+
borderTop: "2px solid transparent",
|
|
627
|
+
borderRadius: "50%",
|
|
628
|
+
animation: "ai-spin 1s linear infinite",
|
|
629
|
+
} }) })) : isActive ? ("Désactiver") : ("Activer") })] }, modelData.id));
|
|
630
|
+
}) })] }), _jsx("div", { style: aiStyles.modalFooter, children: _jsx("button", { onClick: () => setIsModelManagementOpen(false), style: {
|
|
631
|
+
...aiStyles.button,
|
|
632
|
+
...aiStyles.buttonSecondary,
|
|
633
|
+
}, children: "Fermer" }) })] })] }))] }));
|
|
386
634
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiSettingsButton.d.ts","sourceRoot":"","sources":["../../src/components/AiSettingsButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAG5D,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,SAAS,EACT,QAAQ,EACR,GAAG,WAAW,EACf,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"AiSettingsButton.d.ts","sourceRoot":"","sources":["../../src/components/AiSettingsButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAG5D,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,SAAS,EACT,QAAQ,EACR,GAAG,WAAW,EACf,EAAE,qBAAqB,2CAwFvB"}
|
|
@@ -12,5 +12,5 @@ export function AiSettingsButton({ baseUrl, apiKeyId, onAddTokens, onAddStorage,
|
|
|
12
12
|
setIsOpen(false);
|
|
13
13
|
};
|
|
14
14
|
const hasApiKey = Boolean(apiKeyId);
|
|
15
|
-
return (_jsxs("div", { "data-ai-settings-wrapper": true, children: [_jsx("button", { ...buttonProps, onClick: handleToggle, className: className, "data-ai-settings-button": true, disabled: loading, children: children || "AI Settings" }), isOpen && (_jsxs("div", { "data-ai-settings-panel": true, children: [_jsx("div", { "data-ai-settings-overlay": true, onClick: handleClose }), _jsxs("div", { "data-ai-settings-content": true, children: [_jsxs("div", { "data-ai-settings-header": true, children: [_jsx("h3", { children: "AI Settings" }), _jsx("button", { onClick: handleClose, "data-ai-close-button": true, children: "\u00D7" })] }), _jsx("div", { "data-ai-settings-body": true, children: hasApiKey ? (_jsxs(_Fragment, { children: [status && (_jsxs("div", { "data-ai-status-section": true, children: [_jsxs("div", { "data-ai-status-item": true, children: [_jsx("span", { children: "Tokens:" }), _jsx("span", { children: status.balance?.total || 0 })] }), status.storage?.
|
|
15
|
+
return (_jsxs("div", { "data-ai-settings-wrapper": true, children: [_jsx("button", { ...buttonProps, onClick: handleToggle, className: className, "data-ai-settings-button": true, disabled: loading, children: children || "AI Settings" }), isOpen && (_jsxs("div", { "data-ai-settings-panel": true, children: [_jsx("div", { "data-ai-settings-overlay": true, onClick: handleClose }), _jsxs("div", { "data-ai-settings-content": true, children: [_jsxs("div", { "data-ai-settings-header": true, children: [_jsx("h3", { children: "AI Settings" }), _jsx("button", { onClick: handleClose, "data-ai-close-button": true, children: "\u00D7" })] }), _jsx("div", { "data-ai-settings-body": true, children: hasApiKey ? (_jsxs(_Fragment, { children: [status && (_jsxs("div", { "data-ai-status-section": true, children: [_jsxs("div", { "data-ai-status-item": true, children: [_jsx("span", { children: "Tokens:" }), _jsx("span", { children: status.balance?.total || 0 })] }), status.storage?.allocated_mb !== undefined && (_jsxs("div", { "data-ai-status-item": true, children: [_jsx("span", { children: "Storage:" }), _jsxs("span", { children: [status.storage.allocated_mb.toFixed(2), " MB"] })] }))] })), _jsxs("div", { "data-ai-actions-section": true, children: [onDashboard && (_jsx("button", { onClick: onDashboard, "data-ai-action-button": true, children: "Dashboard" })), onAddTokens && (_jsx("button", { onClick: onAddTokens, "data-ai-action-button": true, children: "Add Tokens" })), onAddStorage && (_jsx("button", { onClick: onAddStorage, "data-ai-action-button": true, children: "Add Storage" }))] })] })) : (_jsxs("div", { "data-ai-no-key-section": true, children: [_jsx("p", { children: "No API key configured" }), onDocumentation && (_jsx("button", { onClick: onDocumentation, "data-ai-action-button": true, children: "View Documentation" }))] })) })] })] }))] }));
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiStatusButton.d.ts","sourceRoot":"","sources":["../../src/components/AiStatusButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"AiStatusButton.d.ts","sourceRoot":"","sources":["../../src/components/AiStatusButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAYtD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,OAAe,EACf,SAAc,GACf,EAAE,mBAAmB,2CA6hBrB"}
|
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useRef, useLayoutEffect } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
+
import { BarChart3, Settings, FileText, History as HistoryIcon, FolderPlus, } from "lucide-react";
|
|
5
6
|
import { aiStyles, calculateTooltipPosition } from "../styles/inline";
|
|
6
7
|
export function AiStatusButton({ status, loading = false, className = "", }) {
|
|
7
8
|
const formatNumber = (value) => typeof value === "number" ? value.toLocaleString() : "0";
|
|
8
9
|
const formatFixed = (value, digits) => typeof value === "number" ? value.toFixed(digits) : "0.00";
|
|
10
|
+
const formatStorage = (valueMb) => {
|
|
11
|
+
const mb = typeof valueMb === "number" ? valueMb : 0;
|
|
12
|
+
if (mb >= 1024) {
|
|
13
|
+
const gb = mb / 1024;
|
|
14
|
+
return `${gb.toFixed(2)} GB`;
|
|
15
|
+
}
|
|
16
|
+
return `${mb.toFixed(2)} MB`;
|
|
17
|
+
};
|
|
9
18
|
const safeNumber = (value) => typeof value === "number" ? value : 0;
|
|
10
19
|
const clampPercentage = (value) => Math.min(100, Math.max(0, safeNumber(value)));
|
|
11
20
|
const getUsageColor = (percentage) => {
|
|
@@ -25,7 +34,7 @@ export function AiStatusButton({ status, loading = false, className = "", }) {
|
|
|
25
34
|
const circumference = 2 * Math.PI * radius;
|
|
26
35
|
const offset = circumference - (percentage / 100) * circumference;
|
|
27
36
|
const color = getUsageColor(percentage);
|
|
28
|
-
return (_jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [_jsx("circle", { cx: size / 2, cy: size / 2, r: radius, stroke: aiStyles.tooltipLabel.color, strokeWidth: stroke, fill: "transparent", opacity: 0.3 }), _jsx("circle", { cx: size / 2, cy: size / 2, r: radius, stroke: color, strokeWidth: stroke, fill: "transparent", strokeDasharray: circumference, strokeDashoffset: offset, strokeLinecap: "round", transform: `rotate(-90 ${size / 2} ${size / 2})` })] }));
|
|
37
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [_jsx("circle", { cx: size / 2, cy: size / 2, r: radius, stroke: aiStyles.tooltipLabel.color, strokeWidth: stroke, fill: "transparent", opacity: 0.3 }), _jsx("circle", { cx: size / 2, cy: size / 2, r: radius, stroke: color, strokeWidth: stroke, fill: "transparent", strokeDasharray: circumference, strokeDashoffset: offset, strokeLinecap: "round", transform: `rotate(-90 ${size / 2} ${size / 2})` }), _jsxs("text", { x: size / 2, y: size / 2, textAnchor: "middle", dominantBaseline: "central", fontSize: "7px", fill: color, fontWeight: "600", children: [percentage.toFixed(0), "%"] })] }));
|
|
29
38
|
};
|
|
30
39
|
const balanceUsage = status?.balance;
|
|
31
40
|
const storageUsage = status?.storage;
|
|
@@ -155,17 +164,103 @@ export function AiStatusButton({ status, loading = false, className = "", }) {
|
|
|
155
164
|
}, onMouseEnter: () => setShowTooltip(true), onMouseLeave: handleMouseLeave, children: [_jsx("div", { style: aiStyles.tooltipHeader, children: "API Status" }), _jsxs("div", { style: {
|
|
156
165
|
...aiStyles.tooltipSection,
|
|
157
166
|
...aiStyles.tooltipSectionFirst,
|
|
158
|
-
}, children: [_jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "API Key:" }), _jsx("span", { style: aiStyles.tooltipValue, children: status.api_key.name })] }), _jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "Env:" }), _jsx("span", { style: aiStyles.tooltipValue, children: status.api_key.env })] }), _jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "Rate Limit:" }), _jsxs("span", { style: aiStyles.tooltipValue, children: [status.api_key.rate_limit_rpm, " req/min"] })] })] }), _jsxs("div", { style: aiStyles.tooltipSection, children: [_jsx("div", { style: aiStyles.tooltipSubtitle, children: "Balance" }), _jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "Total:" }), _jsxs("span", { style: aiStyles.tooltipValue, children: ["$", formatFixed(balanceUsed, 6), " / $", formatNumber(balanceTotal)] }), renderUsageCircle(balancePercentage)] })] }), _jsxs("div", { style: aiStyles.tooltipSection, children: [_jsx("div", { style: aiStyles.tooltipSubtitle, children: "Storage" }), _jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "Total:" }), _jsxs("span", { style: aiStyles.tooltipValue, children: [
|
|
159
|
-
|
|
167
|
+
}, children: [_jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "API Key:" }), _jsx("span", { style: aiStyles.tooltipValue, children: status.api_key.name })] }), _jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "Env:" }), _jsx("span", { style: aiStyles.tooltipValue, children: status.api_key.env })] }), _jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "Rate Limit:" }), _jsxs("span", { style: aiStyles.tooltipValue, children: [status.api_key.rate_limit_rpm, " req/min"] })] })] }), _jsxs("div", { style: aiStyles.tooltipSection, children: [_jsx("div", { style: aiStyles.tooltipSubtitle, children: "Balance" }), _jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "Total:" }), _jsxs("span", { style: aiStyles.tooltipValue, children: ["$", formatFixed(balanceUsed, 6), " / $", formatNumber(balanceTotal)] }), renderUsageCircle(balancePercentage)] })] }), _jsxs("div", { style: aiStyles.tooltipSection, children: [_jsx("div", { style: aiStyles.tooltipSubtitle, children: "Storage" }), _jsxs("div", { style: aiStyles.tooltipRow, children: [_jsx("span", { style: aiStyles.tooltipLabel, children: "Total:" }), _jsxs("span", { style: aiStyles.tooltipValue, children: [formatStorage(storageUsed), " /", " ", formatStorage(storageAllocated)] }), renderUsageCircle(storagePercentage)] })] }), _jsxs("div", { style: {
|
|
168
|
+
...aiStyles.tooltipActions,
|
|
169
|
+
width: "100%",
|
|
170
|
+
flexDirection: "row",
|
|
171
|
+
}, children: [_jsx("button", { onClick: () => window.open("https://prompt.lastbrain.io/auth/ai/tokens", "_blank"), style: {
|
|
172
|
+
background: "transparent",
|
|
173
|
+
border: "none",
|
|
174
|
+
borderRadius: "4px",
|
|
175
|
+
padding: "14px",
|
|
176
|
+
cursor: "pointer",
|
|
177
|
+
display: "flex",
|
|
178
|
+
alignItems: "center",
|
|
179
|
+
justifyContent: "center",
|
|
180
|
+
color: "#8b5cf6",
|
|
181
|
+
transition: "all 0.2s ease",
|
|
182
|
+
}, onMouseEnter: (e) => {
|
|
183
|
+
Object.assign(e.currentTarget.style, {
|
|
184
|
+
background: "rgba(139, 92, 246, 0.1)",
|
|
185
|
+
});
|
|
186
|
+
}, onMouseLeave: (e) => {
|
|
187
|
+
Object.assign(e.currentTarget.style, {
|
|
188
|
+
background: "transparent",
|
|
189
|
+
});
|
|
190
|
+
}, title: "Dashboard", children: _jsx(BarChart3, { size: 18 }) }), _jsx("button", { onClick: () => window.open("https://prompt.lastbrain.io/auth/ai/history", "_blank"), style: {
|
|
191
|
+
background: "transparent",
|
|
192
|
+
border: "none",
|
|
193
|
+
borderRadius: "4px",
|
|
194
|
+
padding: "14px",
|
|
195
|
+
cursor: "pointer",
|
|
196
|
+
display: "flex",
|
|
197
|
+
alignItems: "center",
|
|
198
|
+
justifyContent: "center",
|
|
199
|
+
color: "#8b5cf6",
|
|
200
|
+
transition: "all 0.2s ease",
|
|
201
|
+
}, onMouseEnter: (e) => {
|
|
202
|
+
Object.assign(e.currentTarget.style, {
|
|
203
|
+
background: "rgba(139, 92, 246, 0.1)",
|
|
204
|
+
});
|
|
205
|
+
}, onMouseLeave: (e) => {
|
|
206
|
+
Object.assign(e.currentTarget.style, {
|
|
207
|
+
background: "transparent",
|
|
208
|
+
});
|
|
209
|
+
}, title: "History", children: _jsx(HistoryIcon, { size: 18 }) }), _jsx("button", { onClick: () => window.open("https://prompt.lastbrain.io/auth/ai/settings", "_blank"), style: {
|
|
210
|
+
background: "transparent",
|
|
211
|
+
border: "none",
|
|
212
|
+
borderRadius: "4px",
|
|
213
|
+
padding: "14px",
|
|
214
|
+
cursor: "pointer",
|
|
215
|
+
display: "flex",
|
|
216
|
+
alignItems: "center",
|
|
217
|
+
justifyContent: "center",
|
|
218
|
+
color: "#8b5cf6",
|
|
219
|
+
transition: "all 0.2s ease",
|
|
220
|
+
}, onMouseEnter: (e) => {
|
|
221
|
+
Object.assign(e.currentTarget.style, {
|
|
222
|
+
background: "rgba(139, 92, 246, 0.1)",
|
|
223
|
+
});
|
|
160
224
|
}, onMouseLeave: (e) => {
|
|
161
|
-
Object.assign(e.currentTarget.style,
|
|
162
|
-
|
|
163
|
-
|
|
225
|
+
Object.assign(e.currentTarget.style, {
|
|
226
|
+
background: "transparent",
|
|
227
|
+
});
|
|
228
|
+
}, title: "Settings", children: _jsx(Settings, { size: 18 }) }), _jsx("button", { onClick: () => window.open("https://prompt.lastbrain.io/auth/ai/prompts", "_blank"), style: {
|
|
229
|
+
background: "transparent",
|
|
230
|
+
border: "none",
|
|
231
|
+
borderRadius: "4px",
|
|
232
|
+
padding: "14px",
|
|
233
|
+
cursor: "pointer",
|
|
234
|
+
display: "flex",
|
|
235
|
+
alignItems: "center",
|
|
236
|
+
justifyContent: "center",
|
|
237
|
+
color: "#8b5cf6",
|
|
238
|
+
transition: "all 0.2s ease",
|
|
239
|
+
}, onMouseEnter: (e) => {
|
|
240
|
+
Object.assign(e.currentTarget.style, {
|
|
241
|
+
background: "rgba(139, 92, 246, 0.1)",
|
|
242
|
+
});
|
|
164
243
|
}, onMouseLeave: (e) => {
|
|
165
|
-
Object.assign(e.currentTarget.style,
|
|
166
|
-
|
|
167
|
-
|
|
244
|
+
Object.assign(e.currentTarget.style, {
|
|
245
|
+
background: "transparent",
|
|
246
|
+
});
|
|
247
|
+
}, title: "New Prompt", children: _jsx(FileText, { size: 18 }) }), _jsx("button", { onClick: () => window.open("https://prompt.lastbrain.io/auth/folder", "_blank"), style: {
|
|
248
|
+
background: "transparent",
|
|
249
|
+
border: "none",
|
|
250
|
+
padding: "14px",
|
|
251
|
+
cursor: "pointer",
|
|
252
|
+
display: "flex",
|
|
253
|
+
alignItems: "center",
|
|
254
|
+
justifyContent: "center",
|
|
255
|
+
color: "#8b5cf6",
|
|
256
|
+
transition: "all 0.2s ease",
|
|
257
|
+
}, onMouseEnter: (e) => {
|
|
258
|
+
Object.assign(e.currentTarget.style, {
|
|
259
|
+
background: "rgba(139, 92, 246, 0.1)",
|
|
260
|
+
});
|
|
168
261
|
}, onMouseLeave: (e) => {
|
|
169
|
-
Object.assign(e.currentTarget.style,
|
|
170
|
-
|
|
262
|
+
Object.assign(e.currentTarget.style, {
|
|
263
|
+
background: "transparent",
|
|
264
|
+
});
|
|
265
|
+
}, title: "New Folder", children: _jsx(FolderPlus, { size: 18 }) })] })] }), document.body)] }));
|
|
171
266
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface ModelManagementExampleProps {
|
|
2
|
+
/** Clé API LastBrain pour l'authentification */
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
/** URL de base de l'API */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Catégorie de modèles à gérer */
|
|
7
|
+
category?: "text" | "image" | "audio" | "video";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Composant exemple montrant comment utiliser le hook useModelManagement
|
|
11
|
+
* Retourne les données et handlers pour les passer à d'autres composants
|
|
12
|
+
*/
|
|
13
|
+
export declare function useImageModelManagement({ apiKey, baseUrl, category, }?: ModelManagementExampleProps): {
|
|
14
|
+
availableModels: import("..").AIModel[];
|
|
15
|
+
userModels: string[];
|
|
16
|
+
loading: boolean;
|
|
17
|
+
error: string | null;
|
|
18
|
+
toggleModel: (modelId: string, isActive: boolean) => Promise<void>;
|
|
19
|
+
isModelActive: (modelId: string) => boolean;
|
|
20
|
+
getActiveModels: () => import("..").AIModel[];
|
|
21
|
+
getInactiveModels: () => import("..").AIModel[];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Composant exemple affichant les statistiques des modèles
|
|
25
|
+
*/
|
|
26
|
+
export declare function ModelManagementStats({ apiKey, baseUrl, category, }?: ModelManagementExampleProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* Composant exemple pour afficher et gérer une liste de modèles
|
|
29
|
+
*/
|
|
30
|
+
export declare function ModelManagementList({ apiKey, baseUrl, category, onModelToggle, }: ModelManagementExampleProps & {
|
|
31
|
+
onModelToggle?: (modelId: string, isActive: boolean) => void;
|
|
32
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=AiImageGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiImageGenerator.d.ts","sourceRoot":"","sources":["../../src/examples/AiImageGenerator.tsx"],"names":[],"mappings":"AAEA,UAAU,2BAA2B;IACnC,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,OAAO,EACP,QAAkB,GACnB,GAAE,2BAAgC;;;;;2BAiBS,MAAM,YAAY,OAAO;;;;EAmBpE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,OAAO,EACP,QAAkB,GACnB,GAAE,2BAAgC,2CAgDlC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,OAAO,EACP,QAAkB,EAClB,aAAa,GACd,EAAE,2BAA2B,GAAG;IAC/B,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9D,2CAyFA"}
|