@talex-touch/utils 1.0.31 → 1.0.33
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/animation/window-node.ts +15 -12
- package/animation/window.ts +19 -15
- package/auth/clerk-types.ts +1 -1
- package/auth/index.ts +1 -1
- package/auth/useAuthState.ts +6 -5
- package/auth/useClerkConfig.ts +4 -4
- package/auth/useClerkProvider.ts +3 -2
- package/channel/index.ts +23 -22
- package/common/file-scan-constants.ts +137 -121
- package/common/file-scan-utils.ts +48 -27
- package/common/index.ts +3 -3
- package/common/search/gather.ts +1 -1
- package/common/search/index.ts +5 -6
- package/common/storage/constants.ts +3 -2
- package/common/storage/entity/app-settings.ts +5 -3
- package/common/storage/entity/shortcut-settings.ts +10 -10
- package/common/storage/shortcut-storage.ts +6 -4
- package/common/utils/file.ts +14 -6
- package/common/utils/index.ts +62 -52
- package/common/utils/polling.ts +88 -84
- package/common/utils/task-queue.ts +11 -10
- package/common/utils/time.ts +50 -47
- package/common/utils/timing.ts +41 -37
- package/core-box/builder/index.ts +1 -1
- package/core-box/builder/tuff-builder.ts +254 -229
- package/core-box/index.ts +4 -6
- package/core-box/preview/index.ts +1 -0
- package/core-box/preview/types.ts +43 -0
- package/core-box/recommendation.ts +77 -0
- package/core-box/tuff/index.ts +1 -1
- package/core-box/tuff/tuff-dsl.ts +328 -266
- package/electron/download-manager.ts +43 -42
- package/electron/env-tool.ts +19 -18
- package/electron/file-parsers/index.ts +2 -2
- package/electron/file-parsers/parsers/text-parser.ts +15 -14
- package/electron/file-parsers/registry.ts +9 -7
- package/electron/file-parsers/types.ts +4 -4
- package/electron/index.ts +2 -2
- package/eventbus/index.ts +11 -11
- package/index.ts +5 -4
- package/intelligence/client.ts +87 -0
- package/intelligence/index.ts +1 -0
- package/package.json +14 -14
- package/permission/index.ts +8 -8
- package/plugin/channel.ts +77 -68
- package/plugin/index.ts +96 -82
- package/plugin/install.ts +8 -8
- package/plugin/log/types.ts +5 -5
- package/plugin/node/index.ts +1 -1
- package/plugin/node/logger-manager.ts +14 -11
- package/plugin/node/logger.ts +8 -8
- package/plugin/plugin-source.ts +11 -11
- package/plugin/preload.ts +1 -1
- package/plugin/providers/registry.ts +8 -7
- package/plugin/providers/types.ts +6 -6
- package/plugin/sdk/README.md +216 -0
- package/plugin/sdk/box-sdk.ts +219 -0
- package/plugin/sdk/channel.ts +20 -20
- package/plugin/sdk/clipboard.ts +8 -6
- package/plugin/sdk/common.ts +10 -6
- package/plugin/sdk/core-box.ts +2 -3
- package/plugin/sdk/division-box.ts +266 -0
- package/plugin/sdk/enum/bridge-event.ts +1 -1
- package/plugin/sdk/examples/storage-onDidChange-example.js +1 -1
- package/plugin/sdk/feature-sdk.ts +235 -0
- package/plugin/sdk/features.ts +34 -26
- package/plugin/sdk/hooks/bridge.ts +3 -6
- package/plugin/sdk/hooks/index.ts +1 -1
- package/plugin/sdk/hooks/life-cycle.ts +4 -10
- package/plugin/sdk/index.ts +10 -7
- package/plugin/sdk/service/index.ts +3 -3
- package/plugin/sdk/storage.ts +4 -4
- package/plugin/sdk/system.ts +1 -1
- package/plugin/sdk/types.ts +165 -146
- package/plugin/sdk/window/index.ts +8 -5
- package/preload/loading.ts +6 -6
- package/preload/renderer.ts +4 -2
- package/renderer/hooks/arg-mapper.ts +1 -2
- package/renderer/hooks/index.ts +2 -0
- package/renderer/hooks/initialize.ts +10 -8
- package/renderer/hooks/performance.ts +4 -4
- package/renderer/hooks/use-channel.ts +150 -0
- package/renderer/hooks/use-intelligence.ts +236 -0
- package/renderer/index.ts +6 -2
- package/renderer/ref.ts +32 -36
- package/renderer/slots.ts +29 -26
- package/renderer/storage/app-settings.ts +16 -6
- package/renderer/storage/base-storage.ts +222 -114
- package/renderer/storage/index.ts +3 -0
- package/renderer/storage/intelligence-storage.ts +218 -0
- package/renderer/storage/openers.ts +13 -3
- package/renderer/touch-sdk/env.ts +41 -41
- package/renderer/touch-sdk/index.ts +1 -1
- package/renderer/touch-sdk/terminal.ts +5 -5
- package/renderer/touch-sdk/utils.ts +4 -3
- package/search/levenshtein-utils.ts +11 -11
- package/search/types.ts +102 -102
- package/service/index.ts +11 -11
- package/service/protocol/index.ts +217 -14
- package/types/division-box.ts +248 -0
- package/types/download.ts +72 -34
- package/types/index.ts +3 -1
- package/types/intelligence.ts +607 -0
- package/types/modules/base.ts +16 -16
- package/types/modules/index.ts +1 -1
- package/types/modules/module-lifecycle.ts +21 -21
- package/types/modules/module-manager.ts +11 -11
- package/types/modules/module.ts +16 -16
- package/types/storage.ts +0 -1
- package/types/touch-app-core.ts +32 -32
- package/types/update.ts +91 -21
- package/core-box/README.md +0 -218
- package/core-box/builder/tuff-builder.example.ts.bak +0 -258
- package/core-box/run-tests.sh +0 -7
- package/core-box/search.ts +0 -1
- package/electron/clipboard-helper.ts +0 -199
package/types/index.ts
CHANGED
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
export enum AiProviderType {
|
|
2
|
+
OPENAI = 'openai',
|
|
3
|
+
ANTHROPIC = 'anthropic',
|
|
4
|
+
DEEPSEEK = 'deepseek',
|
|
5
|
+
SILICONFLOW = 'siliconflow',
|
|
6
|
+
LOCAL = 'local',
|
|
7
|
+
CUSTOM = 'custom',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export enum AiCapabilityType {
|
|
11
|
+
CHAT = 'chat',
|
|
12
|
+
COMPLETION = 'completion',
|
|
13
|
+
EMBEDDING = 'embedding',
|
|
14
|
+
SUMMARIZE = 'summarize',
|
|
15
|
+
TRANSLATE = 'translate',
|
|
16
|
+
TTS = 'tts',
|
|
17
|
+
STT = 'stt',
|
|
18
|
+
VISION = 'vision',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AiProviderRateLimit {
|
|
22
|
+
requestsPerMinute?: number
|
|
23
|
+
requestsPerDay?: number
|
|
24
|
+
tokensPerMinute?: number
|
|
25
|
+
tokensPerDay?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface AiVisionImageSource {
|
|
29
|
+
type: 'data-url' | 'file' | 'base64'
|
|
30
|
+
dataUrl?: string
|
|
31
|
+
filePath?: string
|
|
32
|
+
base64?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface AiVisionOcrBlock {
|
|
36
|
+
id?: string
|
|
37
|
+
text: string
|
|
38
|
+
language?: string
|
|
39
|
+
confidence?: number
|
|
40
|
+
boundingBox?: [number, number, number, number]
|
|
41
|
+
polygon?: Array<[number, number]>
|
|
42
|
+
type?: 'word' | 'line' | 'paragraph' | 'region'
|
|
43
|
+
children?: AiVisionOcrBlock[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface AiVisionOcrResult {
|
|
47
|
+
text: string
|
|
48
|
+
confidence?: number
|
|
49
|
+
language?: string
|
|
50
|
+
keywords?: string[]
|
|
51
|
+
suggestions?: string[]
|
|
52
|
+
blocks?: AiVisionOcrBlock[]
|
|
53
|
+
raw?: any
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface AiVisionOcrPayload {
|
|
57
|
+
source: AiVisionImageSource
|
|
58
|
+
language?: string
|
|
59
|
+
prompt?: string
|
|
60
|
+
metadata?: Record<string, any>
|
|
61
|
+
includeLayout?: boolean
|
|
62
|
+
includeKeywords?: boolean
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface AiProviderConfig {
|
|
66
|
+
id: string
|
|
67
|
+
type: AiProviderType
|
|
68
|
+
name: string
|
|
69
|
+
enabled: boolean
|
|
70
|
+
apiKey?: string
|
|
71
|
+
baseUrl?: string
|
|
72
|
+
rateLimit?: AiProviderRateLimit
|
|
73
|
+
models?: string[]
|
|
74
|
+
defaultModel?: string
|
|
75
|
+
instructions?: string
|
|
76
|
+
timeout?: number
|
|
77
|
+
priority?: number
|
|
78
|
+
capabilities?: string[]
|
|
79
|
+
metadata?: Record<string, any>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface AiMessage {
|
|
83
|
+
role: 'system' | 'user' | 'assistant'
|
|
84
|
+
content: string
|
|
85
|
+
name?: string
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface AiInvokeOptions {
|
|
89
|
+
strategy?: string
|
|
90
|
+
modelPreference?: string[]
|
|
91
|
+
costCeiling?: number
|
|
92
|
+
latencyTarget?: number
|
|
93
|
+
timeout?: number
|
|
94
|
+
stream?: boolean
|
|
95
|
+
preferredProviderId?: string
|
|
96
|
+
allowedProviderIds?: string[]
|
|
97
|
+
metadata?: Record<string, any>
|
|
98
|
+
testRun?: boolean
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface AiInvokeContext {
|
|
102
|
+
source?: string
|
|
103
|
+
locale?: string
|
|
104
|
+
userId?: string
|
|
105
|
+
sessionId?: string
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface AiUsageInfo {
|
|
109
|
+
promptTokens: number
|
|
110
|
+
completionTokens: number
|
|
111
|
+
totalTokens: number
|
|
112
|
+
cost?: number
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface AiInvokeResult<T = any> {
|
|
116
|
+
result: T
|
|
117
|
+
usage: AiUsageInfo
|
|
118
|
+
model: string
|
|
119
|
+
latency: number
|
|
120
|
+
traceId: string
|
|
121
|
+
provider: string
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface AiStreamChunk {
|
|
125
|
+
delta: string
|
|
126
|
+
done: boolean
|
|
127
|
+
usage?: AiUsageInfo
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface AiCapabilityDescriptor {
|
|
131
|
+
id: string
|
|
132
|
+
type: AiCapabilityType
|
|
133
|
+
name: string
|
|
134
|
+
description: string
|
|
135
|
+
inputSchema?: any
|
|
136
|
+
outputSchema?: any
|
|
137
|
+
defaultStrategy?: string
|
|
138
|
+
supportedProviders: AiProviderType[]
|
|
139
|
+
metadata?: Record<string, any>
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface AiChatPayload {
|
|
143
|
+
messages: AiMessage[]
|
|
144
|
+
context?: AiInvokeContext
|
|
145
|
+
temperature?: number
|
|
146
|
+
maxTokens?: number
|
|
147
|
+
topP?: number
|
|
148
|
+
frequencyPenalty?: number
|
|
149
|
+
presencePenalty?: number
|
|
150
|
+
stop?: string[]
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface AiEmbeddingPayload {
|
|
154
|
+
text: string | string[]
|
|
155
|
+
model?: string
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface AiTranslatePayload {
|
|
159
|
+
text: string
|
|
160
|
+
sourceLang?: string
|
|
161
|
+
targetLang: string
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface AiSummarizePayload {
|
|
165
|
+
text: string
|
|
166
|
+
maxLength?: number
|
|
167
|
+
style?: 'concise' | 'detailed' | 'bullet-points'
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface AiSDKConfig {
|
|
171
|
+
providers: AiProviderConfig[]
|
|
172
|
+
defaultStrategy: string
|
|
173
|
+
enableAudit: boolean
|
|
174
|
+
enableCache: boolean
|
|
175
|
+
cacheExpiration?: number
|
|
176
|
+
capabilities?: Record<string, AiCapabilityRoutingConfig>
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface AiStrategyConfig {
|
|
180
|
+
id: string
|
|
181
|
+
name: string
|
|
182
|
+
type: 'rule-based' | 'adaptive' | 'custom'
|
|
183
|
+
rules?: any
|
|
184
|
+
priority?: number
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface AiAuditLog {
|
|
188
|
+
traceId: string
|
|
189
|
+
timestamp: number
|
|
190
|
+
capabilityId: string
|
|
191
|
+
provider: string
|
|
192
|
+
model: string
|
|
193
|
+
promptHash?: string
|
|
194
|
+
caller?: string
|
|
195
|
+
usage: AiUsageInfo
|
|
196
|
+
latency: number
|
|
197
|
+
success: boolean
|
|
198
|
+
error?: string
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface AiCapabilityProviderBinding {
|
|
202
|
+
providerId: string
|
|
203
|
+
models?: string[]
|
|
204
|
+
priority?: number
|
|
205
|
+
enabled?: boolean
|
|
206
|
+
metadata?: Record<string, any>
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface AiCapabilityRoutingConfig {
|
|
210
|
+
label?: string
|
|
211
|
+
description?: string
|
|
212
|
+
providers: AiCapabilityProviderBinding[]
|
|
213
|
+
promptTemplate?: string
|
|
214
|
+
testResourceDir?: string
|
|
215
|
+
metadata?: Record<string, any>
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface AiSDKPersistedConfig {
|
|
219
|
+
providers: AiProviderConfig[]
|
|
220
|
+
globalConfig: {
|
|
221
|
+
defaultStrategy: string
|
|
222
|
+
enableAudit: boolean
|
|
223
|
+
enableCache: boolean
|
|
224
|
+
cacheExpiration?: number
|
|
225
|
+
}
|
|
226
|
+
capabilities?: Record<string, AiCapabilityRoutingConfig>
|
|
227
|
+
version: number
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface AiProviderAdapter {
|
|
231
|
+
readonly type: AiProviderType
|
|
232
|
+
getConfig: () => AiProviderConfig
|
|
233
|
+
updateConfig: (config: Partial<AiProviderConfig>) => void
|
|
234
|
+
isEnabled: () => boolean
|
|
235
|
+
chat: (payload: AiChatPayload, options: AiInvokeOptions) => Promise<AiInvokeResult<string>>
|
|
236
|
+
chatStream: (
|
|
237
|
+
payload: AiChatPayload,
|
|
238
|
+
options: AiInvokeOptions,
|
|
239
|
+
) => AsyncGenerator<AiStreamChunk>
|
|
240
|
+
embedding: (payload: AiEmbeddingPayload, options: AiInvokeOptions) => Promise<AiInvokeResult<number[]>>
|
|
241
|
+
translate: (payload: AiTranslatePayload, options: AiInvokeOptions) => Promise<AiInvokeResult<string>>
|
|
242
|
+
visionOcr: (
|
|
243
|
+
payload: AiVisionOcrPayload,
|
|
244
|
+
options: AiInvokeOptions,
|
|
245
|
+
) => Promise<AiInvokeResult<AiVisionOcrResult>>
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface ProviderManagerAdapter {
|
|
249
|
+
clear: () => void
|
|
250
|
+
registerFromConfig: (config: AiProviderConfig) => AiProviderAdapter
|
|
251
|
+
getEnabled: () => AiProviderAdapter[]
|
|
252
|
+
get: (providerId: string) => AiProviderAdapter | undefined
|
|
253
|
+
createProviderInstance: (config: AiProviderConfig) => AiProviderAdapter
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface AISDKGlobalConfig {
|
|
257
|
+
defaultStrategy: string
|
|
258
|
+
enableAudit: boolean
|
|
259
|
+
enableCache: boolean
|
|
260
|
+
cacheExpiration?: number
|
|
261
|
+
maxRetries?: number
|
|
262
|
+
defaultTimeout?: number
|
|
263
|
+
enableLogging?: boolean
|
|
264
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error'
|
|
265
|
+
enableCaching?: boolean
|
|
266
|
+
cacheSize?: number
|
|
267
|
+
fallbackStrategy?: 'next-available' | 'fail-fast' | 'round-robin'
|
|
268
|
+
parallelRequests?: boolean
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface TestResult {
|
|
272
|
+
success: boolean
|
|
273
|
+
message?: string
|
|
274
|
+
latency?: number
|
|
275
|
+
timestamp: number
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export interface AISDKCapabilityConfig {
|
|
279
|
+
id: string
|
|
280
|
+
label: string
|
|
281
|
+
description?: string
|
|
282
|
+
providers: AiCapabilityProviderBinding[]
|
|
283
|
+
promptTemplate?: string
|
|
284
|
+
testResourceDir?: string
|
|
285
|
+
metadata?: Record<string, any>
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface AISDKStorageData {
|
|
289
|
+
providers: AiProviderConfig[]
|
|
290
|
+
globalConfig: AISDKGlobalConfig
|
|
291
|
+
capabilities: Record<string, AISDKCapabilityConfig>
|
|
292
|
+
version: number
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export const DEFAULT_PROVIDERS: AiProviderConfig[] = [
|
|
296
|
+
{
|
|
297
|
+
id: 'openai-default',
|
|
298
|
+
type: AiProviderType.OPENAI,
|
|
299
|
+
name: 'OpenAI',
|
|
300
|
+
enabled: false,
|
|
301
|
+
priority: 1,
|
|
302
|
+
models: ['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo'],
|
|
303
|
+
defaultModel: 'gpt-4o-mini',
|
|
304
|
+
timeout: 30000,
|
|
305
|
+
rateLimit: {},
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: 'anthropic-default',
|
|
309
|
+
type: AiProviderType.ANTHROPIC,
|
|
310
|
+
name: 'Anthropic',
|
|
311
|
+
enabled: false,
|
|
312
|
+
priority: 2,
|
|
313
|
+
models: ['claude-3-5-sonnet-20241022', 'claude-3-opus-20240229', 'claude-3-haiku-20240307'],
|
|
314
|
+
defaultModel: 'claude-3-5-sonnet-20241022',
|
|
315
|
+
timeout: 30000,
|
|
316
|
+
rateLimit: {},
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: 'deepseek-default',
|
|
320
|
+
type: AiProviderType.DEEPSEEK,
|
|
321
|
+
name: 'DeepSeek',
|
|
322
|
+
enabled: false,
|
|
323
|
+
priority: 2,
|
|
324
|
+
models: ['deepseek-chat', 'deepseek-coder'],
|
|
325
|
+
defaultModel: 'deepseek-chat',
|
|
326
|
+
timeout: 30000,
|
|
327
|
+
rateLimit: {},
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
id: 'siliconflow-default',
|
|
331
|
+
type: AiProviderType.SILICONFLOW,
|
|
332
|
+
name: 'SiliconFlow',
|
|
333
|
+
enabled: false,
|
|
334
|
+
priority: 2,
|
|
335
|
+
baseUrl: 'https://api.siliconflow.cn/v1',
|
|
336
|
+
models: [
|
|
337
|
+
'deepseek-ai/DeepSeek-R1-0528-Qwen3-8B',
|
|
338
|
+
'tencent/Hunyuan-MT-7B',
|
|
339
|
+
'TeleAI/TeleSpeechASR',
|
|
340
|
+
'THUDM/GLM-4.1V-9B-Thinking',
|
|
341
|
+
'deepseek-ai/DeepSeek-R1-Distill-Qwen-7B',
|
|
342
|
+
'BAAI/bge-reranker-v2-m3',
|
|
343
|
+
'netease-youdao/bce-embedding-base_v1',
|
|
344
|
+
'Kwai-Kolors/Kolors',
|
|
345
|
+
'BAAI/bge-m3',
|
|
346
|
+
],
|
|
347
|
+
defaultModel: 'deepseek-ai/DeepSeek-R1-0528-Qwen3-8B',
|
|
348
|
+
timeout: 30000,
|
|
349
|
+
rateLimit: {},
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
id: 'local-default',
|
|
353
|
+
type: AiProviderType.LOCAL,
|
|
354
|
+
name: 'Local Model',
|
|
355
|
+
enabled: false,
|
|
356
|
+
priority: 3,
|
|
357
|
+
models: [],
|
|
358
|
+
baseUrl: 'http://localhost:11434',
|
|
359
|
+
timeout: 60000,
|
|
360
|
+
rateLimit: {},
|
|
361
|
+
},
|
|
362
|
+
]
|
|
363
|
+
|
|
364
|
+
export const DEFAULT_GLOBAL_CONFIG: AISDKGlobalConfig = {
|
|
365
|
+
defaultStrategy: 'adaptive-default',
|
|
366
|
+
enableAudit: false,
|
|
367
|
+
enableCache: true,
|
|
368
|
+
cacheExpiration: 3600,
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export const DEFAULT_CAPABILITIES: Record<string, AISDKCapabilityConfig> = {
|
|
372
|
+
'text.chat': {
|
|
373
|
+
id: 'text.chat',
|
|
374
|
+
label: '对话 / Chat',
|
|
375
|
+
description: '默认用于系统对话、翻译、总结等文本任务的模型集合',
|
|
376
|
+
providers: [
|
|
377
|
+
{ providerId: 'openai-default', priority: 1, enabled: true },
|
|
378
|
+
{ providerId: 'anthropic-default', priority: 2, enabled: true },
|
|
379
|
+
{ providerId: 'deepseek-default', priority: 3, enabled: true },
|
|
380
|
+
{ providerId: 'siliconflow-default', priority: 4, enabled: true },
|
|
381
|
+
],
|
|
382
|
+
},
|
|
383
|
+
'embedding.generate': {
|
|
384
|
+
id: 'embedding.generate',
|
|
385
|
+
label: 'Embedding / 向量生成',
|
|
386
|
+
description: '为向量检索/摘要生成 embedding',
|
|
387
|
+
providers: [
|
|
388
|
+
{
|
|
389
|
+
providerId: 'siliconflow-default',
|
|
390
|
+
models: ['netease-youdao/bce-embedding-base_v1', 'BAAI/bge-m3'],
|
|
391
|
+
priority: 1,
|
|
392
|
+
enabled: true,
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
providerId: 'openai-default',
|
|
396
|
+
models: ['text-embedding-3-small', 'text-embedding-3-large'],
|
|
397
|
+
priority: 2,
|
|
398
|
+
enabled: false,
|
|
399
|
+
},
|
|
400
|
+
],
|
|
401
|
+
},
|
|
402
|
+
'vision.ocr': {
|
|
403
|
+
id: 'vision.ocr',
|
|
404
|
+
label: '图像 OCR / Image Recognition',
|
|
405
|
+
description: '识别截图、图片中的文字并生成关键词',
|
|
406
|
+
promptTemplate:
|
|
407
|
+
'你是 OCR 助手,识别图片所有文本,生成 keywords 数组(5 个以内)辅助搜索。',
|
|
408
|
+
testResourceDir: 'intelligence/test-capability/ocr',
|
|
409
|
+
providers: [
|
|
410
|
+
{
|
|
411
|
+
providerId: 'siliconflow-default',
|
|
412
|
+
models: ['deepseek-ai/DeepSeek-OCR', 'THUDM/GLM-4.1V-9B-Thinking'],
|
|
413
|
+
priority: 1,
|
|
414
|
+
enabled: true,
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
providerId: 'openai-default',
|
|
418
|
+
models: ['gpt-4o', 'gpt-4o-mini'],
|
|
419
|
+
priority: 2,
|
|
420
|
+
enabled: false,
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
providerId: 'anthropic-default',
|
|
424
|
+
models: ['claude-3-5-sonnet-20241022'],
|
|
425
|
+
priority: 3,
|
|
426
|
+
enabled: false,
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
},
|
|
430
|
+
'text.translate': {
|
|
431
|
+
id: 'text.translate',
|
|
432
|
+
label: '翻译 / Translation',
|
|
433
|
+
description: '多语言文本翻译',
|
|
434
|
+
promptTemplate: '你是专业翻译助手。请将以下文本翻译成 {{targetLang}},只返回译文,不要解释。',
|
|
435
|
+
providers: [
|
|
436
|
+
{ providerId: 'deepseek-default', priority: 1, enabled: true },
|
|
437
|
+
{ providerId: 'openai-default', priority: 2, enabled: false },
|
|
438
|
+
{ providerId: 'anthropic-default', priority: 3, enabled: false },
|
|
439
|
+
],
|
|
440
|
+
},
|
|
441
|
+
'text.summarize': {
|
|
442
|
+
id: 'text.summarize',
|
|
443
|
+
label: '摘要 / Summarization',
|
|
444
|
+
description: '生成文本内容的简洁摘要',
|
|
445
|
+
promptTemplate: '请用简洁的语言总结以下内容的核心要点,不超过 {{maxLength}} 字。',
|
|
446
|
+
providers: [
|
|
447
|
+
{ providerId: 'deepseek-default', priority: 1, enabled: true },
|
|
448
|
+
{ providerId: 'openai-default', priority: 2, enabled: false },
|
|
449
|
+
{ providerId: 'anthropic-default', priority: 3, enabled: false },
|
|
450
|
+
],
|
|
451
|
+
},
|
|
452
|
+
'intent.detect': {
|
|
453
|
+
id: 'intent.detect',
|
|
454
|
+
label: '意图识别 / Intent Detection',
|
|
455
|
+
description: '识别用户查询的意图类型(搜索、打开、计算等)',
|
|
456
|
+
promptTemplate: '分析用户输入的意图,返回 JSON 格式:{intent: string, confidence: number, entities: string[]}',
|
|
457
|
+
providers: [
|
|
458
|
+
{ providerId: 'deepseek-default', priority: 1, enabled: true },
|
|
459
|
+
{ providerId: 'openai-default', priority: 2, enabled: false },
|
|
460
|
+
],
|
|
461
|
+
},
|
|
462
|
+
'code.generate': {
|
|
463
|
+
id: 'code.generate',
|
|
464
|
+
label: '代码生成 / Code Generation',
|
|
465
|
+
description: '根据需求生成代码片段',
|
|
466
|
+
promptTemplate: '你是编程助手。根据需求生成 {{language}} 代码,包含注释说明。',
|
|
467
|
+
providers: [
|
|
468
|
+
{ providerId: 'deepseek-default', models: ['deepseek-coder'], priority: 1, enabled: true },
|
|
469
|
+
{ providerId: 'openai-default', models: ['gpt-4o'], priority: 2, enabled: false },
|
|
470
|
+
],
|
|
471
|
+
},
|
|
472
|
+
'code.explain': {
|
|
473
|
+
id: 'code.explain',
|
|
474
|
+
label: '代码解释 / Code Explanation',
|
|
475
|
+
description: '解释代码的功能和逻辑',
|
|
476
|
+
promptTemplate: '你是编程导师。用通俗易懂的语言解释这段代码的功能、逻辑和关键点。',
|
|
477
|
+
providers: [
|
|
478
|
+
{ providerId: 'deepseek-default', models: ['deepseek-coder'], priority: 1, enabled: true },
|
|
479
|
+
{ providerId: 'anthropic-default', priority: 2, enabled: false },
|
|
480
|
+
],
|
|
481
|
+
},
|
|
482
|
+
'content.extract': {
|
|
483
|
+
id: 'content.extract',
|
|
484
|
+
label: '内容提取 / Content Extraction',
|
|
485
|
+
description: '从文本中提取关键信息(日期、人名、地点等)',
|
|
486
|
+
promptTemplate: '从文本中提取关键信息,返回 JSON 格式:{dates: [], people: [], locations: [], keywords: []}',
|
|
487
|
+
providers: [
|
|
488
|
+
{ providerId: 'deepseek-default', priority: 1, enabled: true },
|
|
489
|
+
{ providerId: 'openai-default', priority: 2, enabled: false },
|
|
490
|
+
],
|
|
491
|
+
},
|
|
492
|
+
'sentiment.analyze': {
|
|
493
|
+
id: 'sentiment.analyze',
|
|
494
|
+
label: '情感分析 / Sentiment Analysis',
|
|
495
|
+
description: '分析文本的情感倾向(积极/消极/中性)',
|
|
496
|
+
promptTemplate: '分析文本情感倾向,返回 JSON:{sentiment: "positive"|"negative"|"neutral", score: 0-1, keywords: []}',
|
|
497
|
+
providers: [
|
|
498
|
+
{ providerId: 'deepseek-default', priority: 1, enabled: true },
|
|
499
|
+
{ providerId: 'openai-default', priority: 2, enabled: false },
|
|
500
|
+
],
|
|
501
|
+
},
|
|
502
|
+
'code.review': {
|
|
503
|
+
id: 'code.review',
|
|
504
|
+
label: '代码审查 / Code Review',
|
|
505
|
+
description: '审查代码,发现潜在问题、最佳实践和改进建议',
|
|
506
|
+
promptTemplate: '作为资深代码审查员,审查以下代码。关注:1) 潜在bug 2) 性能问题 3) 安全隐患 4) 最佳实践 5) 可读性',
|
|
507
|
+
providers: [
|
|
508
|
+
{ providerId: 'deepseek-default', models: ['deepseek-coder'], priority: 1, enabled: true },
|
|
509
|
+
{ providerId: 'anthropic-default', priority: 2, enabled: false },
|
|
510
|
+
{ providerId: 'openai-default', models: ['gpt-4o'], priority: 3, enabled: false },
|
|
511
|
+
],
|
|
512
|
+
},
|
|
513
|
+
'keywords.extract': {
|
|
514
|
+
id: 'keywords.extract',
|
|
515
|
+
label: '关键词提取 / Keyword Extraction',
|
|
516
|
+
description: '从文本中提取关键词和短语',
|
|
517
|
+
promptTemplate: '从文本中提取最重要的关键词,返回 JSON 数组:{keywords: [{term: string, relevance: number}]}',
|
|
518
|
+
providers: [
|
|
519
|
+
{ providerId: 'deepseek-default', priority: 1, enabled: true },
|
|
520
|
+
{ providerId: 'openai-default', priority: 2, enabled: false },
|
|
521
|
+
],
|
|
522
|
+
},
|
|
523
|
+
'audio.transcribe': {
|
|
524
|
+
id: 'audio.transcribe',
|
|
525
|
+
label: '音频转录 / Audio Transcription',
|
|
526
|
+
description: '将语音转换为文字(支持多语言)',
|
|
527
|
+
providers: [
|
|
528
|
+
{
|
|
529
|
+
providerId: 'openai-default',
|
|
530
|
+
models: ['whisper-1'],
|
|
531
|
+
priority: 1,
|
|
532
|
+
enabled: false,
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
providerId: 'siliconflow-default',
|
|
536
|
+
models: ['TeleAI/TeleSpeechASR'],
|
|
537
|
+
priority: 2,
|
|
538
|
+
enabled: true,
|
|
539
|
+
},
|
|
540
|
+
],
|
|
541
|
+
},
|
|
542
|
+
'audio.tts': {
|
|
543
|
+
id: 'audio.tts',
|
|
544
|
+
label: '语音合成 / Text-to-Speech',
|
|
545
|
+
description: '将文字转换为自然语音',
|
|
546
|
+
providers: [
|
|
547
|
+
{
|
|
548
|
+
providerId: 'openai-default',
|
|
549
|
+
models: ['tts-1', 'tts-1-hd'],
|
|
550
|
+
priority: 1,
|
|
551
|
+
enabled: false,
|
|
552
|
+
},
|
|
553
|
+
],
|
|
554
|
+
},
|
|
555
|
+
'image.caption': {
|
|
556
|
+
id: 'image.caption',
|
|
557
|
+
label: '图像标题 / Image Captioning',
|
|
558
|
+
description: '为图片生成描述性标题',
|
|
559
|
+
promptTemplate: '生成简洁准确的图片描述(中英文),捕捉主要内容和氛围。',
|
|
560
|
+
providers: [
|
|
561
|
+
{
|
|
562
|
+
providerId: 'siliconflow-default',
|
|
563
|
+
models: ['THUDM/GLM-4.1V-9B-Thinking'],
|
|
564
|
+
priority: 1,
|
|
565
|
+
enabled: true,
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
providerId: 'openai-default',
|
|
569
|
+
models: ['gpt-4o', 'gpt-4o-mini'],
|
|
570
|
+
priority: 2,
|
|
571
|
+
enabled: false,
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
providerId: 'anthropic-default',
|
|
575
|
+
models: ['claude-3-5-sonnet-20241022'],
|
|
576
|
+
priority: 3,
|
|
577
|
+
enabled: false,
|
|
578
|
+
},
|
|
579
|
+
],
|
|
580
|
+
},
|
|
581
|
+
'image.analyze': {
|
|
582
|
+
id: 'image.analyze',
|
|
583
|
+
label: '图像分析 / Image Analysis',
|
|
584
|
+
description: '深度分析图像内容、物体、场景和上下文',
|
|
585
|
+
promptTemplate: '详细分析图片,包括:物体识别、场景理解、颜色分析、构图评估。返回结构化结果。',
|
|
586
|
+
providers: [
|
|
587
|
+
{
|
|
588
|
+
providerId: 'siliconflow-default',
|
|
589
|
+
models: ['THUDM/GLM-4.1V-9B-Thinking'],
|
|
590
|
+
priority: 1,
|
|
591
|
+
enabled: true,
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
providerId: 'openai-default',
|
|
595
|
+
models: ['gpt-4o'],
|
|
596
|
+
priority: 2,
|
|
597
|
+
enabled: false,
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
providerId: 'anthropic-default',
|
|
601
|
+
models: ['claude-3-5-sonnet-20241022'],
|
|
602
|
+
priority: 3,
|
|
603
|
+
enabled: false,
|
|
604
|
+
},
|
|
605
|
+
],
|
|
606
|
+
},
|
|
607
|
+
}
|