@lastbrain/ai-ui-react 1.0.3
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/README.md +84 -0
- package/dist/components/AiChipLabel.d.ts +8 -0
- package/dist/components/AiChipLabel.d.ts.map +1 -0
- package/dist/components/AiChipLabel.js +39 -0
- package/dist/components/AiImageButton.d.ts +8 -0
- package/dist/components/AiImageButton.d.ts.map +1 -0
- package/dist/components/AiImageButton.js +36 -0
- package/dist/components/AiInput.d.ts +7 -0
- package/dist/components/AiInput.d.ts.map +1 -0
- package/dist/components/AiInput.js +77 -0
- package/dist/components/AiModelSelect.d.ts +10 -0
- package/dist/components/AiModelSelect.d.ts.map +1 -0
- package/dist/components/AiModelSelect.js +5 -0
- package/dist/components/AiPromptPanel.d.ts +22 -0
- package/dist/components/AiPromptPanel.d.ts.map +1 -0
- package/dist/components/AiPromptPanel.js +30 -0
- package/dist/components/AiSelect.d.ts +8 -0
- package/dist/components/AiSelect.d.ts.map +1 -0
- package/dist/components/AiSelect.js +38 -0
- package/dist/components/AiSettingsButton.d.ts +11 -0
- package/dist/components/AiSettingsButton.d.ts.map +1 -0
- package/dist/components/AiSettingsButton.js +16 -0
- package/dist/components/AiTextarea.d.ts +7 -0
- package/dist/components/AiTextarea.d.ts.map +1 -0
- package/dist/components/AiTextarea.js +79 -0
- package/dist/context/AiProvider.d.ts +18 -0
- package/dist/context/AiProvider.d.ts.map +1 -0
- package/dist/context/AiProvider.js +20 -0
- package/dist/hooks/useAiCallImage.d.ts +12 -0
- package/dist/hooks/useAiCallImage.d.ts.map +1 -0
- package/dist/hooks/useAiCallImage.js +29 -0
- package/dist/hooks/useAiCallText.d.ts +12 -0
- package/dist/hooks/useAiCallText.d.ts.map +1 -0
- package/dist/hooks/useAiCallText.js +29 -0
- package/dist/hooks/useAiClient.d.ts +12 -0
- package/dist/hooks/useAiClient.d.ts.map +1 -0
- package/dist/hooks/useAiClient.js +13 -0
- package/dist/hooks/useAiModels.d.ts +13 -0
- package/dist/hooks/useAiModels.d.ts.map +1 -0
- package/dist/hooks/useAiModels.js +32 -0
- package/dist/hooks/useAiStatus.d.ts +13 -0
- package/dist/hooks/useAiStatus.d.ts.map +1 -0
- package/dist/hooks/useAiStatus.js +32 -0
- package/dist/hooks/usePrompts.d.ts +35 -0
- package/dist/hooks/usePrompts.d.ts.map +1 -0
- package/dist/hooks/usePrompts.js +125 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +60 -0
- package/src/components/AiChipLabel.tsx +88 -0
- package/src/components/AiImageButton.tsx +87 -0
- package/src/components/AiInput.tsx +150 -0
- package/src/components/AiModelSelect.tsx +37 -0
- package/src/components/AiPromptPanel.tsx +120 -0
- package/src/components/AiSelect.tsx +91 -0
- package/src/components/AiSettingsButton.tsx +111 -0
- package/src/components/AiTextarea.tsx +152 -0
- package/src/context/AiProvider.tsx +44 -0
- package/src/hooks/useAiCallImage.ts +49 -0
- package/src/hooks/useAiCallText.ts +49 -0
- package/src/hooks/useAiClient.ts +23 -0
- package/src/hooks/useAiModels.ts +50 -0
- package/src/hooks/useAiStatus.ts +50 -0
- package/src/hooks/usePrompts.ts +187 -0
- package/src/index.ts +23 -0
- package/src/types.ts +20 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback } from "react";
|
|
4
|
+
import type { AiImageRequest, AiImageResponse } from "@lastbrain/ai-ui-core";
|
|
5
|
+
import { useAiClient } from "./useAiClient";
|
|
6
|
+
|
|
7
|
+
export interface UseAiCallImageOptions {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
apiKeyId?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface UseAiCallImageResult {
|
|
13
|
+
generateImage: (request: AiImageRequest) => Promise<AiImageResponse>;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useAiCallImage(
|
|
19
|
+
options?: UseAiCallImageOptions
|
|
20
|
+
): UseAiCallImageResult {
|
|
21
|
+
const client = useAiClient(options);
|
|
22
|
+
const [loading, setLoading] = useState(false);
|
|
23
|
+
const [error, setError] = useState<Error | null>(null);
|
|
24
|
+
|
|
25
|
+
const generateImage = useCallback(
|
|
26
|
+
async (request: AiImageRequest): Promise<AiImageResponse> => {
|
|
27
|
+
setLoading(true);
|
|
28
|
+
setError(null);
|
|
29
|
+
try {
|
|
30
|
+
const result = await client.generateImage(request);
|
|
31
|
+
return result;
|
|
32
|
+
} catch (err) {
|
|
33
|
+
const error =
|
|
34
|
+
err instanceof Error ? err : new Error("Failed to generate image");
|
|
35
|
+
setError(error);
|
|
36
|
+
throw error;
|
|
37
|
+
} finally {
|
|
38
|
+
setLoading(false);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
[client]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
generateImage,
|
|
46
|
+
loading,
|
|
47
|
+
error,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback } from "react";
|
|
4
|
+
import type { AiTextRequest, AiTextResponse } from "@lastbrain/ai-ui-core";
|
|
5
|
+
import { useAiClient } from "./useAiClient";
|
|
6
|
+
|
|
7
|
+
export interface UseAiCallTextOptions {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
apiKeyId?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface UseAiCallTextResult {
|
|
13
|
+
generateText: (request: AiTextRequest) => Promise<AiTextResponse>;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useAiCallText(
|
|
19
|
+
options?: UseAiCallTextOptions
|
|
20
|
+
): UseAiCallTextResult {
|
|
21
|
+
const client = useAiClient(options);
|
|
22
|
+
const [loading, setLoading] = useState(false);
|
|
23
|
+
const [error, setError] = useState<Error | null>(null);
|
|
24
|
+
|
|
25
|
+
const generateText = useCallback(
|
|
26
|
+
async (request: AiTextRequest): Promise<AiTextResponse> => {
|
|
27
|
+
setLoading(true);
|
|
28
|
+
setError(null);
|
|
29
|
+
try {
|
|
30
|
+
const result = await client.generateText(request);
|
|
31
|
+
return result;
|
|
32
|
+
} catch (err) {
|
|
33
|
+
const error =
|
|
34
|
+
err instanceof Error ? err : new Error("Failed to generate text");
|
|
35
|
+
setError(error);
|
|
36
|
+
throw error;
|
|
37
|
+
} finally {
|
|
38
|
+
setLoading(false);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
[client]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
generateText,
|
|
46
|
+
loading,
|
|
47
|
+
error,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { createClient } from "@lastbrain/ai-ui-core";
|
|
5
|
+
import { useAiContext } from "../context/AiProvider";
|
|
6
|
+
|
|
7
|
+
export interface UseAiClientOptions {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
apiKeyId?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useAiClient(options?: UseAiClientOptions) {
|
|
13
|
+
const context = useAiContext();
|
|
14
|
+
|
|
15
|
+
const client = useMemo(() => {
|
|
16
|
+
const baseUrl = options?.baseUrl || context.baseUrl;
|
|
17
|
+
const apiKeyId = options?.apiKeyId || context.apiKeyId;
|
|
18
|
+
|
|
19
|
+
return createClient({ baseUrl, apiKeyId });
|
|
20
|
+
}, [options?.baseUrl, options?.apiKeyId, context.baseUrl, context.apiKeyId]);
|
|
21
|
+
|
|
22
|
+
return client;
|
|
23
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useCallback } from "react";
|
|
4
|
+
import type { ModelRef } from "@lastbrain/ai-ui-core";
|
|
5
|
+
import { useAiClient } from "./useAiClient";
|
|
6
|
+
|
|
7
|
+
export interface UseAiModelsOptions {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
apiKeyId?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface UseAiModelsResult {
|
|
13
|
+
models: ModelRef[] | null;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
refetch: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useAiModels(options?: UseAiModelsOptions): UseAiModelsResult {
|
|
20
|
+
const client = useAiClient(options);
|
|
21
|
+
const [models, setModels] = useState<ModelRef[] | null>(null);
|
|
22
|
+
const [loading, setLoading] = useState(false);
|
|
23
|
+
const [error, setError] = useState<Error | null>(null);
|
|
24
|
+
|
|
25
|
+
const fetchModels = useCallback(async () => {
|
|
26
|
+
setLoading(true);
|
|
27
|
+
setError(null);
|
|
28
|
+
try {
|
|
29
|
+
const result = await client.getModels();
|
|
30
|
+
setModels(result);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
setError(
|
|
33
|
+
err instanceof Error ? err : new Error("Failed to fetch models")
|
|
34
|
+
);
|
|
35
|
+
} finally {
|
|
36
|
+
setLoading(false);
|
|
37
|
+
}
|
|
38
|
+
}, [client]);
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
fetchModels();
|
|
42
|
+
}, [fetchModels]);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
models,
|
|
46
|
+
loading,
|
|
47
|
+
error,
|
|
48
|
+
refetch: fetchModels,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useCallback } from "react";
|
|
4
|
+
import type { AiStatus } from "@lastbrain/ai-ui-core";
|
|
5
|
+
import { useAiClient } from "./useAiClient";
|
|
6
|
+
|
|
7
|
+
export interface UseAiStatusOptions {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
apiKeyId?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface UseAiStatusResult {
|
|
13
|
+
status: AiStatus | null;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
refetch: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useAiStatus(options?: UseAiStatusOptions): UseAiStatusResult {
|
|
20
|
+
const client = useAiClient(options);
|
|
21
|
+
const [status, setStatus] = useState<AiStatus | null>(null);
|
|
22
|
+
const [loading, setLoading] = useState(false);
|
|
23
|
+
const [error, setError] = useState<Error | null>(null);
|
|
24
|
+
|
|
25
|
+
const fetchStatus = useCallback(async () => {
|
|
26
|
+
setLoading(true);
|
|
27
|
+
setError(null);
|
|
28
|
+
try {
|
|
29
|
+
const result = await client.getStatus();
|
|
30
|
+
setStatus(result);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
setError(
|
|
33
|
+
err instanceof Error ? err : new Error("Failed to fetch status")
|
|
34
|
+
);
|
|
35
|
+
} finally {
|
|
36
|
+
setLoading(false);
|
|
37
|
+
}
|
|
38
|
+
}, [client]);
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
fetchStatus();
|
|
42
|
+
}, [fetchStatus]);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
status,
|
|
46
|
+
loading,
|
|
47
|
+
error,
|
|
48
|
+
refetch: fetchStatus,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback } from "react";
|
|
4
|
+
import { useAiContext } from "../context/AiProvider";
|
|
5
|
+
|
|
6
|
+
export interface Prompt {
|
|
7
|
+
id: string;
|
|
8
|
+
slug?: string;
|
|
9
|
+
title: string;
|
|
10
|
+
content: string;
|
|
11
|
+
type: "text" | "image";
|
|
12
|
+
is_public: boolean;
|
|
13
|
+
favorite: boolean;
|
|
14
|
+
tags: string[];
|
|
15
|
+
created_at: string;
|
|
16
|
+
updated_at?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface PublicPrompt extends Prompt {
|
|
20
|
+
slug: string;
|
|
21
|
+
views: number;
|
|
22
|
+
used_count: number;
|
|
23
|
+
picked_count: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface UsePromptsOptions {
|
|
27
|
+
type?: "text" | "image";
|
|
28
|
+
favorite?: boolean;
|
|
29
|
+
public?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface UsePromptsReturn {
|
|
33
|
+
prompts: Prompt[] | PublicPrompt[];
|
|
34
|
+
loading: boolean;
|
|
35
|
+
error: string | null;
|
|
36
|
+
fetchPrompts: (options?: UsePromptsOptions) => Promise<void>;
|
|
37
|
+
createPrompt: (
|
|
38
|
+
data: Omit<Prompt, "id" | "created_at" | "updated_at">
|
|
39
|
+
) => Promise<Prompt | null>;
|
|
40
|
+
updatePrompt: (id: string, data: Partial<Prompt>) => Promise<Prompt | null>;
|
|
41
|
+
deletePrompt: (id: string) => Promise<boolean>;
|
|
42
|
+
incrementStat: (
|
|
43
|
+
promptId: string,
|
|
44
|
+
statType: "views" | "used" | "picked"
|
|
45
|
+
) => Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function usePrompts(): UsePromptsReturn {
|
|
49
|
+
const { apiKeyId } = useAiContext();
|
|
50
|
+
const [prompts, setPrompts] = useState<Prompt[] | PublicPrompt[]>([]);
|
|
51
|
+
const [loading, setLoading] = useState(false);
|
|
52
|
+
const [error, setError] = useState<string | null>(null);
|
|
53
|
+
|
|
54
|
+
const fetchPrompts = useCallback(async (options?: UsePromptsOptions) => {
|
|
55
|
+
try {
|
|
56
|
+
setLoading(true);
|
|
57
|
+
setError(null);
|
|
58
|
+
|
|
59
|
+
const params = new URLSearchParams();
|
|
60
|
+
if (options?.type) params.append("type", options.type);
|
|
61
|
+
if (options?.favorite !== undefined)
|
|
62
|
+
params.append("favorite", String(options.favorite));
|
|
63
|
+
|
|
64
|
+
// Use public route without auth if public=true, otherwise use auth route
|
|
65
|
+
const endpoint = options?.public
|
|
66
|
+
? `/api/ai/public/prompts?${params}`
|
|
67
|
+
: `/api/ai/auth/prompts?${params}`;
|
|
68
|
+
|
|
69
|
+
const response = await fetch(endpoint);
|
|
70
|
+
|
|
71
|
+
const data = await response.json();
|
|
72
|
+
|
|
73
|
+
if (response.ok) {
|
|
74
|
+
setPrompts(data.prompts || []);
|
|
75
|
+
} else {
|
|
76
|
+
setError(data.error || "Failed to fetch prompts");
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
setError(err instanceof Error ? err.message : "Unknown error");
|
|
80
|
+
} finally {
|
|
81
|
+
setLoading(false);
|
|
82
|
+
}
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
const createPrompt = useCallback(
|
|
86
|
+
async (data: Omit<Prompt, "id" | "created_at" | "updated_at">) => {
|
|
87
|
+
try {
|
|
88
|
+
setError(null);
|
|
89
|
+
|
|
90
|
+
const response = await fetch("/api/ai/auth/prompts", {
|
|
91
|
+
method: "POST",
|
|
92
|
+
headers: { "Content-Type": "application/json" },
|
|
93
|
+
body: JSON.stringify(data),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const result = await response.json();
|
|
97
|
+
|
|
98
|
+
if (response.ok) {
|
|
99
|
+
return result.prompt;
|
|
100
|
+
} else {
|
|
101
|
+
setError(result.error || "Failed to create prompt");
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
} catch (err) {
|
|
105
|
+
setError(err instanceof Error ? err.message : "Unknown error");
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
[]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const updatePrompt = useCallback(
|
|
113
|
+
async (id: string, data: Partial<Prompt>) => {
|
|
114
|
+
try {
|
|
115
|
+
setError(null);
|
|
116
|
+
|
|
117
|
+
const response = await fetch("/api/ai/auth/prompts", {
|
|
118
|
+
method: "PUT",
|
|
119
|
+
headers: { "Content-Type": "application/json" },
|
|
120
|
+
body: JSON.stringify({ id, ...data }),
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const result = await response.json();
|
|
124
|
+
|
|
125
|
+
if (response.ok) {
|
|
126
|
+
return result.prompt;
|
|
127
|
+
} else {
|
|
128
|
+
setError(result.error || "Failed to update prompt");
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
} catch (err) {
|
|
132
|
+
setError(err instanceof Error ? err.message : "Unknown error");
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
[]
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const deletePrompt = useCallback(async (id: string) => {
|
|
140
|
+
try {
|
|
141
|
+
setError(null);
|
|
142
|
+
|
|
143
|
+
const response = await fetch(`/api/ai/auth/prompts?id=${id}`, {
|
|
144
|
+
method: "DELETE",
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const result = await response.json();
|
|
148
|
+
|
|
149
|
+
if (response.ok) {
|
|
150
|
+
return true;
|
|
151
|
+
} else {
|
|
152
|
+
setError(result.error || "Failed to delete prompt");
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
} catch (err) {
|
|
156
|
+
setError(err instanceof Error ? err.message : "Unknown error");
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}, []);
|
|
160
|
+
|
|
161
|
+
const incrementStat = useCallback(
|
|
162
|
+
async (promptId: string, statType: "views" | "used" | "picked") => {
|
|
163
|
+
try {
|
|
164
|
+
await fetch("/api/ai/auth/prompts/stats", {
|
|
165
|
+
method: "POST",
|
|
166
|
+
headers: { "Content-Type": "application/json" },
|
|
167
|
+
body: JSON.stringify({ prompt_id: promptId, stat_type: statType }),
|
|
168
|
+
});
|
|
169
|
+
} catch (err) {
|
|
170
|
+
// Silent fail for stats
|
|
171
|
+
console.error("Failed to increment stat:", err);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
[]
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
prompts,
|
|
179
|
+
loading,
|
|
180
|
+
error,
|
|
181
|
+
fetchPrompts,
|
|
182
|
+
createPrompt,
|
|
183
|
+
updatePrompt,
|
|
184
|
+
deletePrompt,
|
|
185
|
+
incrementStat,
|
|
186
|
+
};
|
|
187
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
export * from "./types";
|
|
3
|
+
|
|
4
|
+
// Context
|
|
5
|
+
export * from "./context/AiProvider";
|
|
6
|
+
|
|
7
|
+
// Hooks
|
|
8
|
+
export * from "./hooks/useAiClient";
|
|
9
|
+
export * from "./hooks/useAiModels";
|
|
10
|
+
export * from "./hooks/useAiStatus";
|
|
11
|
+
export * from "./hooks/useAiCallText";
|
|
12
|
+
export * from "./hooks/useAiCallImage";
|
|
13
|
+
export * from "./hooks/usePrompts";
|
|
14
|
+
|
|
15
|
+
// Components
|
|
16
|
+
export * from "./components/AiPromptPanel";
|
|
17
|
+
export * from "./components/AiModelSelect";
|
|
18
|
+
export * from "./components/AiInput";
|
|
19
|
+
export * from "./components/AiTextarea";
|
|
20
|
+
export * from "./components/AiSelect";
|
|
21
|
+
export * from "./components/AiChipLabel";
|
|
22
|
+
export * from "./components/AiImageButton";
|
|
23
|
+
export * from "./components/AiSettingsButton";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ToastType = {
|
|
2
|
+
type: "success" | "error";
|
|
3
|
+
message: string;
|
|
4
|
+
code?: string;
|
|
5
|
+
};
|
|
6
|
+
export type UiMode = "modal" | "drawer";
|
|
7
|
+
|
|
8
|
+
export interface BaseAiProps {
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
apiKeyId?: string;
|
|
11
|
+
type?: UiMode;
|
|
12
|
+
context?: string | null;
|
|
13
|
+
model?: string | null;
|
|
14
|
+
prompt?: string | null;
|
|
15
|
+
editMode?: boolean;
|
|
16
|
+
onValue?: (value: string) => void;
|
|
17
|
+
onToast?: (toast: ToastType) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|