-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes.d.ts
127 lines (103 loc) · 2.47 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
export interface ILLMOptions extends Record<string, any> {
model: string
temperature?: number
penalty_score?: number
}
export interface IFunction_call {
name: string
arguments: string
thoughts?: string
}
export interface Message {
role: 'user' | 'assistant' | 'function' | 'system'
content?: string
name?: string
function_call?: IFunction_call
}
export interface ChunkFunction {
(text: string): boolean
}
export interface IEmbeddingResult {
embeddings: number[][]
total_tokens: number
}
export interface ILLMResult {
content: string
total_tokens: number
}
export declare class BasePlatform {
getModels(): string[]
embedTexts(texts: string[]): Promise<IEmbeddingResult>
completion(messages: Message[] | Message | string, options?: ILLMOptions, chunk_callback?: ChunkFunction): Promise<ILLMResult>
count_tokens(text: string): number
speech(text: string, opts?: Record<string, any>): Promise<ArrayBuffer>
getSystemPrompt(): string
}
export interface IPlatformConfig extends Record<string, any> {
apiKey?: string
basePath?: string
client_id?: string
client_secret?: string
system_prompt?: string
round_max_tokens: number
splitter_chunk_size: number
splitter_chunk_overlap: number
dimension: number
tts_model?: string
tts_voice?: string
tts_speed?: number
}
type PlatformKeys = 'openai' | 'wenxin' | 'qwen'
export interface ISystemConfig {
[key in PlatformKeys]: IPlatformConfig
platform: PlatformKeys
model: string
embedding: PlatformKeys
max_related_message_num: number
topK: number
auto_play_audio: boolean
}
export interface IMessageParams {
platform?: PlatformKeys
model?: string
embedding?: PlatformKeys
temperature?: number
penalty_score?: number
}
export interface IPromptFunction {
id: string
keywords: string[]
label: string
remarks: string
callback(...args: any[]): string | Function | boolean
}
type SelectionHitResult = { hits: HitPrompt[], prompt: string } | undefined
type SearchPrompt = (prompt: string) => SelectionHitResult
export interface IConversation {
id: string
title: string
created: number
system_id?: string
new_create?: boolean
}
export interface IMessage {
id: string
role: 'user' | 'assistant' | 'system'
created: number
content: string
params?: IMessageParams
is_delete?: boolean
ended?: boolean
is_end?: boolean
total_tokens?: number
skip_relation?: boolean
split?: boolean
autio_path?: string
}
export interface HitPrompt {
id: string
label: string
sort: number
remarks: string
hit: boolean
}