-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathtypes.ts
210 lines (168 loc) · 4.26 KB
/
types.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import { v4 as uuidv4 } from 'uuid'
import { Model } from '../renderer/packages/models/openai'
import * as siliconflow from '../renderer/packages/models/siliconflow'
import { ClaudeModel } from '../renderer/packages/models/claude'
export const MessageRoleEnum = {
System: 'system',
User: 'user',
Assistant: 'assistant',
} as const
export type MessageRole = (typeof MessageRoleEnum)[keyof typeof MessageRoleEnum]
export interface Message {
id: string
role: MessageRole
content: string
name?: string
cancel?: () => void
generating?: boolean
aiProvider?: ModelProvider
model?: string
errorCode?: number
error?: string
errorExtra?: {
[key: string]: any
}
wordCount?: number
tokenCount?: number
tokensUsed?: number
timestamp?: number
}
export type SettingWindowTab = 'ai' | 'display' | 'chat' | 'advanced'
export type SessionType = 'chat'
export function isChatSession(session: Session) {
return session.type === 'chat' || !session.type
}
export interface Session {
id: string
type?: SessionType
name: string
picUrl?: string
messages: Message[]
copilotId?: string
}
export function createMessage(role: MessageRole = MessageRoleEnum.User, content: string = ''): Message {
return {
id: uuidv4(),
content: content,
role: role,
timestamp: new Date().getTime(),
}
}
export enum ModelProvider {
ChatboxAI = 'chatbox-ai',
OpenAI = 'openai',
Claude = 'claude',
Ollama = 'ollama',
SiliconFlow = 'silicon-flow',
LMStudio = 'lm-studio',
}
export interface ModelSettings {
aiProvider: ModelProvider
// openai
openaiKey: string
apiHost: string
model: Model | 'custom-model'
openaiCustomModel?: string
//LMStudio
lmStudioHost: string
lmStudioModel: string
// claude
claudeApiKey: string
claudeApiHost: string
claudeModel: ClaudeModel
// azure
azureEndpoint: string
azureDeploymentName: string
azureDalleDeploymentName: string
azureApikey: string
// chatglm-6b
chatglm6bUrl: string
// chatbox-ai
licenseKey?: string
chatboxAIModel?: ChatboxAIModel
licenseInstances?: {
[key: string]: string
}
licenseDetail?: ChatboxAILicenseDetail
// ollama
ollamaHost: string
ollamaModel: string
// siliconflow
siliconCloudHost: string
siliconCloudKey: string
siliconCloudModel: siliconflow.Model | 'custom-model'
temperature: number
topP: number
openaiMaxContextMessageCount: number
}
export interface Settings extends ModelSettings {
showWordCount?: boolean
showTokenCount?: boolean
showTokenUsed?: boolean
showModelName?: boolean
showMessageTimestamp?: boolean
theme: Theme
language: Language
languageInited?: boolean
fontSize: number
spellCheck: boolean
defaultPrompt?: string
proxy?: string
allowReportingAndTracking: boolean
userAvatarKey?: string
enableMarkdownRendering: boolean
autoGenerateTitle: boolean
}
export type Language = 'en' | 'zh-Hans' | 'zh-Hant' | 'ja' | 'ko' | 'ru' | 'de' | 'fr' | 'tr'
export interface Config {
uuid: string
}
export interface SponsorAd {
text: string
url: string
}
export interface SponsorAboutBanner {
type: 'picture' | 'picture-text'
name: string
pictureUrl: string
link: string
title: string
description: string
}
export interface CopilotDetail {
id: string
name: string
picUrl?: string
prompt: string
demoQuestion?: string
demoAnswer?: string
starred?: boolean
usedCount: number
shared?: boolean
}
export interface Toast {
id: string
content: string
}
export enum Theme {
DarkMode,
LightMode,
FollowSystem,
}
export interface RemoteConfig {
setting_chatboxai_first: boolean
product_ids: number[]
}
export interface ChatboxAILicenseDetail {
type: ChatboxAIModel
name: string
defaultModel: ChatboxAIModel
remaining_quota_35: number
remaining_quota_4: number
remaining_quota_image: number
image_used_count: number
image_total_quota: number
token_refreshed_time: string
token_expire_time: string | null | undefined
}
export type ChatboxAIModel = 'chatboxai-3.5' | 'chatboxai-4'