@talex-touch/utils 1.0.40 → 1.0.42
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/core-box/tuff/tuff-dsl.ts +65 -0
- package/intelligence/client.ts +8 -8
- package/market/constants.ts +14 -0
- package/market/types.ts +1 -1
- package/package.json +1 -1
- package/plugin/index.ts +2 -1
- package/plugin/providers/index.ts +4 -0
- package/plugin/providers/market-client.ts +215 -0
- package/plugin/providers/npm-provider.ts +213 -0
- package/plugin/providers/tpex-provider.ts +283 -0
- package/plugin/providers/tpex-types.ts +34 -0
- package/plugin/sdk/hooks/bridge.ts +105 -48
- package/plugin/sdk/performance.ts +1 -16
- package/renderer/hooks/arg-mapper.ts +20 -6
- package/renderer/hooks/use-intelligence.ts +291 -34
- package/renderer/storage/intelligence-storage.ts +9 -9
- package/types/division-box.ts +20 -0
- package/types/intelligence.ts +1496 -78
|
@@ -1,12 +1,51 @@
|
|
|
1
1
|
import type { Ref } from 'vue'
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
IntelligenceAgentPayload,
|
|
4
|
+
IntelligenceAgentResult,
|
|
5
|
+
IntelligenceChatPayload,
|
|
6
|
+
IntelligenceClassificationPayload,
|
|
7
|
+
IntelligenceClassificationResult,
|
|
8
|
+
IntelligenceCodeDebugPayload,
|
|
9
|
+
IntelligenceCodeDebugResult,
|
|
10
|
+
IntelligenceCodeExplainPayload,
|
|
11
|
+
IntelligenceCodeExplainResult,
|
|
12
|
+
IntelligenceCodeGeneratePayload,
|
|
13
|
+
IntelligenceCodeGenerateResult,
|
|
14
|
+
IntelligenceCodeRefactorPayload,
|
|
15
|
+
IntelligenceCodeRefactorResult,
|
|
16
|
+
IntelligenceCodeReviewPayload,
|
|
17
|
+
IntelligenceCodeReviewResult,
|
|
18
|
+
IntelligenceContentExtractPayload,
|
|
19
|
+
IntelligenceContentExtractResult,
|
|
20
|
+
IntelligenceEmbeddingPayload,
|
|
21
|
+
IntelligenceGrammarCheckPayload,
|
|
22
|
+
IntelligenceGrammarCheckResult,
|
|
23
|
+
IntelligenceImageAnalyzePayload,
|
|
24
|
+
IntelligenceImageAnalyzeResult,
|
|
25
|
+
IntelligenceImageCaptionPayload,
|
|
26
|
+
IntelligenceImageCaptionResult,
|
|
27
|
+
IntelligenceImageGeneratePayload,
|
|
28
|
+
IntelligenceImageGenerateResult,
|
|
29
|
+
IntelligenceIntentDetectPayload,
|
|
30
|
+
IntelligenceIntentDetectResult,
|
|
31
|
+
IntelligenceInvokeOptions,
|
|
32
|
+
IntelligenceInvokeResult,
|
|
33
|
+
IntelligenceKeywordsExtractPayload,
|
|
34
|
+
IntelligenceKeywordsExtractResult,
|
|
35
|
+
IntelligenceProviderConfig,
|
|
36
|
+
IntelligenceRAGQueryPayload,
|
|
37
|
+
IntelligenceRAGQueryResult,
|
|
38
|
+
IntelligenceRerankPayload,
|
|
39
|
+
IntelligenceRerankResult,
|
|
40
|
+
IntelligenceRewritePayload,
|
|
41
|
+
IntelligenceSemanticSearchPayload,
|
|
42
|
+
IntelligenceSemanticSearchResult,
|
|
43
|
+
IntelligenceSentimentAnalyzePayload,
|
|
44
|
+
IntelligenceSentimentAnalyzeResult,
|
|
45
|
+
IntelligenceSummarizePayload,
|
|
46
|
+
IntelligenceTranslatePayload,
|
|
47
|
+
IntelligenceVisionOcrPayload,
|
|
48
|
+
IntelligenceVisionOcrResult,
|
|
10
49
|
} from '../../types/intelligence'
|
|
11
50
|
import { ref } from 'vue'
|
|
12
51
|
import { useChannel } from './use-channel'
|
|
@@ -20,11 +59,11 @@ interface IntelligenceComposable {
|
|
|
20
59
|
invoke: <T = any>(
|
|
21
60
|
capabilityId: string,
|
|
22
61
|
payload: any,
|
|
23
|
-
options?:
|
|
24
|
-
) => Promise<
|
|
62
|
+
options?: IntelligenceInvokeOptions,
|
|
63
|
+
) => Promise<IntelligenceInvokeResult<T>>
|
|
25
64
|
|
|
26
65
|
// Provider testing
|
|
27
|
-
testProvider: (config:
|
|
66
|
+
testProvider: (config: IntelligenceProviderConfig) => Promise<{
|
|
28
67
|
success: boolean
|
|
29
68
|
message: string
|
|
30
69
|
latency?: number
|
|
@@ -50,21 +89,56 @@ interface IntelligenceComposable {
|
|
|
50
89
|
inputHint: string
|
|
51
90
|
}>
|
|
52
91
|
|
|
53
|
-
//
|
|
92
|
+
// Text methods
|
|
54
93
|
text: {
|
|
55
|
-
chat: (payload:
|
|
56
|
-
translate: (payload:
|
|
57
|
-
summarize: (payload:
|
|
94
|
+
chat: (payload: IntelligenceChatPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<string>>
|
|
95
|
+
translate: (payload: IntelligenceTranslatePayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<string>>
|
|
96
|
+
summarize: (payload: IntelligenceSummarizePayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<string>>
|
|
97
|
+
rewrite: (payload: IntelligenceRewritePayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<string>>
|
|
98
|
+
grammarCheck: (payload: IntelligenceGrammarCheckPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceGrammarCheckResult>>
|
|
58
99
|
}
|
|
59
100
|
|
|
60
|
-
//
|
|
101
|
+
// Embedding methods
|
|
61
102
|
embedding: {
|
|
62
|
-
generate: (payload:
|
|
103
|
+
generate: (payload: IntelligenceEmbeddingPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<number[]>>
|
|
63
104
|
}
|
|
64
105
|
|
|
65
|
-
//
|
|
106
|
+
// Code methods
|
|
107
|
+
code: {
|
|
108
|
+
generate: (payload: IntelligenceCodeGeneratePayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeGenerateResult>>
|
|
109
|
+
explain: (payload: IntelligenceCodeExplainPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeExplainResult>>
|
|
110
|
+
review: (payload: IntelligenceCodeReviewPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeReviewResult>>
|
|
111
|
+
refactor: (payload: IntelligenceCodeRefactorPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeRefactorResult>>
|
|
112
|
+
debug: (payload: IntelligenceCodeDebugPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeDebugResult>>
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Analysis methods
|
|
116
|
+
analysis: {
|
|
117
|
+
detectIntent: (payload: IntelligenceIntentDetectPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceIntentDetectResult>>
|
|
118
|
+
analyzeSentiment: (payload: IntelligenceSentimentAnalyzePayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceSentimentAnalyzeResult>>
|
|
119
|
+
extractContent: (payload: IntelligenceContentExtractPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceContentExtractResult>>
|
|
120
|
+
extractKeywords: (payload: IntelligenceKeywordsExtractPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceKeywordsExtractResult>>
|
|
121
|
+
classify: (payload: IntelligenceClassificationPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceClassificationResult>>
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Vision methods
|
|
66
125
|
vision: {
|
|
67
|
-
ocr: (payload:
|
|
126
|
+
ocr: (payload: IntelligenceVisionOcrPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceVisionOcrResult>>
|
|
127
|
+
caption: (payload: IntelligenceImageCaptionPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceImageCaptionResult>>
|
|
128
|
+
analyze: (payload: IntelligenceImageAnalyzePayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceImageAnalyzeResult>>
|
|
129
|
+
generate: (payload: IntelligenceImageGeneratePayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceImageGenerateResult>>
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// RAG methods
|
|
133
|
+
rag: {
|
|
134
|
+
query: (payload: IntelligenceRAGQueryPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceRAGQueryResult>>
|
|
135
|
+
semanticSearch: (payload: IntelligenceSemanticSearchPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceSemanticSearchResult>>
|
|
136
|
+
rerank: (payload: IntelligenceRerankPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceRerankResult>>
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Agent methods
|
|
140
|
+
agent: {
|
|
141
|
+
run: (payload: IntelligenceAgentPayload, options?: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceAgentResult>>
|
|
68
142
|
}
|
|
69
143
|
|
|
70
144
|
// Loading state
|
|
@@ -143,13 +217,13 @@ export function useIntelligence(_options: UseIntelligenceOptions = {}): Intellig
|
|
|
143
217
|
|
|
144
218
|
return {
|
|
145
219
|
// Core invoke
|
|
146
|
-
invoke: <T = any>(capabilityId: string, payload: any, options?:
|
|
220
|
+
invoke: <T = any>(capabilityId: string, payload: any, options?: IntelligenceInvokeOptions) =>
|
|
147
221
|
withLoadingState(() =>
|
|
148
|
-
sendChannelRequest<
|
|
222
|
+
sendChannelRequest<IntelligenceInvokeResult<T>>('intelligence:invoke', { capabilityId, payload, options }),
|
|
149
223
|
),
|
|
150
224
|
|
|
151
225
|
// Provider testing
|
|
152
|
-
testProvider: (config:
|
|
226
|
+
testProvider: (config: IntelligenceProviderConfig) =>
|
|
153
227
|
withLoadingState(() =>
|
|
154
228
|
sendChannelRequest<{
|
|
155
229
|
success: boolean
|
|
@@ -175,41 +249,59 @@ export function useIntelligence(_options: UseIntelligenceOptions = {}): Intellig
|
|
|
175
249
|
inputHint: string
|
|
176
250
|
}>('intelligence:get-capability-test-meta', params),
|
|
177
251
|
|
|
178
|
-
//
|
|
252
|
+
// Text methods
|
|
179
253
|
text: {
|
|
180
|
-
chat: (payload:
|
|
254
|
+
chat: (payload: IntelligenceChatPayload, options?: IntelligenceInvokeOptions) =>
|
|
181
255
|
withLoadingState(() =>
|
|
182
|
-
sendChannelRequest<
|
|
256
|
+
sendChannelRequest<IntelligenceInvokeResult<string>>('intelligence:invoke', {
|
|
183
257
|
capabilityId: 'text.chat',
|
|
184
258
|
payload,
|
|
185
259
|
options,
|
|
186
260
|
}),
|
|
187
261
|
),
|
|
188
262
|
|
|
189
|
-
translate: (payload:
|
|
263
|
+
translate: (payload: IntelligenceTranslatePayload, options?: IntelligenceInvokeOptions) =>
|
|
190
264
|
withLoadingState(() =>
|
|
191
|
-
sendChannelRequest<
|
|
265
|
+
sendChannelRequest<IntelligenceInvokeResult<string>>('intelligence:invoke', {
|
|
192
266
|
capabilityId: 'text.translate',
|
|
193
267
|
payload,
|
|
194
268
|
options,
|
|
195
269
|
}),
|
|
196
270
|
),
|
|
197
271
|
|
|
198
|
-
summarize: (payload:
|
|
272
|
+
summarize: (payload: IntelligenceSummarizePayload, options?: IntelligenceInvokeOptions) =>
|
|
199
273
|
withLoadingState(() =>
|
|
200
|
-
sendChannelRequest<
|
|
274
|
+
sendChannelRequest<IntelligenceInvokeResult<string>>('intelligence:invoke', {
|
|
201
275
|
capabilityId: 'text.summarize',
|
|
202
276
|
payload,
|
|
203
277
|
options,
|
|
204
278
|
}),
|
|
205
279
|
),
|
|
280
|
+
|
|
281
|
+
rewrite: (payload: IntelligenceRewritePayload, options?: IntelligenceInvokeOptions) =>
|
|
282
|
+
withLoadingState(() =>
|
|
283
|
+
sendChannelRequest<IntelligenceInvokeResult<string>>('intelligence:invoke', {
|
|
284
|
+
capabilityId: 'text.rewrite',
|
|
285
|
+
payload,
|
|
286
|
+
options,
|
|
287
|
+
}),
|
|
288
|
+
),
|
|
289
|
+
|
|
290
|
+
grammarCheck: (payload: IntelligenceGrammarCheckPayload, options?: IntelligenceInvokeOptions) =>
|
|
291
|
+
withLoadingState(() =>
|
|
292
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceGrammarCheckResult>>('intelligence:invoke', {
|
|
293
|
+
capabilityId: 'text.grammar',
|
|
294
|
+
payload,
|
|
295
|
+
options,
|
|
296
|
+
}),
|
|
297
|
+
),
|
|
206
298
|
},
|
|
207
299
|
|
|
208
|
-
//
|
|
300
|
+
// Embedding methods
|
|
209
301
|
embedding: {
|
|
210
|
-
generate: (payload:
|
|
302
|
+
generate: (payload: IntelligenceEmbeddingPayload, options?: IntelligenceInvokeOptions) =>
|
|
211
303
|
withLoadingState(() =>
|
|
212
|
-
sendChannelRequest<
|
|
304
|
+
sendChannelRequest<IntelligenceInvokeResult<number[]>>('intelligence:invoke', {
|
|
213
305
|
capabilityId: 'embedding.generate',
|
|
214
306
|
payload,
|
|
215
307
|
options,
|
|
@@ -217,16 +309,181 @@ export function useIntelligence(_options: UseIntelligenceOptions = {}): Intellig
|
|
|
217
309
|
),
|
|
218
310
|
},
|
|
219
311
|
|
|
220
|
-
//
|
|
312
|
+
// Code methods
|
|
313
|
+
code: {
|
|
314
|
+
generate: (payload: IntelligenceCodeGeneratePayload, options?: IntelligenceInvokeOptions) =>
|
|
315
|
+
withLoadingState(() =>
|
|
316
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceCodeGenerateResult>>('intelligence:invoke', {
|
|
317
|
+
capabilityId: 'code.generate',
|
|
318
|
+
payload,
|
|
319
|
+
options,
|
|
320
|
+
}),
|
|
321
|
+
),
|
|
322
|
+
|
|
323
|
+
explain: (payload: IntelligenceCodeExplainPayload, options?: IntelligenceInvokeOptions) =>
|
|
324
|
+
withLoadingState(() =>
|
|
325
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceCodeExplainResult>>('intelligence:invoke', {
|
|
326
|
+
capabilityId: 'code.explain',
|
|
327
|
+
payload,
|
|
328
|
+
options,
|
|
329
|
+
}),
|
|
330
|
+
),
|
|
331
|
+
|
|
332
|
+
review: (payload: IntelligenceCodeReviewPayload, options?: IntelligenceInvokeOptions) =>
|
|
333
|
+
withLoadingState(() =>
|
|
334
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceCodeReviewResult>>('intelligence:invoke', {
|
|
335
|
+
capabilityId: 'code.review',
|
|
336
|
+
payload,
|
|
337
|
+
options,
|
|
338
|
+
}),
|
|
339
|
+
),
|
|
340
|
+
|
|
341
|
+
refactor: (payload: IntelligenceCodeRefactorPayload, options?: IntelligenceInvokeOptions) =>
|
|
342
|
+
withLoadingState(() =>
|
|
343
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceCodeRefactorResult>>('intelligence:invoke', {
|
|
344
|
+
capabilityId: 'code.refactor',
|
|
345
|
+
payload,
|
|
346
|
+
options,
|
|
347
|
+
}),
|
|
348
|
+
),
|
|
349
|
+
|
|
350
|
+
debug: (payload: IntelligenceCodeDebugPayload, options?: IntelligenceInvokeOptions) =>
|
|
351
|
+
withLoadingState(() =>
|
|
352
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceCodeDebugResult>>('intelligence:invoke', {
|
|
353
|
+
capabilityId: 'code.debug',
|
|
354
|
+
payload,
|
|
355
|
+
options,
|
|
356
|
+
}),
|
|
357
|
+
),
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
// Analysis methods
|
|
361
|
+
analysis: {
|
|
362
|
+
detectIntent: (payload: IntelligenceIntentDetectPayload, options?: IntelligenceInvokeOptions) =>
|
|
363
|
+
withLoadingState(() =>
|
|
364
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceIntentDetectResult>>('intelligence:invoke', {
|
|
365
|
+
capabilityId: 'intent.detect',
|
|
366
|
+
payload,
|
|
367
|
+
options,
|
|
368
|
+
}),
|
|
369
|
+
),
|
|
370
|
+
|
|
371
|
+
analyzeSentiment: (payload: IntelligenceSentimentAnalyzePayload, options?: IntelligenceInvokeOptions) =>
|
|
372
|
+
withLoadingState(() =>
|
|
373
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceSentimentAnalyzeResult>>('intelligence:invoke', {
|
|
374
|
+
capabilityId: 'sentiment.analyze',
|
|
375
|
+
payload,
|
|
376
|
+
options,
|
|
377
|
+
}),
|
|
378
|
+
),
|
|
379
|
+
|
|
380
|
+
extractContent: (payload: IntelligenceContentExtractPayload, options?: IntelligenceInvokeOptions) =>
|
|
381
|
+
withLoadingState(() =>
|
|
382
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceContentExtractResult>>('intelligence:invoke', {
|
|
383
|
+
capabilityId: 'content.extract',
|
|
384
|
+
payload,
|
|
385
|
+
options,
|
|
386
|
+
}),
|
|
387
|
+
),
|
|
388
|
+
|
|
389
|
+
extractKeywords: (payload: IntelligenceKeywordsExtractPayload, options?: IntelligenceInvokeOptions) =>
|
|
390
|
+
withLoadingState(() =>
|
|
391
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceKeywordsExtractResult>>('intelligence:invoke', {
|
|
392
|
+
capabilityId: 'keywords.extract',
|
|
393
|
+
payload,
|
|
394
|
+
options,
|
|
395
|
+
}),
|
|
396
|
+
),
|
|
397
|
+
|
|
398
|
+
classify: (payload: IntelligenceClassificationPayload, options?: IntelligenceInvokeOptions) =>
|
|
399
|
+
withLoadingState(() =>
|
|
400
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceClassificationResult>>('intelligence:invoke', {
|
|
401
|
+
capabilityId: 'text.classify',
|
|
402
|
+
payload,
|
|
403
|
+
options,
|
|
404
|
+
}),
|
|
405
|
+
),
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
// Vision methods
|
|
221
409
|
vision: {
|
|
222
|
-
ocr: (payload:
|
|
410
|
+
ocr: (payload: IntelligenceVisionOcrPayload, options?: IntelligenceInvokeOptions) =>
|
|
223
411
|
withLoadingState(() =>
|
|
224
|
-
sendChannelRequest<
|
|
412
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceVisionOcrResult>>('intelligence:invoke', {
|
|
225
413
|
capabilityId: 'vision.ocr',
|
|
226
414
|
payload,
|
|
227
415
|
options,
|
|
228
416
|
}),
|
|
229
417
|
),
|
|
418
|
+
|
|
419
|
+
caption: (payload: IntelligenceImageCaptionPayload, options?: IntelligenceInvokeOptions) =>
|
|
420
|
+
withLoadingState(() =>
|
|
421
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceImageCaptionResult>>('intelligence:invoke', {
|
|
422
|
+
capabilityId: 'image.caption',
|
|
423
|
+
payload,
|
|
424
|
+
options,
|
|
425
|
+
}),
|
|
426
|
+
),
|
|
427
|
+
|
|
428
|
+
analyze: (payload: IntelligenceImageAnalyzePayload, options?: IntelligenceInvokeOptions) =>
|
|
429
|
+
withLoadingState(() =>
|
|
430
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceImageAnalyzeResult>>('intelligence:invoke', {
|
|
431
|
+
capabilityId: 'image.analyze',
|
|
432
|
+
payload,
|
|
433
|
+
options,
|
|
434
|
+
}),
|
|
435
|
+
),
|
|
436
|
+
|
|
437
|
+
generate: (payload: IntelligenceImageGeneratePayload, options?: IntelligenceInvokeOptions) =>
|
|
438
|
+
withLoadingState(() =>
|
|
439
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceImageGenerateResult>>('intelligence:invoke', {
|
|
440
|
+
capabilityId: 'image.generate',
|
|
441
|
+
payload,
|
|
442
|
+
options,
|
|
443
|
+
}),
|
|
444
|
+
),
|
|
445
|
+
},
|
|
446
|
+
|
|
447
|
+
// RAG methods
|
|
448
|
+
rag: {
|
|
449
|
+
query: (payload: IntelligenceRAGQueryPayload, options?: IntelligenceInvokeOptions) =>
|
|
450
|
+
withLoadingState(() =>
|
|
451
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceRAGQueryResult>>('intelligence:invoke', {
|
|
452
|
+
capabilityId: 'rag.query',
|
|
453
|
+
payload,
|
|
454
|
+
options,
|
|
455
|
+
}),
|
|
456
|
+
),
|
|
457
|
+
|
|
458
|
+
semanticSearch: (payload: IntelligenceSemanticSearchPayload, options?: IntelligenceInvokeOptions) =>
|
|
459
|
+
withLoadingState(() =>
|
|
460
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceSemanticSearchResult>>('intelligence:invoke', {
|
|
461
|
+
capabilityId: 'search.semantic',
|
|
462
|
+
payload,
|
|
463
|
+
options,
|
|
464
|
+
}),
|
|
465
|
+
),
|
|
466
|
+
|
|
467
|
+
rerank: (payload: IntelligenceRerankPayload, options?: IntelligenceInvokeOptions) =>
|
|
468
|
+
withLoadingState(() =>
|
|
469
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceRerankResult>>('intelligence:invoke', {
|
|
470
|
+
capabilityId: 'search.rerank',
|
|
471
|
+
payload,
|
|
472
|
+
options,
|
|
473
|
+
}),
|
|
474
|
+
),
|
|
475
|
+
},
|
|
476
|
+
|
|
477
|
+
// Agent methods
|
|
478
|
+
agent: {
|
|
479
|
+
run: (payload: IntelligenceAgentPayload, options?: IntelligenceInvokeOptions) =>
|
|
480
|
+
withLoadingState(() =>
|
|
481
|
+
sendChannelRequest<IntelligenceInvokeResult<IntelligenceAgentResult>>('intelligence:invoke', {
|
|
482
|
+
capabilityId: 'agent.run',
|
|
483
|
+
payload,
|
|
484
|
+
options,
|
|
485
|
+
}),
|
|
486
|
+
),
|
|
230
487
|
},
|
|
231
488
|
|
|
232
489
|
// Reactive state
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IntelligenceProviderConfig, AISDKGlobalConfig, AISDKStorageData } from '../../types/intelligence'
|
|
2
2
|
import { StorageList } from '../../common/storage/constants'
|
|
3
3
|
import {
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
IntelligenceProviderType,
|
|
6
6
|
|
|
7
7
|
DEFAULT_CAPABILITIES,
|
|
8
8
|
DEFAULT_GLOBAL_CONFIG,
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
import { createStorageProxy, TouchStorage } from './base-storage'
|
|
12
12
|
|
|
13
13
|
// Re-export types for convenience
|
|
14
|
-
export {
|
|
15
|
-
export type {
|
|
14
|
+
export { IntelligenceProviderType }
|
|
15
|
+
export type { IntelligenceProviderConfig, AISDKGlobalConfig }
|
|
16
16
|
|
|
17
17
|
const defaultIntelligenceData: AISDKStorageData = {
|
|
18
18
|
providers: [...DEFAULT_PROVIDERS],
|
|
@@ -32,7 +32,7 @@ class IntelligenceStorage extends TouchStorage<AISDKStorageData> {
|
|
|
32
32
|
/**
|
|
33
33
|
* 添加新的提供商
|
|
34
34
|
*/
|
|
35
|
-
addProvider(provider:
|
|
35
|
+
addProvider(provider: IntelligenceProviderConfig): void {
|
|
36
36
|
const currentData = this.get()
|
|
37
37
|
const updatedProviders = [...currentData.providers, provider]
|
|
38
38
|
this.set({
|
|
@@ -44,7 +44,7 @@ class IntelligenceStorage extends TouchStorage<AISDKStorageData> {
|
|
|
44
44
|
/**
|
|
45
45
|
* 更新提供商配置
|
|
46
46
|
*/
|
|
47
|
-
updateProvider(id: string, updatedProvider: Partial<
|
|
47
|
+
updateProvider(id: string, updatedProvider: Partial<IntelligenceProviderConfig>): void {
|
|
48
48
|
const currentData = this.get()
|
|
49
49
|
const providerIndex = currentData.providers.findIndex(p => p.id === id)
|
|
50
50
|
|
|
@@ -93,14 +93,14 @@ class IntelligenceStorage extends TouchStorage<AISDKStorageData> {
|
|
|
93
93
|
/**
|
|
94
94
|
* 获取特定类型的提供商
|
|
95
95
|
*/
|
|
96
|
-
getProvidersByType(type:
|
|
96
|
+
getProvidersByType(type: IntelligenceProviderType): IntelligenceProviderConfig[] {
|
|
97
97
|
return this.get().providers.filter(p => p.type === type)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* 获取启用的提供商
|
|
102
102
|
*/
|
|
103
|
-
getEnabledProviders():
|
|
103
|
+
getEnabledProviders(): IntelligenceProviderConfig[] {
|
|
104
104
|
return this.get().providers.filter(p => p.enabled)
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -113,7 +113,7 @@ class IntelligenceStorage extends TouchStorage<AISDKStorageData> {
|
|
|
113
113
|
return false
|
|
114
114
|
|
|
115
115
|
// 检查是否有必要的配置项
|
|
116
|
-
const hasApiKey = provider.type ===
|
|
116
|
+
const hasApiKey = provider.type === IntelligenceProviderType.LOCAL || !!provider.apiKey
|
|
117
117
|
const hasModels = !!(provider.models && provider.models.length > 0)
|
|
118
118
|
|
|
119
119
|
return hasApiKey && hasModels
|
package/types/division-box.ts
CHANGED
|
@@ -93,6 +93,23 @@ export interface HeaderConfig {
|
|
|
93
93
|
*/
|
|
94
94
|
export type DivisionBoxSize = 'compact' | 'medium' | 'expanded'
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* UI configuration for DivisionBox CoreBox header
|
|
98
|
+
*/
|
|
99
|
+
export interface DivisionBoxUIConfig {
|
|
100
|
+
/** Show the search input in header */
|
|
101
|
+
showInput?: boolean
|
|
102
|
+
|
|
103
|
+
/** Placeholder text for search input */
|
|
104
|
+
inputPlaceholder?: string
|
|
105
|
+
|
|
106
|
+
/** Show result list area */
|
|
107
|
+
showResults?: boolean
|
|
108
|
+
|
|
109
|
+
/** Initial input value */
|
|
110
|
+
initialInput?: string
|
|
111
|
+
}
|
|
112
|
+
|
|
96
113
|
/**
|
|
97
114
|
* Configuration for creating a DivisionBox instance
|
|
98
115
|
*/
|
|
@@ -118,6 +135,9 @@ export interface DivisionBoxConfig {
|
|
|
118
135
|
/** Header configuration */
|
|
119
136
|
header?: HeaderConfig
|
|
120
137
|
|
|
138
|
+
/** UI configuration for CoreBox header display */
|
|
139
|
+
ui?: DivisionBoxUIConfig
|
|
140
|
+
|
|
121
141
|
/** WebContentsView preferences (main process only) */
|
|
122
142
|
webPreferences?: any
|
|
123
143
|
}
|