@smart-cloud/ai-kit-ui 1.4.11 → 1.4.13
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/ShadowBoundary.d.ts +29 -0
- package/dist/ai-chatbot/AiChatbot.d.ts +15 -0
- package/dist/ai-chatbot/attachmentStorage.d.ts +19 -0
- package/dist/ai-chatbot/index.d.ts +1 -0
- package/dist/ai-feature/AiFeature.d.ts +28 -0
- package/dist/ai-feature/AiFeatureBorder.d.ts +5 -0
- package/dist/ai-feature/ProofreadDiff.d.ts +13 -0
- package/dist/ai-feature/index.d.ts +2 -0
- package/dist/ai-feature/utils.d.ts +1 -0
- package/dist/doc-search/DocSearch.d.ts +18 -0
- package/dist/doc-search/index.d.ts +1 -0
- package/dist/i18n/ar.d.ts +1 -0
- package/dist/i18n/de.d.ts +1 -0
- package/dist/i18n/en.d.ts +1 -0
- package/dist/i18n/es.d.ts +1 -0
- package/dist/i18n/fr.d.ts +1 -0
- package/dist/i18n/he.d.ts +1 -0
- package/dist/i18n/hi.d.ts +1 -0
- package/dist/i18n/hu.d.ts +1 -0
- package/dist/i18n/id.d.ts +1 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/it.d.ts +1 -0
- package/dist/i18n/ja.d.ts +1 -0
- package/dist/i18n/ko.d.ts +1 -0
- package/dist/i18n/nb.d.ts +1 -0
- package/dist/i18n/nl.d.ts +1 -0
- package/dist/i18n/pl.d.ts +1 -0
- package/dist/i18n/pt.d.ts +1 -0
- package/dist/i18n/ru.d.ts +1 -0
- package/dist/i18n/sv.d.ts +1 -0
- package/dist/i18n/th.d.ts +1 -0
- package/dist/i18n/tr.d.ts +1 -0
- package/dist/i18n/ua.d.ts +1 -0
- package/dist/i18n/zh.d.ts +1 -0
- package/dist/index.cjs +6 -6
- package/dist/index.d.ts +6 -112
- package/dist/index.js +6 -6
- package/dist/poweredBy.d.ts +4 -0
- package/dist/useAiRun.d.ts +38 -0
- package/dist/withAiKitShell.d.ts +7 -0
- package/package.json +28 -26
- package/src/doc-search/DocSearch.tsx +85 -39
- package/tsconfig.types.json +13 -0
- package/tsup.config.ts +1 -1
- package/dist/index.d.cts +0 -112
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AiKitLanguageCode, type AiKitStatusEvent } from "@smart-cloud/ai-kit-core";
|
|
2
|
+
export type AiRunState<T> = {
|
|
3
|
+
busy: boolean;
|
|
4
|
+
error: string | null;
|
|
5
|
+
statusEvent: AiKitStatusEvent | null;
|
|
6
|
+
result: T | null;
|
|
7
|
+
isCancelled: boolean;
|
|
8
|
+
/** Last known execution source (best-effort). */
|
|
9
|
+
lastSource: "on-device" | "backend" | null;
|
|
10
|
+
};
|
|
11
|
+
export type AiFeatureFunction<T> = (args: {
|
|
12
|
+
signal: AbortSignal;
|
|
13
|
+
onStatus: (e: AiKitStatusEvent) => void;
|
|
14
|
+
}) => Promise<T>;
|
|
15
|
+
export type UseAiRunResult<T> = AiRunState<T> & {
|
|
16
|
+
run: (func: AiFeatureFunction<T>) => Promise<T | null>;
|
|
17
|
+
cancel: () => void;
|
|
18
|
+
reset: () => void;
|
|
19
|
+
/** Current AbortSignal, if a run is in-flight. */
|
|
20
|
+
signal: AbortSignal | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Returns true if backend routing is configured in the current AiKit settings.
|
|
24
|
+
*
|
|
25
|
+
* This is intentionally conservative: it only checks *configuration*, not reachability.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isBackendConfigured(): Promise<boolean>;
|
|
28
|
+
export declare function readDefaultOutputLanguage(): AiKitLanguageCode;
|
|
29
|
+
/**
|
|
30
|
+
* Removes a single surrounding Markdown code fence.
|
|
31
|
+
*
|
|
32
|
+
* Handles common model outputs like:
|
|
33
|
+
* ```json
|
|
34
|
+
* {"a":1}
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function stripCodeFence(text: string): string;
|
|
38
|
+
export declare function useAiRun<T>(): UseAiRunResult<T>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AiWorkerProps } from "@smart-cloud/ai-kit-core";
|
|
2
|
+
import { type ComponentType } from "react";
|
|
3
|
+
export type AiKitShellInjectedProps = {
|
|
4
|
+
language?: string;
|
|
5
|
+
rootElement: HTMLElement;
|
|
6
|
+
};
|
|
7
|
+
export declare function withAiKitShell<P extends object>(RootComponent: ComponentType<P & AiKitShellInjectedProps>, propOverrides?: Partial<AiWorkerProps>): import("react").FC<P & Partial<AiWorkerProps>>;
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart-cloud/ai-kit-ui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "
|
|
10
|
+
"build": "yarn build:js && yarn build:types",
|
|
11
|
+
"build:js": "tsup --minify",
|
|
12
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
11
13
|
"lint": "eslint 'src/**/*.{ts,tsx}' --report-unused-disable-directives --max-warnings 0",
|
|
12
14
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
-
"publish": "WPSUITE_PREMIUM=true
|
|
15
|
+
"publish": "WPSUITE_PREMIUM=true yarn build && npm publish --access=public"
|
|
14
16
|
},
|
|
15
17
|
"publishConfig": {
|
|
16
18
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -19,16 +21,16 @@
|
|
|
19
21
|
"dependencies": {
|
|
20
22
|
"@emotion/cache": "^11.14.0",
|
|
21
23
|
"@emotion/react": "^11.14.0",
|
|
22
|
-
"@mantine/colors-generator": "^8.3.
|
|
23
|
-
"@smart-cloud/ai-kit-core": "^1.4.
|
|
24
|
-
"@smart-cloud/wpsuite-core": "^2.2.
|
|
25
|
-
"@tabler/icons-react": "^3.
|
|
24
|
+
"@mantine/colors-generator": "^8.3.18",
|
|
25
|
+
"@smart-cloud/ai-kit-core": "^1.4.8",
|
|
26
|
+
"@smart-cloud/wpsuite-core": "^2.2.11",
|
|
27
|
+
"@tabler/icons-react": "^3.41.1",
|
|
26
28
|
"chroma-js": "^3.2.0",
|
|
27
|
-
"country-flag-icons": "^1.6.
|
|
29
|
+
"country-flag-icons": "^1.6.16",
|
|
28
30
|
"react-markdown": "^10.1.0",
|
|
29
31
|
"rehype-parse": "^9.0.1",
|
|
30
32
|
"rehype-raw": "^7.0.0",
|
|
31
|
-
"rehype-remark": "^10.0.
|
|
33
|
+
"rehype-remark": "^10.0.1",
|
|
32
34
|
"rehype-sanitize": "^6.0.0",
|
|
33
35
|
"rehype-stringify": "^10.0.1",
|
|
34
36
|
"remark-gfm": "^4.0.1",
|
|
@@ -38,36 +40,36 @@
|
|
|
38
40
|
"unified": "^11.0.5"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
41
|
-
"@mantine/core": "^8.3.
|
|
42
|
-
"@mantine/hooks": "^8.3.
|
|
43
|
-
"@mantine/modals": "^8.3.
|
|
44
|
-
"@wordpress/data": "^10.
|
|
45
|
-
"aws-amplify": "^6.16.
|
|
43
|
+
"@mantine/core": "^8.3.18",
|
|
44
|
+
"@mantine/hooks": "^8.3.18",
|
|
45
|
+
"@mantine/modals": "^8.3.18",
|
|
46
|
+
"@wordpress/data": "^10.44.0",
|
|
47
|
+
"aws-amplify": "^6.16.4",
|
|
46
48
|
"react": "^18.3.1",
|
|
47
49
|
"react-dom": "^18.3.1"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
52
|
"@eslint/js": "^10.0.1",
|
|
51
|
-
"@mantine/core": "^8.3.
|
|
52
|
-
"@mantine/hooks": "^8.3.
|
|
53
|
-
"@mantine/modals": "^8.3.
|
|
54
|
-
"@types/dom-chromium-ai": "^0.0.
|
|
53
|
+
"@mantine/core": "^8.3.18",
|
|
54
|
+
"@mantine/hooks": "^8.3.18",
|
|
55
|
+
"@mantine/modals": "^8.3.18",
|
|
56
|
+
"@types/dom-chromium-ai": "^0.0.16",
|
|
55
57
|
"@types/jquery": "^4.0.0",
|
|
56
58
|
"@types/react": "^18.3.23",
|
|
57
59
|
"@types/react-dom": "^18.3.7",
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
59
|
-
"@typescript-eslint/parser": "^8.
|
|
60
|
-
"@wordpress/data": "^10.
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
61
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
62
|
+
"@wordpress/data": "^10.44.0",
|
|
61
63
|
"ajv": "^8.18.0",
|
|
62
|
-
"aws-amplify": "^6.16.
|
|
63
|
-
"eslint": "^10.
|
|
64
|
-
"globals": "^17.
|
|
64
|
+
"aws-amplify": "^6.16.4",
|
|
65
|
+
"eslint": "^10.2.1",
|
|
66
|
+
"globals": "^17.5.0",
|
|
65
67
|
"jquery": "^4.0.0",
|
|
66
68
|
"react": "^18.3.1",
|
|
67
69
|
"react-dom": "^18.3.1",
|
|
68
70
|
"tsup": "^8.5.1",
|
|
69
|
-
"typescript": "^
|
|
70
|
-
"typescript-eslint": "^8.
|
|
71
|
+
"typescript": "^6.0.3",
|
|
72
|
+
"typescript-eslint": "^8.58.2"
|
|
71
73
|
},
|
|
72
74
|
"exports": {
|
|
73
75
|
".": {
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
AiKitDocSearchIcon,
|
|
21
21
|
CapabilityDecision,
|
|
22
|
+
type ContextKind,
|
|
22
23
|
dispatchBackend,
|
|
23
24
|
resolveBackend,
|
|
24
25
|
sendSearchMessage,
|
|
@@ -51,8 +52,75 @@ I18n.putVocabularies(translations);
|
|
|
51
52
|
|
|
52
53
|
type Props = DocSearchProps & AiKitShellInjectedProps;
|
|
53
54
|
|
|
55
|
+
type MetadataOptions = {
|
|
56
|
+
allowedCategories: Record<string, string[]>;
|
|
57
|
+
allowedTags: string[];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const metadataOptionsCache = new Map<string, MetadataOptions>();
|
|
61
|
+
const metadataOptionsRequestCache = new Map<string, Promise<MetadataOptions>>();
|
|
62
|
+
|
|
54
63
|
const USE_AUDIO = false; // Set to true to enable audio recording feature (requires backend support for audio input)
|
|
55
64
|
|
|
65
|
+
async function loadMetadataOptionsFromBackend(
|
|
66
|
+
context: ContextKind,
|
|
67
|
+
): Promise<MetadataOptions> {
|
|
68
|
+
const cached = metadataOptionsCache.get(context);
|
|
69
|
+
if (cached) {
|
|
70
|
+
return cached;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const inFlight = metadataOptionsRequestCache.get(context);
|
|
74
|
+
if (inFlight) {
|
|
75
|
+
return inFlight;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const request = (async () => {
|
|
79
|
+
const backend = await resolveBackend();
|
|
80
|
+
|
|
81
|
+
if (!backend.available) {
|
|
82
|
+
throw new Error("Backend not available for metadata options");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const decision: CapabilityDecision = {
|
|
86
|
+
feature: "prompt",
|
|
87
|
+
source: "backend",
|
|
88
|
+
mode: "backend-only",
|
|
89
|
+
onDeviceAvailable: false,
|
|
90
|
+
backendAvailable: backend.available,
|
|
91
|
+
backendTransport: backend.transport,
|
|
92
|
+
backendApiName: backend.apiName,
|
|
93
|
+
backendBaseUrl: backend.baseUrl,
|
|
94
|
+
reason: backend.reason ?? "",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const data = (await dispatchBackend(
|
|
98
|
+
decision,
|
|
99
|
+
context,
|
|
100
|
+
"/kb/metadata-options",
|
|
101
|
+
"GET",
|
|
102
|
+
null,
|
|
103
|
+
{},
|
|
104
|
+
)) as MetadataOptions;
|
|
105
|
+
|
|
106
|
+
const normalized: MetadataOptions = {
|
|
107
|
+
allowedCategories: data.allowedCategories || {},
|
|
108
|
+
allowedTags: data.allowedTags || [],
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
metadataOptionsCache.set(context, normalized);
|
|
112
|
+
return normalized;
|
|
113
|
+
})();
|
|
114
|
+
|
|
115
|
+
metadataOptionsRequestCache.set(context, request);
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
return await request;
|
|
119
|
+
} finally {
|
|
120
|
+
metadataOptionsRequestCache.delete(context);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
56
124
|
function groupChunksByDoc(result: SearchResult | null) {
|
|
57
125
|
const docs = result?.citations?.docs ?? [];
|
|
58
126
|
const chunks = result?.citations?.chunks ?? [];
|
|
@@ -157,10 +225,8 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
157
225
|
);
|
|
158
226
|
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
|
159
227
|
const [tagSearchValue, setTagSearchValue] = useState<string>("");
|
|
160
|
-
const [metadataOptions, setMetadataOptions] =
|
|
161
|
-
|
|
162
|
-
allowedTags: string[];
|
|
163
|
-
} | null>(null);
|
|
228
|
+
const [metadataOptions, setMetadataOptions] =
|
|
229
|
+
useState<MetadataOptions | null>(null);
|
|
164
230
|
const [loadingMetadata, setLoadingMetadata] = useState(false);
|
|
165
231
|
const animationFrameRef = useRef<number | null>(null);
|
|
166
232
|
|
|
@@ -351,6 +417,8 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
351
417
|
useEffect(() => {
|
|
352
418
|
if (!enableUserFilters) return;
|
|
353
419
|
|
|
420
|
+
if (showOpenButton && !featureOpen) return;
|
|
421
|
+
|
|
354
422
|
// Use provided options if available
|
|
355
423
|
if (availableCategories || availableTags) {
|
|
356
424
|
setMetadataOptions({
|
|
@@ -362,43 +430,14 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
362
430
|
|
|
363
431
|
// Otherwise fetch from backend
|
|
364
432
|
const loadMetadata = async () => {
|
|
433
|
+
const effectiveContext: ContextKind =
|
|
434
|
+
context === "admin" ? "admin" : "frontend";
|
|
435
|
+
|
|
365
436
|
setLoadingMetadata(true);
|
|
366
437
|
try {
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
if (!backend.available) {
|
|
370
|
-
console.error("Backend not available for metadata options");
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
438
|
+
const data = await loadMetadataOptionsFromBackend(effectiveContext);
|
|
373
439
|
|
|
374
|
-
|
|
375
|
-
feature: "prompt",
|
|
376
|
-
source: "backend",
|
|
377
|
-
mode: "backend-only",
|
|
378
|
-
onDeviceAvailable: false,
|
|
379
|
-
backendAvailable: backend.available,
|
|
380
|
-
backendTransport: backend.transport,
|
|
381
|
-
backendApiName: backend.apiName,
|
|
382
|
-
backendBaseUrl: backend.baseUrl,
|
|
383
|
-
reason: backend.reason ?? "",
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
const data = (await dispatchBackend(
|
|
387
|
-
decision,
|
|
388
|
-
context ?? "frontend",
|
|
389
|
-
"/kb/metadata-options",
|
|
390
|
-
"GET",
|
|
391
|
-
null,
|
|
392
|
-
{},
|
|
393
|
-
)) as {
|
|
394
|
-
allowedCategories: Record<string, string[]>;
|
|
395
|
-
allowedTags: string[];
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
setMetadataOptions({
|
|
399
|
-
allowedCategories: data.allowedCategories || {},
|
|
400
|
-
allowedTags: data.allowedTags || [],
|
|
401
|
-
});
|
|
440
|
+
setMetadataOptions(data);
|
|
402
441
|
} catch (error) {
|
|
403
442
|
console.error("Failed to load metadata options:", error);
|
|
404
443
|
} finally {
|
|
@@ -407,7 +446,14 @@ const DocSearchBase: FC<Props> = (props) => {
|
|
|
407
446
|
};
|
|
408
447
|
|
|
409
448
|
void loadMetadata();
|
|
410
|
-
}, [
|
|
449
|
+
}, [
|
|
450
|
+
enableUserFilters,
|
|
451
|
+
availableCategories,
|
|
452
|
+
availableTags,
|
|
453
|
+
context,
|
|
454
|
+
featureOpen,
|
|
455
|
+
showOpenButton,
|
|
456
|
+
]);
|
|
411
457
|
|
|
412
458
|
const onSearch = useCallback(async () => {
|
|
413
459
|
let q: string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": false,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"emitDeclarationOnly": true,
|
|
7
|
+
"declarationMap": false,
|
|
8
|
+
"rootDir": "src",
|
|
9
|
+
"outDir": "dist"
|
|
10
|
+
},
|
|
11
|
+
"include": ["src"],
|
|
12
|
+
"exclude": ["dist", "build", "node_modules", "tsup.config.ts"]
|
|
13
|
+
}
|
package/tsup.config.ts
CHANGED
package/dist/index.d.cts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import * as _smart_cloud_ai_kit_core from '@smart-cloud/ai-kit-core';
|
|
2
|
-
import { AiModePreference, HistoryStorageMode, AiChatbotLabels, AiKitStatusEvent, AiKitLanguageCode, AiWorkerProps } from '@smart-cloud/ai-kit-core';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import React__default, { FC, ComponentType } from 'react';
|
|
5
|
-
|
|
6
|
-
declare const AiFeature: FC<_smart_cloud_ai_kit_core.AiWorkerProps & {
|
|
7
|
-
mode: _smart_cloud_ai_kit_core.AiFeatureMode;
|
|
8
|
-
context?: _smart_cloud_ai_kit_core.ContextKind;
|
|
9
|
-
modeOverride?: AiModePreference;
|
|
10
|
-
autoRun?: boolean;
|
|
11
|
-
onDeviceTimeout?: number;
|
|
12
|
-
editable?: boolean;
|
|
13
|
-
acceptButtonTitle?: string;
|
|
14
|
-
showRegenerateOnBackendButton?: boolean;
|
|
15
|
-
optionsDisplay?: "collapse" | "horizontal" | "vertical";
|
|
16
|
-
default?: _smart_cloud_ai_kit_core.AiFeatureOptions & {
|
|
17
|
-
getText?: Promise<string> | (() => Promise<string>);
|
|
18
|
-
image?: Blob;
|
|
19
|
-
};
|
|
20
|
-
allowOverride?: {
|
|
21
|
-
text?: boolean;
|
|
22
|
-
instructions?: boolean;
|
|
23
|
-
tone?: boolean;
|
|
24
|
-
length?: boolean;
|
|
25
|
-
type?: boolean;
|
|
26
|
-
outputLanguage?: boolean;
|
|
27
|
-
outputFormat?: boolean;
|
|
28
|
-
};
|
|
29
|
-
onAccept?: (result: unknown) => void;
|
|
30
|
-
onOptionsChanged?: (options: _smart_cloud_ai_kit_core.AiFeatureOptions) => void;
|
|
31
|
-
} & Partial<_smart_cloud_ai_kit_core.AiWorkerProps>>;
|
|
32
|
-
|
|
33
|
-
declare const markdownToHtml: (markdown: string) => Promise<string>;
|
|
34
|
-
|
|
35
|
-
declare const DEFAULT_CHATBOT_LABELS: Required<AiChatbotLabels>;
|
|
36
|
-
declare const AiChatbot: React__default.FC<_smart_cloud_ai_kit_core.AiWorkerProps & {
|
|
37
|
-
context?: _smart_cloud_ai_kit_core.ContextKind;
|
|
38
|
-
placeholder?: string;
|
|
39
|
-
maxImages?: number;
|
|
40
|
-
maxImageBytes?: number;
|
|
41
|
-
previewMode?: boolean;
|
|
42
|
-
historyStorage?: HistoryStorageMode;
|
|
43
|
-
emptyHistoryAfterDays?: number;
|
|
44
|
-
labels?: AiChatbotLabels;
|
|
45
|
-
openButtonIconLayout?: _smart_cloud_ai_kit_core.OpenButtonIconLayout;
|
|
46
|
-
openButtonPosition?: _smart_cloud_ai_kit_core.OpenButtonPosition;
|
|
47
|
-
} & Partial<_smart_cloud_ai_kit_core.AiWorkerProps>>;
|
|
48
|
-
|
|
49
|
-
declare const DocSearch: FC<_smart_cloud_ai_kit_core.AiWorkerProps & {
|
|
50
|
-
context?: _smart_cloud_ai_kit_core.ContextKind;
|
|
51
|
-
autoRun?: boolean;
|
|
52
|
-
title?: string;
|
|
53
|
-
getSearchText?: () => string;
|
|
54
|
-
searchButtonIcon?: string;
|
|
55
|
-
showSearchButtonTitle?: boolean;
|
|
56
|
-
showSearchButtonIcon?: boolean;
|
|
57
|
-
showSources?: boolean;
|
|
58
|
-
topK?: number;
|
|
59
|
-
snippetMaxChars?: number;
|
|
60
|
-
onClickDoc?: (doc: _smart_cloud_ai_kit_core.RetrievedDoc) => void;
|
|
61
|
-
enableUserFilters?: boolean;
|
|
62
|
-
availableCategories?: Record<string, string[]>;
|
|
63
|
-
availableTags?: string[];
|
|
64
|
-
} & Partial<_smart_cloud_ai_kit_core.AiWorkerProps>>;
|
|
65
|
-
|
|
66
|
-
type AiRunState<T> = {
|
|
67
|
-
busy: boolean;
|
|
68
|
-
error: string | null;
|
|
69
|
-
statusEvent: AiKitStatusEvent | null;
|
|
70
|
-
result: T | null;
|
|
71
|
-
isCancelled: boolean;
|
|
72
|
-
/** Last known execution source (best-effort). */
|
|
73
|
-
lastSource: "on-device" | "backend" | null;
|
|
74
|
-
};
|
|
75
|
-
type AiFeatureFunction<T> = (args: {
|
|
76
|
-
signal: AbortSignal;
|
|
77
|
-
onStatus: (e: AiKitStatusEvent) => void;
|
|
78
|
-
}) => Promise<T>;
|
|
79
|
-
type UseAiRunResult<T> = AiRunState<T> & {
|
|
80
|
-
run: (func: AiFeatureFunction<T>) => Promise<T | null>;
|
|
81
|
-
cancel: () => void;
|
|
82
|
-
reset: () => void;
|
|
83
|
-
/** Current AbortSignal, if a run is in-flight. */
|
|
84
|
-
signal: AbortSignal | null;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Returns true if backend routing is configured in the current AiKit settings.
|
|
88
|
-
*
|
|
89
|
-
* This is intentionally conservative: it only checks *configuration*, not reachability.
|
|
90
|
-
*/
|
|
91
|
-
declare function isBackendConfigured(): Promise<boolean>;
|
|
92
|
-
declare function readDefaultOutputLanguage(): AiKitLanguageCode;
|
|
93
|
-
/**
|
|
94
|
-
* Removes a single surrounding Markdown code fence.
|
|
95
|
-
*
|
|
96
|
-
* Handles common model outputs like:
|
|
97
|
-
* ```json
|
|
98
|
-
* {"a":1}
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
declare function stripCodeFence(text: string): string;
|
|
102
|
-
declare function useAiRun<T>(): UseAiRunResult<T>;
|
|
103
|
-
|
|
104
|
-
type AiKitShellInjectedProps = {
|
|
105
|
-
language?: string;
|
|
106
|
-
rootElement: HTMLElement;
|
|
107
|
-
};
|
|
108
|
-
declare function withAiKitShell<P extends object>(RootComponent: ComponentType<P & AiKitShellInjectedProps>, propOverrides?: Partial<AiWorkerProps>): React.FC<P & Partial<AiWorkerProps>>;
|
|
109
|
-
|
|
110
|
-
declare const translations: Record<string, Record<string, string>>;
|
|
111
|
-
|
|
112
|
-
export { AiChatbot, AiFeature, type AiFeatureFunction, type AiRunState, DEFAULT_CHATBOT_LABELS, DocSearch, type UseAiRunResult, isBackendConfigured, markdownToHtml, readDefaultOutputLanguage, stripCodeFence, translations, useAiRun, withAiKitShell };
|