@blocklet/aigne-hub 0.2.7
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 +29 -0
- package/lib/cjs/api/ai-kit.js +60 -0
- package/lib/cjs/api/api.js +17 -0
- package/lib/cjs/api/app.js +57 -0
- package/lib/cjs/api/call/api.js +51 -0
- package/lib/cjs/api/call/app.js +74 -0
- package/lib/cjs/api/call/index.js +19 -0
- package/lib/cjs/api/call/proxy.js +64 -0
- package/lib/cjs/api/call/v1.js +166 -0
- package/lib/cjs/api/call/v2.js +101 -0
- package/lib/cjs/api/config.js +46 -0
- package/lib/cjs/api/constants.js +4 -0
- package/lib/cjs/api/error.js +42 -0
- package/lib/cjs/api/index.js +19 -0
- package/lib/cjs/api/types/audio.js +2 -0
- package/lib/cjs/api/types/chat.js +14 -0
- package/lib/cjs/api/types/embedding.js +2 -0
- package/lib/cjs/api/types/image.js +2 -0
- package/lib/cjs/api/types/index.js +19 -0
- package/lib/cjs/api/types/status.js +2 -0
- package/lib/cjs/api/utils/auth.js +90 -0
- package/lib/cjs/api/utils/event-stream.js +59 -0
- package/lib/cjs/components/conversation/conversation.js +71 -0
- package/lib/cjs/components/conversation/index.js +25 -0
- package/lib/cjs/components/conversation/message.js +120 -0
- package/lib/cjs/components/conversation/prompt.js +43 -0
- package/lib/cjs/components/conversation/use-conversation.js +100 -0
- package/lib/cjs/components/credit/alert.js +40 -0
- package/lib/cjs/components/credit/balance.js +95 -0
- package/lib/cjs/components/credit/button.js +69 -0
- package/lib/cjs/components/credit/index.js +12 -0
- package/lib/cjs/components/form-label.js +27 -0
- package/lib/cjs/components/image-preview.js +116 -0
- package/lib/cjs/components/index.js +45 -0
- package/lib/cjs/components/loading-image.js +37 -0
- package/lib/cjs/components/subscribe/alert.js +53 -0
- package/lib/cjs/components/subscribe/button.js +92 -0
- package/lib/cjs/components/subscribe/state.js +42 -0
- package/lib/cjs/components/switch-button.js +48 -0
- package/lib/cjs/components/table.js +203 -0
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/libs/logger.js +8 -0
- package/lib/cjs/utils/withLocaleProvider.js +11 -0
- package/lib/esm/api/ai-kit.js +54 -0
- package/lib/esm/api/api.js +11 -0
- package/lib/esm/api/app.js +42 -0
- package/lib/esm/api/call/api.js +24 -0
- package/lib/esm/api/call/app.js +68 -0
- package/lib/esm/api/call/index.js +3 -0
- package/lib/esm/api/call/proxy.js +58 -0
- package/lib/esm/api/call/v1.js +155 -0
- package/lib/esm/api/call/v2.js +93 -0
- package/lib/esm/api/config.js +41 -0
- package/lib/esm/api/constants.js +1 -0
- package/lib/esm/api/error.js +37 -0
- package/lib/esm/api/index.js +3 -0
- package/lib/esm/api/types/audio.js +1 -0
- package/lib/esm/api/types/chat.js +9 -0
- package/lib/esm/api/types/embedding.js +1 -0
- package/lib/esm/api/types/image.js +1 -0
- package/lib/esm/api/types/index.js +3 -0
- package/lib/esm/api/types/status.js +1 -0
- package/lib/esm/api/utils/auth.js +79 -0
- package/lib/esm/api/utils/event-stream.js +50 -0
- package/lib/esm/components/conversation/conversation.js +65 -0
- package/lib/esm/components/conversation/index.js +4 -0
- package/lib/esm/components/conversation/message.js +114 -0
- package/lib/esm/components/conversation/prompt.js +40 -0
- package/lib/esm/components/conversation/use-conversation.js +97 -0
- package/lib/esm/components/credit/alert.js +35 -0
- package/lib/esm/components/credit/balance.js +90 -0
- package/lib/esm/components/credit/button.js +64 -0
- package/lib/esm/components/credit/index.js +3 -0
- package/lib/esm/components/form-label.js +24 -0
- package/lib/esm/components/image-preview.js +110 -0
- package/lib/esm/components/index.js +14 -0
- package/lib/esm/components/loading-image.js +35 -0
- package/lib/esm/components/subscribe/alert.js +48 -0
- package/lib/esm/components/subscribe/button.js +87 -0
- package/lib/esm/components/subscribe/state.js +39 -0
- package/lib/esm/components/switch-button.js +46 -0
- package/lib/esm/components/table.js +198 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/libs/logger.js +3 -0
- package/lib/esm/utils/withLocaleProvider.js +8 -0
- package/lib/types/api/ai-kit.d.ts +70 -0
- package/lib/types/api/api.d.ts +4 -0
- package/lib/types/api/app.d.ts +113 -0
- package/lib/types/api/call/api.d.ts +2 -0
- package/lib/types/api/call/app.d.ts +50 -0
- package/lib/types/api/call/index.d.ts +3 -0
- package/lib/types/api/call/proxy.d.ts +6 -0
- package/lib/types/api/call/v1.d.ts +51 -0
- package/lib/types/api/call/v2.d.ts +30 -0
- package/lib/types/api/config.d.ts +14 -0
- package/lib/types/api/constants.d.ts +1 -0
- package/lib/types/api/error.d.ts +18 -0
- package/lib/types/api/index.d.ts +3 -0
- package/lib/types/api/types/audio.d.ts +18 -0
- package/lib/types/api/types/chat.d.ts +97 -0
- package/lib/types/api/types/embedding.d.ts +9 -0
- package/lib/types/api/types/image.d.ts +23 -0
- package/lib/types/api/types/index.d.ts +3 -0
- package/lib/types/api/types/status.d.ts +3 -0
- package/lib/types/api/utils/auth.d.ts +33 -0
- package/lib/types/api/utils/event-stream.d.ts +7 -0
- package/lib/types/components/conversation/conversation.d.ts +30 -0
- package/lib/types/components/conversation/index.d.ts +4 -0
- package/lib/types/components/conversation/message.d.ts +10 -0
- package/lib/types/components/conversation/prompt.d.ts +10 -0
- package/lib/types/components/conversation/use-conversation.d.ts +44 -0
- package/lib/types/components/credit/alert.d.ts +10 -0
- package/lib/types/components/credit/balance.d.ts +7 -0
- package/lib/types/components/credit/button.d.ts +11 -0
- package/lib/types/components/credit/index.d.ts +3 -0
- package/lib/types/components/form-label.d.ts +7 -0
- package/lib/types/components/image-preview.d.ts +17 -0
- package/lib/types/components/index.d.ts +12 -0
- package/lib/types/components/loading-image.d.ts +6 -0
- package/lib/types/components/subscribe/alert.d.ts +5 -0
- package/lib/types/components/subscribe/button.d.ts +5 -0
- package/lib/types/components/subscribe/state.d.ts +14 -0
- package/lib/types/components/switch-button.d.ts +7 -0
- package/lib/types/components/table.d.ts +3 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/libs/logger.d.ts +2 -0
- package/lib/types/utils/withLocaleProvider.d.ts +9 -0
- package/package.json +158 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from 'express';
|
|
2
|
+
export declare function proxyToAIKit(path: '/api/v1/status' | '/api/v1/chat/completions' | '/api/v1/image/generations' | '/api/v1/embeddings' | '/api/v1/audio/transcriptions' | '/api/v1/audio/speech' | '/api/app/status' | '/api/app/usage' | '/api/app/register' | '/api/user/credit/grants' | '/api/user/credit/balance' | '/api/user/credit/transactions' | '/api/user/credit/payment-link', { useAIKitService, proxyReqHeaders, proxyResHeaders, }?: {
|
|
3
|
+
useAIKitService?: boolean;
|
|
4
|
+
proxyReqHeaders?: string[];
|
|
5
|
+
proxyResHeaders?: string[];
|
|
6
|
+
}): (req: Request, res: Response, next: NextFunction) => void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { IncomingMessage } from 'http';
|
|
2
|
+
import { ReadableStream } from 'stream/web';
|
|
3
|
+
import { AxiosResponse } from 'axios';
|
|
4
|
+
import { ChatCompletionError, ChatCompletionInput, ChatCompletionResponse, EmbeddingInput, EmbeddingResponse, ImageGenerationInput, ImageGenerationResponse } from '../types';
|
|
5
|
+
import { AudioSpeechInput, AudioTranscriptionsInput } from '../types/audio';
|
|
6
|
+
import { StatusResponse } from '../types/status';
|
|
7
|
+
export declare function status(options?: {
|
|
8
|
+
useAIKitService?: boolean;
|
|
9
|
+
responseType?: undefined;
|
|
10
|
+
}): Promise<StatusResponse>;
|
|
11
|
+
export declare function status(options: {
|
|
12
|
+
useAIKitService?: boolean;
|
|
13
|
+
responseType: 'stream';
|
|
14
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
15
|
+
export declare function chatCompletions(input: ChatCompletionInput, options?: {
|
|
16
|
+
useAIKitService?: boolean;
|
|
17
|
+
responseType?: undefined;
|
|
18
|
+
}): Promise<ReadableStream<Exclude<ChatCompletionResponse, ChatCompletionError>>>;
|
|
19
|
+
export declare function chatCompletions(input: ChatCompletionInput, options: {
|
|
20
|
+
useAIKitService?: boolean;
|
|
21
|
+
responseType: 'stream';
|
|
22
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
23
|
+
export declare function imageGenerations(input: ImageGenerationInput, options?: {
|
|
24
|
+
useAIKitService?: boolean;
|
|
25
|
+
responseType?: undefined;
|
|
26
|
+
timeout?: number;
|
|
27
|
+
}): Promise<ImageGenerationResponse>;
|
|
28
|
+
export declare function imageGenerations(input: ImageGenerationInput, options: {
|
|
29
|
+
useAIKitService?: boolean;
|
|
30
|
+
responseType: 'stream';
|
|
31
|
+
timeout?: number;
|
|
32
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
33
|
+
export declare function embeddings(input: EmbeddingInput, options?: {
|
|
34
|
+
useAIKitService?: boolean;
|
|
35
|
+
responseType?: undefined;
|
|
36
|
+
}): Promise<EmbeddingResponse>;
|
|
37
|
+
export declare function embeddings(input: EmbeddingInput, options: {
|
|
38
|
+
useAIKitService?: boolean;
|
|
39
|
+
responseType: 'stream';
|
|
40
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
41
|
+
export declare function audioTranscriptions(input: AudioTranscriptionsInput, options?: {
|
|
42
|
+
useAIKitService?: boolean;
|
|
43
|
+
responseType?: undefined;
|
|
44
|
+
}): Promise<EmbeddingResponse>;
|
|
45
|
+
export declare function audioTranscriptions(input: AudioTranscriptionsInput, options: {
|
|
46
|
+
useAIKitService?: boolean;
|
|
47
|
+
responseType: 'stream';
|
|
48
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
49
|
+
export declare function audioSpeech(input: AudioSpeechInput, { useAIKitService }?: {
|
|
50
|
+
useAIKitService?: boolean;
|
|
51
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IncomingMessage } from 'http';
|
|
2
|
+
import { ReadableStream } from 'stream/web';
|
|
3
|
+
import { AxiosResponse } from 'axios';
|
|
4
|
+
import { ChatCompletionError, ChatCompletionInput, ChatCompletionResponse, EmbeddingInput, EmbeddingResponse, ImageGenerationInput, ImageGenerationResponse } from '../types';
|
|
5
|
+
export declare function chatCompletionsV2(input: ChatCompletionInput, options?: {
|
|
6
|
+
useAIKitService?: boolean;
|
|
7
|
+
responseType?: undefined;
|
|
8
|
+
}): Promise<ReadableStream<Exclude<ChatCompletionResponse, ChatCompletionError>>>;
|
|
9
|
+
export declare function chatCompletionsV2(input: ChatCompletionInput, options: {
|
|
10
|
+
useAIKitService?: boolean;
|
|
11
|
+
responseType: 'stream';
|
|
12
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
13
|
+
export declare function imageGenerationsV2(input: ImageGenerationInput, options?: {
|
|
14
|
+
useAIKitService?: boolean;
|
|
15
|
+
responseType?: undefined;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}): Promise<ImageGenerationResponse>;
|
|
18
|
+
export declare function imageGenerationsV2(input: ImageGenerationInput, options: {
|
|
19
|
+
useAIKitService?: boolean;
|
|
20
|
+
responseType: 'stream';
|
|
21
|
+
timeout?: number;
|
|
22
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
23
|
+
export declare function embeddingsV2(input: EmbeddingInput, options?: {
|
|
24
|
+
useAIKitService?: boolean;
|
|
25
|
+
responseType?: undefined;
|
|
26
|
+
}): Promise<EmbeddingResponse>;
|
|
27
|
+
export declare function embeddingsV2(input: EmbeddingInput, options: {
|
|
28
|
+
useAIKitService?: boolean;
|
|
29
|
+
responseType: 'stream';
|
|
30
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
declare class Config extends EventEmitter {
|
|
3
|
+
static CONFIG_FILE_PATH: string;
|
|
4
|
+
constructor();
|
|
5
|
+
private reloadConfigFile;
|
|
6
|
+
config: {
|
|
7
|
+
useAIKitService?: boolean;
|
|
8
|
+
} | undefined;
|
|
9
|
+
get useAIKitService(): boolean | undefined;
|
|
10
|
+
set useAIKitService(value: boolean | undefined);
|
|
11
|
+
save(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
declare const AIKitConfig: Config;
|
|
14
|
+
export default AIKitConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AI_KIT_BASE_URL: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum SubscriptionErrorType {
|
|
2
|
+
UNSUBSCRIBED = "UNSUBSCRIBED",
|
|
3
|
+
UNKNOWN = "UNKNOWN"
|
|
4
|
+
}
|
|
5
|
+
export declare enum CreditErrorType {
|
|
6
|
+
NOT_ENOUGH = "NOT_ENOUGH",
|
|
7
|
+
UNKNOWN = "UNKNOWN"
|
|
8
|
+
}
|
|
9
|
+
export declare class SubscriptionError extends Error {
|
|
10
|
+
timestamp: string;
|
|
11
|
+
type: SubscriptionErrorType;
|
|
12
|
+
constructor(type: SubscriptionErrorType);
|
|
13
|
+
}
|
|
14
|
+
export declare class CreditError extends Error {
|
|
15
|
+
timestamp: string;
|
|
16
|
+
type: CreditErrorType;
|
|
17
|
+
constructor(type: CreditErrorType, link?: string);
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReadStream } from 'fs';
|
|
2
|
+
import type { Readable } from 'stream';
|
|
3
|
+
import type { ReadableStream } from 'stream/web';
|
|
4
|
+
export interface AudioTranscriptionsInput {
|
|
5
|
+
file: Buffer | ReadStream | Readable | ReadableStream;
|
|
6
|
+
model: string;
|
|
7
|
+
language?: string;
|
|
8
|
+
prompt?: string;
|
|
9
|
+
responseFormat?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
|
|
10
|
+
temperature?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface AudioSpeechInput {
|
|
13
|
+
model: string;
|
|
14
|
+
input: string;
|
|
15
|
+
voice: string;
|
|
16
|
+
responseFormat?: 'mp3' | 'opus' | 'aac' | 'and' | 'flac';
|
|
17
|
+
speed?: 0.25 | 4.0 | 1.0;
|
|
18
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export interface ChatCompletionInput {
|
|
2
|
+
stream?: boolean;
|
|
3
|
+
model?: string;
|
|
4
|
+
messages: ({
|
|
5
|
+
role: 'system';
|
|
6
|
+
content: string;
|
|
7
|
+
} | {
|
|
8
|
+
role: 'user';
|
|
9
|
+
content: string | ({
|
|
10
|
+
type: 'text';
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'image_url';
|
|
14
|
+
imageUrl: {
|
|
15
|
+
url: string;
|
|
16
|
+
};
|
|
17
|
+
})[];
|
|
18
|
+
} | {
|
|
19
|
+
role: 'assistant';
|
|
20
|
+
content?: string;
|
|
21
|
+
toolCalls?: {
|
|
22
|
+
id: string;
|
|
23
|
+
type: 'function';
|
|
24
|
+
function: {
|
|
25
|
+
name: string;
|
|
26
|
+
arguments: string;
|
|
27
|
+
};
|
|
28
|
+
}[];
|
|
29
|
+
} | {
|
|
30
|
+
role: 'tool';
|
|
31
|
+
content: string;
|
|
32
|
+
toolCallId: string;
|
|
33
|
+
})[];
|
|
34
|
+
temperature?: number;
|
|
35
|
+
topP?: number;
|
|
36
|
+
presencePenalty?: number;
|
|
37
|
+
frequencyPenalty?: number;
|
|
38
|
+
maxTokens?: number;
|
|
39
|
+
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
40
|
+
type: 'function';
|
|
41
|
+
function: {
|
|
42
|
+
name: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
tools?: {
|
|
47
|
+
type: 'function';
|
|
48
|
+
function: {
|
|
49
|
+
name: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
parameters: Record<string, any>;
|
|
52
|
+
};
|
|
53
|
+
}[];
|
|
54
|
+
responseFormat?: {
|
|
55
|
+
type?: 'text' | 'json_object';
|
|
56
|
+
} | {
|
|
57
|
+
type: 'json_schema';
|
|
58
|
+
jsonSchema: {
|
|
59
|
+
name: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
schema: Record<string, any>;
|
|
62
|
+
strict?: boolean;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export type ChatCompletionResponse = ChatCompletionChunk | ChatCompletionError | ChatCompletionUsage;
|
|
67
|
+
export interface ChatCompletionChunk {
|
|
68
|
+
delta: {
|
|
69
|
+
role?: 'system' | 'user' | 'assistant' | 'tool' | 'developer';
|
|
70
|
+
content?: string | null;
|
|
71
|
+
toolCalls?: {
|
|
72
|
+
id?: string;
|
|
73
|
+
type?: 'function';
|
|
74
|
+
function?: {
|
|
75
|
+
name?: string;
|
|
76
|
+
arguments?: string;
|
|
77
|
+
};
|
|
78
|
+
}[];
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export interface ChatCompletionError {
|
|
82
|
+
error: {
|
|
83
|
+
message: string;
|
|
84
|
+
type?: string;
|
|
85
|
+
timestamp?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface ChatCompletionUsage {
|
|
89
|
+
usage: {
|
|
90
|
+
promptTokens: number;
|
|
91
|
+
completionTokens: number;
|
|
92
|
+
totalTokens: number;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export declare function isChatCompletionChunk(data: ChatCompletionResponse): data is ChatCompletionChunk;
|
|
96
|
+
export declare function isChatCompletionUsage(data: ChatCompletionResponse): data is ChatCompletionUsage;
|
|
97
|
+
export declare function isChatCompletionError(data: ChatCompletionResponse): data is ChatCompletionError;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface ImageGenerationInput {
|
|
2
|
+
model?: string;
|
|
3
|
+
image?: string | string[];
|
|
4
|
+
prompt: string;
|
|
5
|
+
size?: '256x256' | '512x512' | '1024x1024' | '1024x1792' | '1792x1024' | '1536x1024' | '1024x1536' | 'auto';
|
|
6
|
+
n?: number;
|
|
7
|
+
responseFormat?: 'url' | 'b64_json';
|
|
8
|
+
style?: 'vivid' | 'natural';
|
|
9
|
+
quality?: 'standard' | 'hd' | 'high' | 'medium' | 'low' | 'auto';
|
|
10
|
+
background?: 'transparent' | 'opaque' | 'auto';
|
|
11
|
+
outputFormat?: 'jpeg' | 'png' | 'webp';
|
|
12
|
+
moderation?: 'low' | 'auto';
|
|
13
|
+
outputCompression?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ImageGenerationResponse {
|
|
16
|
+
data: ({
|
|
17
|
+
url: string;
|
|
18
|
+
b64Json?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
url?: undefined;
|
|
21
|
+
b64Json: string;
|
|
22
|
+
})[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BytesType } from '@ocap/util';
|
|
2
|
+
import type { WalletObject } from '@ocap/wallet';
|
|
3
|
+
import type { NextFunction, Request, Response } from 'express';
|
|
4
|
+
export declare const wallet: WalletObject;
|
|
5
|
+
export declare const ensureAdmin: (req: Request & {
|
|
6
|
+
user?: import("@blocklet/sdk/lib/util/login").SessionUser;
|
|
7
|
+
}, res: Response, next: NextFunction) => Promise<void>;
|
|
8
|
+
export declare function appIdFromPublicKey(publicKey: BytesType): string;
|
|
9
|
+
export declare function verifyRemoteComponentCall({ appId, timestamp, data, sig, pk, userDid, expiresIn, }: {
|
|
10
|
+
appId: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
data: object;
|
|
13
|
+
sig: string;
|
|
14
|
+
pk: BytesType;
|
|
15
|
+
userDid?: string;
|
|
16
|
+
expiresIn?: number;
|
|
17
|
+
}): boolean;
|
|
18
|
+
export declare function signRemoteComponentCall({ data, userDid }: {
|
|
19
|
+
data: object;
|
|
20
|
+
userDid?: string;
|
|
21
|
+
}): {
|
|
22
|
+
appId: string;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
userDid: string | undefined;
|
|
25
|
+
sig: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function getRemoteComponentCallHeaders(data: object, userDid?: string): {
|
|
28
|
+
'x-app-id': string;
|
|
29
|
+
'x-timestamp': string;
|
|
30
|
+
'x-component-sig': string;
|
|
31
|
+
'x-app-user-did': string;
|
|
32
|
+
};
|
|
33
|
+
export declare function ensureRemoteComponentCall(getPublicKey: (appId: string) => Promise<BytesType>, fallback?: (req: Request, res: Response, next: NextFunction) => any): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
import { ReadableStream, TransformStream } from 'stream/web';
|
|
3
|
+
export declare function readableToWeb(readable: Readable): ReadableStream<any>;
|
|
4
|
+
export declare class EventSourceParserStream<T> extends TransformStream<any, T> {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare function tryParseJsonFromResponseStream<T>(data: Readable): Promise<T | undefined>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BoxProps } from '@mui/material';
|
|
2
|
+
import { ChatCompletionMessageParam } from 'openai/resources/index';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { PromptProps } from './prompt';
|
|
5
|
+
export interface MessageItem {
|
|
6
|
+
id: string;
|
|
7
|
+
prompt?: string | ChatCompletionMessageParam[];
|
|
8
|
+
response?: string | {
|
|
9
|
+
url: string;
|
|
10
|
+
}[];
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
error?: {
|
|
13
|
+
message: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
meta?: any;
|
|
17
|
+
}
|
|
18
|
+
export interface ConversationRef {
|
|
19
|
+
scrollToBottom: (options?: {
|
|
20
|
+
force?: boolean;
|
|
21
|
+
}) => void;
|
|
22
|
+
}
|
|
23
|
+
export default function Conversation({ ref, messages, onSubmit, customActions, renderAvatar, maxWidth, scrollContainer, promptProps, ...props }: Omit<BoxProps, 'onSubmit'> & {
|
|
24
|
+
messages: MessageItem[];
|
|
25
|
+
onSubmit: (prompt: string) => void;
|
|
26
|
+
customActions?: (item: MessageItem) => Array<ReactNode[]>;
|
|
27
|
+
renderAvatar?: (item: MessageItem, isAI: boolean) => ReactNode;
|
|
28
|
+
scrollContainer?: HTMLElement;
|
|
29
|
+
promptProps?: Partial<PromptProps>;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BoxProps } from '@mui/material';
|
|
2
|
+
import { ChatCompletionMessageParam } from 'openai/resources/index';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
export default function Message({ avatar, message, children, loading, actions, ...props }: {
|
|
5
|
+
avatar?: ReactNode;
|
|
6
|
+
message?: string | ChatCompletionMessageParam[];
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
actions?: ReactNode[];
|
|
10
|
+
} & BoxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BoxProps, SxProps } from '@mui/material';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface PromptProps extends Omit<BoxProps<'form'>, 'onSubmit' | 'sx'> {
|
|
4
|
+
onSubmit: (prompt: string) => any;
|
|
5
|
+
startAdornment?: ReactNode;
|
|
6
|
+
endAdornment?: ReactNode;
|
|
7
|
+
slotProps?: any;
|
|
8
|
+
sx?: SxProps;
|
|
9
|
+
}
|
|
10
|
+
export default function Prompt({ startAdornment, endAdornment, onSubmit, slotProps, sx, ...props }: PromptProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ChatCompletionMessageParam } from 'openai/resources/index';
|
|
2
|
+
import { MessageItem } from './conversation';
|
|
3
|
+
export default function useConversation({ scrollToBottom, textCompletions, imageGenerations, }: {
|
|
4
|
+
scrollToBottom?: (options?: {
|
|
5
|
+
force?: boolean;
|
|
6
|
+
}) => void;
|
|
7
|
+
textCompletions: (prompt: string | ChatCompletionMessageParam[], options: {
|
|
8
|
+
meta?: any;
|
|
9
|
+
}) => Promise<ReadableStream<string | Uint8Array | {
|
|
10
|
+
type: 'text';
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'images';
|
|
14
|
+
images: {
|
|
15
|
+
url: string;
|
|
16
|
+
}[];
|
|
17
|
+
}>>;
|
|
18
|
+
imageGenerations?: (prompt: {
|
|
19
|
+
prompt: string;
|
|
20
|
+
n: number;
|
|
21
|
+
size: string;
|
|
22
|
+
}, options: {
|
|
23
|
+
meta?: any;
|
|
24
|
+
}) => Promise<{
|
|
25
|
+
url: string;
|
|
26
|
+
}[]>;
|
|
27
|
+
}): {
|
|
28
|
+
messages: MessageItem[];
|
|
29
|
+
add: (prompt: string | ChatCompletionMessageParam[], meta?: any) => Promise<{
|
|
30
|
+
id: string;
|
|
31
|
+
data: {
|
|
32
|
+
url: string;
|
|
33
|
+
}[];
|
|
34
|
+
text?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
id: string;
|
|
37
|
+
text: string | {
|
|
38
|
+
url: string;
|
|
39
|
+
}[];
|
|
40
|
+
data?: undefined;
|
|
41
|
+
}>;
|
|
42
|
+
cancel: ({ id }: Pick<MessageItem, "id">) => void;
|
|
43
|
+
setMessages: import("react").Dispatch<import("react").SetStateAction<MessageItem[]>>;
|
|
44
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AlertProps } from '@mui/material';
|
|
2
|
+
import { CreditErrorType } from '../../api/error';
|
|
3
|
+
interface CreditError {
|
|
4
|
+
type: CreditErrorType;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: import("react").ComponentType<{
|
|
8
|
+
error: CreditError;
|
|
9
|
+
} & AlertProps>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const _default: import("react").ComponentType<{
|
|
2
|
+
shouldOpenInNewTab?: boolean;
|
|
3
|
+
size?: "small" | "medium" | "large";
|
|
4
|
+
variant?: "text" | "outlined" | "contained";
|
|
5
|
+
color?: "primary" | "secondary" | "error" | "info" | "success" | "warning";
|
|
6
|
+
useAIKitService?: boolean;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & import("@mui/lab").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
9
|
+
ref?: ((instance: HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
10
|
+
}, "href" | "className" | "style" | "classes" | "children" | "tabIndex" | "color" | "disabled" | "sx" | "action" | "loading" | "size" | "variant" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "loadingIndicator" | "disableElevation" | "endIcon" | "fullWidth" | "loadingPosition" | "startIcon">>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FormLabelProps } from '@mui/material';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
export default function CustomFormLabel({ children, required, tooltip, description, ...props }: FormLabelProps & {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
tooltip?: ReactNode | string;
|
|
6
|
+
description?: ReactNode | string;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface ImagePreviewProps {
|
|
2
|
+
dataSource?: Array<{
|
|
3
|
+
src: string;
|
|
4
|
+
alt?: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
}>;
|
|
8
|
+
spacing?: number;
|
|
9
|
+
itemWidth?: number;
|
|
10
|
+
itemHeight?: number;
|
|
11
|
+
transition?: string;
|
|
12
|
+
borderRadius?: number;
|
|
13
|
+
formatDownloadSrc?: (src: string) => string;
|
|
14
|
+
showDownloadButton?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export default function ImagePreview({ dataSource, itemWidth, itemHeight, spacing, transition, borderRadius, formatDownloadSrc, showDownloadButton, }: ImagePreviewProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { default as LoadingImage } from './loading-image';
|
|
2
|
+
export { default as ImagePreview } from './image-preview';
|
|
3
|
+
export { default as Conversation } from './conversation';
|
|
4
|
+
export * from './conversation';
|
|
5
|
+
export { default as SubscribeButton } from './subscribe/button';
|
|
6
|
+
export { default as SubscribeErrorAlert } from './subscribe/alert';
|
|
7
|
+
export { default as CreditButton } from './credit/button';
|
|
8
|
+
export { default as CreditBalance } from './credit/balance';
|
|
9
|
+
export { default as CreditErrorAlert } from './credit/alert';
|
|
10
|
+
export { default as Switch } from './switch-button';
|
|
11
|
+
export { default as Table } from './table';
|
|
12
|
+
export { default as FormLabel } from './form-label';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ImgHTMLAttributes } from 'react';
|
|
2
|
+
declare function LoadingImage({ ref, onLoad, ...props }: {
|
|
3
|
+
ref?: any;
|
|
4
|
+
onLoad?: () => void;
|
|
5
|
+
} & Omit<ImgHTMLAttributes<HTMLImageElement>, 'onLoad'>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default LoadingImage;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AIKitServiceConfig, AppStatusResult } from '../../api/app';
|
|
2
|
+
export interface AIKitServiceStatus {
|
|
3
|
+
app?: AppStatusResult;
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
error?: Error;
|
|
6
|
+
fetch: () => Promise<void>;
|
|
7
|
+
setConfig: (config: AIKitServiceConfig) => Promise<void>;
|
|
8
|
+
computed: {
|
|
9
|
+
isSubscriptionAvailable?: boolean;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare const useAIKitServiceStatus: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<AIKitServiceStatus>, "setState"> & {
|
|
13
|
+
setState(nextStateOrUpdater: AIKitServiceStatus | Partial<AIKitServiceStatus> | ((state: import("immer").WritableDraft<AIKitServiceStatus>) => void), shouldReplace?: boolean | undefined): void;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SwitchProps as MuiSwitchProps } from '@mui/material';
|
|
2
|
+
import type { LiteralUnion } from 'type-fest';
|
|
3
|
+
type CustomSwitchProps = {
|
|
4
|
+
variant?: LiteralUnion<'success' | 'error' | 'warning' | 'info' | 'primary' | 'secondary', string>;
|
|
5
|
+
} & MuiSwitchProps;
|
|
6
|
+
declare const SwitchButton: React.FC<CustomSwitchProps>;
|
|
7
|
+
export default SwitchButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
export default function withLocaleProvider<T>(C: ComponentType<T>, { translations, fallbackLocale, }: {
|
|
3
|
+
fallbackLocale?: string;
|
|
4
|
+
translations: {
|
|
5
|
+
[locale: string]: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
}): ComponentType<T>;
|