@lastbrain/ai-ui-react 1.0.69 → 1.0.70
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/AiChipLabel.d.ts.map +1 -1
- package/dist/components/AiChipLabel.js +3 -1
- package/dist/components/AiContextButton.d.ts +5 -1
- package/dist/components/AiContextButton.d.ts.map +1 -1
- package/dist/components/AiContextButton.js +10 -4
- package/dist/components/AiPromptPanel.js +12 -6
- package/dist/components/AiStatusButton.d.ts.map +1 -1
- package/dist/components/AiStatusButton.js +18 -13
- package/dist/components/AiTextarea.d.ts.map +1 -1
- package/dist/components/LBApiKeySelector.d.ts.map +1 -1
- package/dist/components/LBConnectButton.d.ts.map +1 -1
- package/dist/components/LBConnectButton.js +1 -1
- package/dist/components/LBSigninModal.d.ts.map +1 -1
- package/dist/components/LBSigninModal.js +1 -1
- package/dist/context/LBAuthProvider.d.ts +35 -3
- package/dist/context/LBAuthProvider.d.ts.map +1 -1
- package/dist/context/LBAuthProvider.js +2 -0
- package/dist/examples/AiUiPremiumShowcase.d.ts.map +1 -1
- package/dist/hooks/useAiModels.d.ts.map +1 -1
- package/dist/hooks/useModelManagement.d.ts.map +1 -1
- package/dist/utils/errorHandler.d.ts +2 -2
- package/dist/utils/errorHandler.d.ts.map +1 -1
- package/dist/utils/errorHandler.js +8 -1
- package/dist/utils/modelManagement.d.ts +13 -10
- package/dist/utils/modelManagement.d.ts.map +1 -1
- package/dist/utils/modelManagement.js +19 -2
- package/package.json +1 -1
- package/src/components/AiChipLabel.tsx +5 -1
- package/src/components/AiContextButton.tsx +44 -23
- package/src/components/AiPromptPanel.tsx +19 -15
- package/src/components/AiStatusButton.tsx +24 -19
- package/src/components/AiTextarea.tsx +3 -1
- package/src/components/LBApiKeySelector.tsx +13 -3
- package/src/components/LBConnectButton.tsx +3 -12
- package/src/components/LBSigninModal.tsx +20 -10
- package/src/context/LBAuthProvider.tsx +45 -6
- package/src/examples/AiUiPremiumShowcase.tsx +4 -1
- package/src/hooks/useAiModels.ts +2 -1
- package/src/hooks/useModelManagement.ts +2 -1
- package/src/utils/errorHandler.ts +16 -3
- package/src/utils/modelManagement.ts +53 -15
|
@@ -7,6 +7,51 @@ export interface ModelToggleOptions {
|
|
|
7
7
|
baseUrl?: string; // URL de base de l'API
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
interface Provider {
|
|
11
|
+
models?: ModelInfo[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ProvidersResponse {
|
|
15
|
+
providers?: Provider[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ModelsResponse {
|
|
19
|
+
models?: ModelInfo[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type ModelCategory = "text" | "image" | "audio" | "video";
|
|
23
|
+
|
|
24
|
+
interface ModelInfo {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
provider: string;
|
|
29
|
+
category: ModelCategory;
|
|
30
|
+
isActive?: boolean;
|
|
31
|
+
isPro?: boolean;
|
|
32
|
+
costPer1M?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isModelCategory(value: unknown): value is ModelCategory {
|
|
36
|
+
return (
|
|
37
|
+
value === "text" ||
|
|
38
|
+
value === "image" ||
|
|
39
|
+
value === "audio" ||
|
|
40
|
+
value === "video"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function isModelInfo(value: unknown): value is ModelInfo {
|
|
45
|
+
if (!value || typeof value !== "object") return false;
|
|
46
|
+
const v = value as Record<string, unknown>;
|
|
47
|
+
return (
|
|
48
|
+
typeof v.id === "string" &&
|
|
49
|
+
typeof v.name === "string" &&
|
|
50
|
+
typeof v.provider === "string" &&
|
|
51
|
+
isModelCategory(v.category)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
10
55
|
function isAuthTokenCandidate(value?: string): boolean {
|
|
11
56
|
if (!value) return false;
|
|
12
57
|
const token = value.trim();
|
|
@@ -66,18 +111,7 @@ export async function toggleUserModel(
|
|
|
66
111
|
*/
|
|
67
112
|
export async function getAvailableModels(
|
|
68
113
|
options: ModelToggleOptions = {}
|
|
69
|
-
): Promise<
|
|
70
|
-
Array<{
|
|
71
|
-
id: string;
|
|
72
|
-
name: string;
|
|
73
|
-
description?: string;
|
|
74
|
-
provider: string;
|
|
75
|
-
category: "text" | "image" | "audio" | "video";
|
|
76
|
-
isActive?: boolean;
|
|
77
|
-
isPro?: boolean;
|
|
78
|
-
costPer1M?: number;
|
|
79
|
-
}>
|
|
80
|
-
> {
|
|
114
|
+
): Promise<ModelInfo[]> {
|
|
81
115
|
const { apiKey, baseUrl = "" } = options;
|
|
82
116
|
|
|
83
117
|
// Déterminer le contexte
|
|
@@ -123,11 +157,15 @@ export async function getAvailableModels(
|
|
|
123
157
|
const data = await response.json();
|
|
124
158
|
|
|
125
159
|
if (Array.isArray(data?.models)) {
|
|
126
|
-
return data.models;
|
|
160
|
+
return data.models.filter(isModelInfo);
|
|
127
161
|
}
|
|
128
162
|
if (Array.isArray(data?.providers)) {
|
|
129
|
-
return
|
|
130
|
-
|
|
163
|
+
return (
|
|
164
|
+
(data as ProvidersResponse).providers?.flatMap((provider: Provider) =>
|
|
165
|
+
Array.isArray(provider.models)
|
|
166
|
+
? provider.models.filter(isModelInfo)
|
|
167
|
+
: []
|
|
168
|
+
) || []
|
|
131
169
|
);
|
|
132
170
|
}
|
|
133
171
|
return [];
|