ctod 0.7.0 → 0.7.1
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/.api-key +1 -0
- package/.nyc_output/42919e68-b472-4a5d-b2d3-5d5153f28467.json +1 -0
- package/.nyc_output/processinfo/42919e68-b472-4a5d-b2d3-5d5153f28467.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/.output/.output/stores//344/270/200/345/240/264/346/234/237/345/276/205/345/267/262/344/271/205/347/232/204/345/222/214/350/247/243/cover-0.png +1 -0
- package/.output/.output/stores//344/270/200/345/240/264/346/234/237/345/276/205/345/267/262/344/271/205/347/232/204/345/222/214/350/247/243/cover-1.png +1 -0
- package/.output/.output/stores//344/270/200/345/240/264/346/234/237/345/276/205/345/267/262/344/271/205/347/232/204/345/222/214/350/247/243/story-config.json +4 -0
- package/.output/.output/stores//344/270/200/345/240/264/346/234/237/345/276/205/345/267/262/344/271/205/347/232/204/345/222/214/350/247/243/story.json +22 -0
- package/.output/.output/stores//345/276/236/351/273/221/346/232/227/350/265/260/345/220/221/345/205/211/346/230/216/cover-0.png +1 -0
- package/.output/.output/stores//345/276/236/351/273/221/346/232/227/350/265/260/345/220/221/345/205/211/346/230/216/cover-1.png +1 -0
- package/.output/.output/stores//345/276/236/351/273/221/346/232/227/350/265/260/345/220/221/345/205/211/346/230/216/story-config.json +4 -0
- package/.output/.output/stores//345/276/236/351/273/221/346/232/227/350/265/260/345/220/221/345/205/211/346/230/216/story.json +24 -0
- package/.output/.output/stores//347/240/264/347/242/216/347/232/204/345/271/273/350/261/241/cover-0.png +1 -0
- package/.output/.output/stores//347/240/264/347/242/216/347/232/204/345/271/273/350/261/241/cover-1.png +1 -0
- package/.output/.output/stores//347/240/264/347/242/216/347/232/204/345/271/273/350/261/241/story-config.json +4 -0
- package/.output/.output/stores//347/240/264/347/242/216/347/232/204/345/271/273/350/261/241/story.json +24 -0
- package/.output/.output/stores//350/227/235/350/241/223/345/256/266/347/232/204/351/235/210/346/204/237/cover-0.png +1 -0
- package/.output/.output/stores//350/227/235/350/241/223/345/256/266/347/232/204/351/235/210/346/204/237/cover-1.png +1 -0
- package/.output/.output/stores//350/227/235/350/241/223/345/256/266/347/232/204/351/235/210/346/204/237/story-config.json +4 -0
- package/.output/.output/stores//350/227/235/350/241/223/345/256/266/347/232/204/351/235/210/346/204/237/story.json +28 -0
- package/.output/.output/stores//350/250/230/346/206/266/345/225/206/344/272/272/cover-0.png +1 -0
- package/.output/.output/stores//350/250/230/346/206/266/345/225/206/344/272/272/cover-1.png +1 -0
- package/.output/.output/stores//350/250/230/346/206/266/345/225/206/344/272/272/story-config.json +4 -0
- package/.output/.output/stores//350/250/230/346/206/266/345/225/206/344/272/272/story.json +18 -0
- package/.output/.output/stores//350/250/255/350/250/210/350/210/207/351/226/213/347/231/274/347/232/204/346/214/221/346/210/260/content.json +22 -0
- package/.output/.output/talks//344/273/245/347/254/221/350/251/261/347/202/272/345/237/272/347/244/216/347/232/204/351/235/242/350/251/246/content.json +30 -0
- package/.output/.output/talks//344/273/245/347/254/221/350/251/261/347/202/272/345/237/272/347/244/216/347/232/204/351/235/242/350/251/246/cover-1684055229695.png +0 -0
- package/.output/.output/talks//345/234/250/346/224/277/346/262/273/345/200/231/351/201/270/344/272/272/350/276/257/350/253/226/344/270/255/347/232/204/350/252/252/346/234/215/346/200/247/346/272/235/351/200/232/content.json +30 -0
- package/.output/.output/talks//345/234/250/346/224/277/346/262/273/345/200/231/351/201/270/344/272/272/350/276/257/350/253/226/344/270/255/347/232/204/350/252/252/346/234/215/346/200/247/346/272/235/351/200/232/cover-1684056611678.png +0 -0
- package/.output/.output/talks//346/224/276/351/254/206/347/232/204/345/200/231/351/201/270/344/272/272/351/200/262/350/241/214/346/224/277/346/262/273/350/276/257/350/253/226/content.json +36 -0
- package/.output/.output/talks//346/224/276/351/254/206/347/232/204/345/200/231/351/201/270/344/272/272/351/200/262/350/241/214/346/224/277/346/262/273/350/276/257/350/253/226/cover-1684055140609.png +0 -0
- package/.output/.output/talks//346/224/277/346/262/273/347/254/221/350/251/261/content.json +30 -0
- package/.output/.output/talks//346/224/277/346/262/273/347/254/221/350/251/261/cover-1684056246465.png +0 -0
- package/.output/.output/talks//350/251/274/350/253/247/345/256/266/351/225/267/346/225/231/345/270/253/346/234/203/350/255/260/content.json +26 -0
- package/.output/.output/talks//350/251/274/350/253/247/345/256/266/351/225/267/346/225/231/345/270/253/346/234/203/350/255/260/cover-1685785935121.png +0 -0
- package/.output/.output/talks//350/262/241/345/213/231/351/241/247/345/225/217/350/253/256/350/251/242/content.json +26 -0
- package/.output/.output/talks//350/262/241/345/213/231/351/241/247/345/225/217/350/253/256/350/251/242/cover-1685785115833.png +0 -0
- package/.output/.output/talks//351/206/253/347/224/237/345/222/214/347/227/205/344/272/272/350/250/216/350/253/226/346/202/262/345/202/267/content.json +32 -0
- package/.output/.output/talks//351/206/253/347/224/237/345/222/214/347/227/205/344/272/272/350/250/216/350/253/226/346/202/262/345/202/267/cover-1684055075942.png +0 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/examples/basic.ts +0 -89
- package/examples/llama.cpp.ts +0 -56
- package/examples/plugin.ts +0 -118
- package/lib/broker/chat.ts +0 -435
- package/lib/core/parser.ts +0 -62
- package/lib/core/plugin.ts +0 -46
- package/lib/core/translator.ts +0 -115
- package/lib/ctod.ts +0 -71
- package/lib/index.ts +0 -41
- package/lib/plugins/index.ts +0 -38
- package/lib/plugins/limiter.ts +0 -103
- package/lib/plugins/print-log.ts +0 -35
- package/lib/plugins/retry.ts +0 -25
- package/lib/plugins/role.ts +0 -28
- package/lib/service/llama3.cpp/completion.ts +0 -313
- package/lib/service/llama3.cpp/index.ts +0 -53
- package/lib/service/openai/chat.ts +0 -244
- package/lib/service/openai/images-generation.ts +0 -64
- package/lib/service/openai/index.ts +0 -97
- package/lib/service/openai/vision.ts +0 -111
- package/lib/shims.d.ts +0 -4
- package/lib/templates.ts +0 -71
- package/lib/types.ts +0 -4
- package/lib/utils/error.ts +0 -14
- package/lib/utils/validate.ts +0 -64
- package/logo.ai +2 -1141
- package/logo.png +0 -0
- package/types/examples/basic.d.ts +0 -1
- package/types/examples/chat-demo.d.ts +0 -2
- package/types/examples/chat-for-llama.cpp-demo.d.ts +0 -2
- package/types/examples/chat-with-json-schema-demo.d.ts +0 -2
- package/types/examples/llama.cpp.d.ts +0 -2
- package/types/examples/plugin-demo.d.ts +0 -2
- package/types/examples/plugin.d.ts +0 -2
- package/types/examples/stream-for-llama.cpp-demo.d.ts +0 -2
- package/types/examples/vision-demo.d.ts +0 -2
- package/types/lib/broker/chat.d.ts +0 -150
- package/types/lib/core/parser.d.ts +0 -32
- package/types/lib/core/plugin.d.ts +0 -34
- package/types/lib/core/translator.d.ts +0 -67
- package/types/lib/ctod.d.ts +0 -32
- package/types/lib/index.d.ts +0 -34
- package/types/lib/plugins/index.d.ts +0 -47
- package/types/lib/plugins/limiter.d.ts +0 -36
- package/types/lib/plugins/print-log.d.ts +0 -5
- package/types/lib/plugins/retry.d.ts +0 -6
- package/types/lib/plugins/role.d.ts +0 -5
- package/types/lib/service/llama3.cpp/completion.d.ts +0 -61
- package/types/lib/service/llama3.cpp/index.d.ts +0 -19
- package/types/lib/service/openai/chat.d.ts +0 -110
- package/types/lib/service/openai/completion.d.ts +0 -59
- package/types/lib/service/openai/images-generation.d.ts +0 -35
- package/types/lib/service/openai/index.d.ts +0 -29
- package/types/lib/service/openai/vision.d.ts +0 -74
- package/types/lib/templates.d.ts +0 -20
- package/types/lib/types.d.ts +0 -1
- package/types/lib/utils/error.d.ts +0 -11
- package/types/lib/utils/validate.d.ts +0 -16
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { OpenAI } from './index';
|
|
2
|
-
import { PromiseResponseType } from '../../types';
|
|
3
|
-
export type ChatGPTMessage = {
|
|
4
|
-
role: 'system' | 'user' | 'assistant';
|
|
5
|
-
name?: string;
|
|
6
|
-
content: string;
|
|
7
|
-
};
|
|
8
|
-
type ApiResponse = {
|
|
9
|
-
id: string;
|
|
10
|
-
object: string;
|
|
11
|
-
created: number;
|
|
12
|
-
choices: Array<{
|
|
13
|
-
index: number;
|
|
14
|
-
finish_reason: string;
|
|
15
|
-
message: {
|
|
16
|
-
role: 'system' | 'user' | 'assistant';
|
|
17
|
-
name?: string;
|
|
18
|
-
content: string;
|
|
19
|
-
};
|
|
20
|
-
}>;
|
|
21
|
-
usage: {
|
|
22
|
-
prompt_tokens: number;
|
|
23
|
-
completion_tokens: number;
|
|
24
|
-
total_tokens: number;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export type Config = {
|
|
28
|
-
/**
|
|
29
|
-
* @zh 一次回應數量
|
|
30
|
-
* @en How many chat completion choices to generate for each input message.
|
|
31
|
-
*/
|
|
32
|
-
n: number;
|
|
33
|
-
/**
|
|
34
|
-
* @zh 選擇運行的模型,16k意味著能處理長度為 16,384 的文本,32k意味著能處理長度為 32768 的文本。
|
|
35
|
-
* @en How many chat completion choices to generate for each input message.
|
|
36
|
-
*/
|
|
37
|
-
model: 'gpt-4' | 'gpt-3.5-turbo' | 'gpt-4-turbo' | 'gpt-4o' | 'gpt-4o-mini' | 'o1-preview' | 'o1' | 'o1-mini';
|
|
38
|
-
/**
|
|
39
|
-
* @zh 冒險指數,數值由 0 ~ 2 之間,越低回應越穩定。
|
|
40
|
-
* @en What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
|
|
41
|
-
*/
|
|
42
|
-
temperature: number;
|
|
43
|
-
/**
|
|
44
|
-
* @zh 是否強制要回傳 JSON 格式的資料
|
|
45
|
-
* @en Whether to force the return of JSON format data
|
|
46
|
-
*/
|
|
47
|
-
forceJsonFormat: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* @zh 每次對話最多產生幾個 tokens。
|
|
50
|
-
* @en How many tokens to complete to.
|
|
51
|
-
*/
|
|
52
|
-
maxTokens?: number;
|
|
53
|
-
};
|
|
54
|
-
export declare class OpenAIChat {
|
|
55
|
-
openai: OpenAI;
|
|
56
|
-
config: Config;
|
|
57
|
-
constructor(openai: OpenAI);
|
|
58
|
-
/**
|
|
59
|
-
* @zh 改變對話的一些設定
|
|
60
|
-
* @en Change some settings of the conversation
|
|
61
|
-
*/
|
|
62
|
-
setConfig(options: Partial<Config>): void;
|
|
63
|
-
/**
|
|
64
|
-
* @zh 檢視內容是否符合 OpenAI 的審查
|
|
65
|
-
* @en View content for OpenAI moderation
|
|
66
|
-
*/
|
|
67
|
-
moderations(input: string): Promise<{
|
|
68
|
-
isSafe: boolean;
|
|
69
|
-
result: any;
|
|
70
|
-
}>;
|
|
71
|
-
/**
|
|
72
|
-
* @zh 進行對話
|
|
73
|
-
* @en Talk to the AI
|
|
74
|
-
*/
|
|
75
|
-
talk(messages?: ChatGPTMessage[], options?: {
|
|
76
|
-
/** 要 forceJsonFormat 為 true 才會生效 */
|
|
77
|
-
jsonSchema?: any;
|
|
78
|
-
abortController?: AbortController;
|
|
79
|
-
}): Promise<{
|
|
80
|
-
id: string;
|
|
81
|
-
text: string;
|
|
82
|
-
newMessages: ChatGPTMessage[];
|
|
83
|
-
isDone: boolean;
|
|
84
|
-
apiReseponse: ApiResponse;
|
|
85
|
-
}>;
|
|
86
|
-
talkStream(params: {
|
|
87
|
-
messages: any[];
|
|
88
|
-
onMessage: (message: string) => void;
|
|
89
|
-
onEnd: () => void;
|
|
90
|
-
onWarn: (warn: any) => void;
|
|
91
|
-
onError: (error: any) => void;
|
|
92
|
-
}): {
|
|
93
|
-
cancel: () => void;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* @zh 開啟持續性對話
|
|
97
|
-
*/
|
|
98
|
-
keepTalk(prompt: string | string[], oldMessages?: ChatGPTMessage[]): Promise<{
|
|
99
|
-
result: {
|
|
100
|
-
id: string;
|
|
101
|
-
text: string;
|
|
102
|
-
newMessages: ChatGPTMessage[];
|
|
103
|
-
isDone: boolean;
|
|
104
|
-
apiReseponse: ApiResponse;
|
|
105
|
-
};
|
|
106
|
-
nextTalk: (prompt: string | string[]) => Promise<any>;
|
|
107
|
-
}>;
|
|
108
|
-
}
|
|
109
|
-
export type OpenAIChatTalkResponse = PromiseResponseType<OpenAIChat['talk']>;
|
|
110
|
-
export {};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { OpenAI } from './index';
|
|
2
|
-
import { PromiseResponseType } from '../../types';
|
|
3
|
-
declare type Config = {
|
|
4
|
-
/**
|
|
5
|
-
* @zh 一次回應數量
|
|
6
|
-
* @en How many chat completion choices to generate for each input message.
|
|
7
|
-
*/
|
|
8
|
-
n: number;
|
|
9
|
-
/**
|
|
10
|
-
* @zh 最長回應長度,最大值為 4096。
|
|
11
|
-
* @en The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
|
|
12
|
-
* @see https://platform.openai.com/tokenizer
|
|
13
|
-
*/
|
|
14
|
-
maxTokens: number;
|
|
15
|
-
/**
|
|
16
|
-
* @zh 冒險指數,數值由 0 ~ 2 之間。
|
|
17
|
-
* @en What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
|
|
18
|
-
*/
|
|
19
|
-
temperature: number;
|
|
20
|
-
};
|
|
21
|
-
declare type ApiResponse = {
|
|
22
|
-
id: string;
|
|
23
|
-
object: string;
|
|
24
|
-
created: number;
|
|
25
|
-
model: string;
|
|
26
|
-
choices: Array<{
|
|
27
|
-
text: string;
|
|
28
|
-
index: number;
|
|
29
|
-
logprobs: any;
|
|
30
|
-
finish_reason: string;
|
|
31
|
-
}>;
|
|
32
|
-
usage: {
|
|
33
|
-
prompt_tokens: number;
|
|
34
|
-
completion_tokens: number;
|
|
35
|
-
total_tokens: number;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export declare class OpenAICompletion {
|
|
39
|
-
private openai;
|
|
40
|
-
private config;
|
|
41
|
-
constructor(openai: OpenAI);
|
|
42
|
-
/**
|
|
43
|
-
* @zh 改變對話的一些設定。
|
|
44
|
-
* @en Change some settings of the chat.
|
|
45
|
-
*/
|
|
46
|
-
setConfig(options: Partial<Config>): void;
|
|
47
|
-
/**
|
|
48
|
-
* @zh 進行補文。
|
|
49
|
-
* @en Do completion.
|
|
50
|
-
*/
|
|
51
|
-
run(prompt: string | string[]): Promise<{
|
|
52
|
-
id: string;
|
|
53
|
-
text: string;
|
|
54
|
-
isDone: boolean;
|
|
55
|
-
apiReseponse: ApiResponse;
|
|
56
|
-
}>;
|
|
57
|
-
}
|
|
58
|
-
export declare type OpenAiOpenAICompletionResponse = PromiseResponseType<OpenAICompletion['run']>;
|
|
59
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { OpenAI } from './index';
|
|
2
|
-
type ApiResponse = {
|
|
3
|
-
created: string;
|
|
4
|
-
data: {
|
|
5
|
-
b64_json: string;
|
|
6
|
-
}[];
|
|
7
|
-
};
|
|
8
|
-
type Config = {
|
|
9
|
-
/**
|
|
10
|
-
* @zh 模型,支援 dall-e-2 和 dall-e-3
|
|
11
|
-
* @en Model, support dall-e-2 and dall-e-3
|
|
12
|
-
*/
|
|
13
|
-
model: 'dall-e-2' | 'dall-e-3';
|
|
14
|
-
/**
|
|
15
|
-
* @zh 解析度,例如 1024x1024
|
|
16
|
-
* @en Resolution, for example 1024x1024
|
|
17
|
-
*/
|
|
18
|
-
size: `${number}x${number}`;
|
|
19
|
-
};
|
|
20
|
-
export declare class OpenAIImagesGeneration {
|
|
21
|
-
private openai;
|
|
22
|
-
private config;
|
|
23
|
-
constructor(openai: OpenAI);
|
|
24
|
-
/**
|
|
25
|
-
* @zh 改變對話的一些設定
|
|
26
|
-
* @en Change some settings of the conversation
|
|
27
|
-
*/
|
|
28
|
-
setConfig(options: Partial<Config>): void;
|
|
29
|
-
/**
|
|
30
|
-
* @zh 產生圖片
|
|
31
|
-
* @en Generate image
|
|
32
|
-
*/
|
|
33
|
-
create(prompt: string): Promise<ApiResponse>;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { OpenAIVision } from './vision';
|
|
2
|
-
import { OpenAIChat, Config } from './chat';
|
|
3
|
-
import { OpenAIImagesGeneration } from './images-generation';
|
|
4
|
-
export declare class OpenAI {
|
|
5
|
-
_axios: import("axios").AxiosInstance;
|
|
6
|
-
_apiKey: string;
|
|
7
|
-
static createChatRequest(apiKey: string | (() => Promise<string>), config?: Partial<Config> | (() => Promise<Partial<Config>>), options?: {
|
|
8
|
-
axios?: any;
|
|
9
|
-
}): (messages: any[], { onCancel }: any) => Promise<string>;
|
|
10
|
-
static createChatRequestWithJsonSchema(params: {
|
|
11
|
-
axios?: any;
|
|
12
|
-
apiKey: string | (() => Promise<string>);
|
|
13
|
-
config?: Partial<Pick<Config, 'model' | 'temperature'>> | (() => Promise<Partial<Pick<Config, 'model' | 'temperature'>>>);
|
|
14
|
-
}): (messages: any[], { schema, onCancel }: any) => Promise<string>;
|
|
15
|
-
constructor(apiKey?: string);
|
|
16
|
-
/**
|
|
17
|
-
* @zh 如果你有需要特別設定 axios,請使用這方法。
|
|
18
|
-
* @en If you need to set axios, please use this method.
|
|
19
|
-
*/
|
|
20
|
-
setAxios(axios: any): void;
|
|
21
|
-
/**
|
|
22
|
-
* @zh 設定 api key。
|
|
23
|
-
* @en Set api key.
|
|
24
|
-
*/
|
|
25
|
-
setConfiguration(apiKey: string): void;
|
|
26
|
-
createChat(): OpenAIChat;
|
|
27
|
-
createVision(): OpenAIVision;
|
|
28
|
-
createImagesGeneration(): OpenAIImagesGeneration;
|
|
29
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { OpenAI } from './index';
|
|
2
|
-
import { PromiseResponseType } from '../../types';
|
|
3
|
-
type ImageContent = {
|
|
4
|
-
type: 'image_url' | 'text';
|
|
5
|
-
text?: string;
|
|
6
|
-
image_url?: {
|
|
7
|
-
url: string;
|
|
8
|
-
detail?: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
type VisionMessage = {
|
|
12
|
-
role: 'system' | 'user' | 'assistant';
|
|
13
|
-
name?: string;
|
|
14
|
-
content: string | ImageContent[];
|
|
15
|
-
};
|
|
16
|
-
type ApiResponse = {
|
|
17
|
-
id: string;
|
|
18
|
-
object: string;
|
|
19
|
-
created: number;
|
|
20
|
-
model: string;
|
|
21
|
-
usage: {
|
|
22
|
-
prompt_tokens: number;
|
|
23
|
-
completion_tokens: number;
|
|
24
|
-
total_tokens: number;
|
|
25
|
-
};
|
|
26
|
-
choices: Array<{
|
|
27
|
-
message: {
|
|
28
|
-
role: string;
|
|
29
|
-
content: string;
|
|
30
|
-
};
|
|
31
|
-
finish_details: {
|
|
32
|
-
type: string;
|
|
33
|
-
};
|
|
34
|
-
index: number;
|
|
35
|
-
}>;
|
|
36
|
-
};
|
|
37
|
-
export type Config = {
|
|
38
|
-
/**
|
|
39
|
-
* @zh 選擇運行的模型。
|
|
40
|
-
* @en How many chat completion choices to generate for each input message.
|
|
41
|
-
*/
|
|
42
|
-
model: 'gpt-4-vision-preview';
|
|
43
|
-
/**
|
|
44
|
-
* @zh 冒險指數,數值由 0 ~ 2 之間。
|
|
45
|
-
* @en What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
|
|
46
|
-
*/
|
|
47
|
-
temperature: number;
|
|
48
|
-
/**
|
|
49
|
-
* @zh 每次對話最多產生幾個 tokens。
|
|
50
|
-
* @en How many tokens to complete to.
|
|
51
|
-
*/
|
|
52
|
-
maxTokens?: number;
|
|
53
|
-
};
|
|
54
|
-
export declare class OpenAIVision {
|
|
55
|
-
openai: OpenAI;
|
|
56
|
-
config: Config;
|
|
57
|
-
constructor(openai: OpenAI);
|
|
58
|
-
/**
|
|
59
|
-
* @zh 改變對話的一些設定
|
|
60
|
-
* @en Change some settings of the conversation
|
|
61
|
-
*/
|
|
62
|
-
setConfig(options: Partial<Config>): void;
|
|
63
|
-
/**
|
|
64
|
-
* @zh 辨識圖片
|
|
65
|
-
* @en Recognize images
|
|
66
|
-
*/
|
|
67
|
-
view(messages: VisionMessage[]): Promise<{
|
|
68
|
-
id: string;
|
|
69
|
-
text: string;
|
|
70
|
-
apiReseponse: ApiResponse;
|
|
71
|
-
}>;
|
|
72
|
-
}
|
|
73
|
-
export type OpenAIChatVisionResponse = PromiseResponseType<OpenAIVision['view']>;
|
|
74
|
-
export {};
|
package/types/lib/templates.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type JsonResponseFormat = {
|
|
2
|
-
desc: string;
|
|
3
|
-
example: any;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* @zh 協助使用者將格式需求轉成論敘語句。
|
|
7
|
-
* @en Assist the user in converting the formatting requirements into declarative sentences.
|
|
8
|
-
*/
|
|
9
|
-
export declare const requireJsonResponse: (question: string | string[], format: Record<string, JsonResponseFormat>) => string;
|
|
10
|
-
/**
|
|
11
|
-
* @zh 協助使用者將格式需求轉成論敘語句,支援 Handlebars。
|
|
12
|
-
* @en Assist the user in converting the formatting requirements into declarative sentences, support Handlebars.
|
|
13
|
-
*/
|
|
14
|
-
export declare const requireJsonResponseWithHandlebars: (value: Record<string, any>, question: string | string[], format: Record<string, JsonResponseFormat>) => string;
|
|
15
|
-
/**
|
|
16
|
-
* @zh 協助使用者將格式需求轉成論敘語句,並支援 Json Schema。
|
|
17
|
-
* @en Assist the user in converting the formatting requirements into declarative sentences, and support Json Schema.
|
|
18
|
-
*/
|
|
19
|
-
export declare const requireJsonResponseWithJsonSchema: (question: string | string[], format: Record<string, any>) => string;
|
|
20
|
-
export {};
|
package/types/lib/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type PromiseResponseType<T extends (...args: any) => Promise<any>, R = Parameters<ReturnType<T>['then']>[0]> = R extends (value: infer P) => any ? P : never;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as Yup from 'yup';
|
|
2
|
-
import { Schema } from 'yup';
|
|
3
|
-
export type ValidateCallback<T extends Record<string, Schema>> = (_yup: typeof Yup) => {
|
|
4
|
-
[K in keyof T]: T[K];
|
|
5
|
-
};
|
|
6
|
-
export type ValidateCallbackOutputs<T extends ValidateCallback<any>, R = ReturnType<T>> = {
|
|
7
|
-
[K in keyof R]: R[K] extends {
|
|
8
|
-
'__outputType': any;
|
|
9
|
-
} ? R[K]['__outputType'] : R[K];
|
|
10
|
-
};
|
|
11
|
-
export declare function definedValidateSchema<T extends ValidateCallback<any>>(cb: T): T;
|
|
12
|
-
export declare function validate<T extends ValidateCallback<any>, R = ReturnType<T>>(target: any, schemaCallback: T): { [K in keyof R]: R[K] extends {
|
|
13
|
-
__outputType: any;
|
|
14
|
-
} ? R[K]["__outputType"] : R[K]; };
|
|
15
|
-
export declare const defineYupSchema: <T extends Record<string, Yup.Schema<any, any, any, "">>>(cb: ValidateCallback<T>) => T;
|
|
16
|
-
export declare const validateToJsonSchema: <T extends ValidateCallback<any>>(cb: T) => import("json-schema").JSONSchema7;
|