@codingame/monaco-vscode-ai-service-override 25.1.2 → 26.0.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-ai-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - ai service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "26.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
package/vscode/src/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformationService.js
CHANGED
|
@@ -8,8 +8,12 @@ import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/ins
|
|
|
8
8
|
|
|
9
9
|
var AiRelatedInformationService_1;
|
|
10
10
|
let AiRelatedInformationService = class AiRelatedInformationService {
|
|
11
|
-
static {
|
|
12
|
-
|
|
11
|
+
static {
|
|
12
|
+
AiRelatedInformationService_1 = this;
|
|
13
|
+
}
|
|
14
|
+
static {
|
|
15
|
+
this.DEFAULT_TIMEOUT = 1000 * 10;
|
|
16
|
+
}
|
|
13
17
|
constructor(logService) {
|
|
14
18
|
this.logService = logService;
|
|
15
19
|
this._providers = ( new Map());
|
|
@@ -36,7 +40,7 @@ let AiRelatedInformationService = class AiRelatedInformationService {
|
|
|
36
40
|
}
|
|
37
41
|
async getRelatedInformation(query, types, token) {
|
|
38
42
|
if (this._providers.size === 0) {
|
|
39
|
-
throw ( new Error(
|
|
43
|
+
throw ( new Error("No related information providers registered"));
|
|
40
44
|
}
|
|
41
45
|
const providers = [];
|
|
42
46
|
for (const type of types) {
|
|
@@ -46,41 +50,40 @@ let AiRelatedInformationService = class AiRelatedInformationService {
|
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
if (providers.length === 0) {
|
|
49
|
-
throw ( new Error(
|
|
53
|
+
throw ( new Error("No related information providers registered for the given types"));
|
|
50
54
|
}
|
|
51
55
|
const stopwatch = StopWatch.create();
|
|
52
|
-
const cancellablePromises = ( providers.map(
|
|
53
|
-
return createCancelablePromise(async
|
|
56
|
+
const cancellablePromises = ( providers.map(provider => {
|
|
57
|
+
return createCancelablePromise(async t => {
|
|
54
58
|
try {
|
|
55
59
|
const result = await provider.provideAiRelatedInformation(query, t);
|
|
56
60
|
return result.filter(r => types.includes(r.type));
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
}
|
|
61
|
+
} catch (e) {}
|
|
60
62
|
return [];
|
|
61
63
|
});
|
|
62
64
|
}));
|
|
63
65
|
try {
|
|
64
|
-
const results = await raceTimeout(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const results = await raceTimeout(
|
|
67
|
+
Promise.allSettled(cancellablePromises),
|
|
68
|
+
AiRelatedInformationService_1.DEFAULT_TIMEOUT,
|
|
69
|
+
() => {
|
|
70
|
+
cancellablePromises.forEach(p => p.cancel());
|
|
71
|
+
this.logService.warn("[AiRelatedInformationService]: Related information provider timed out");
|
|
72
|
+
}
|
|
73
|
+
);
|
|
68
74
|
if (!results) {
|
|
69
75
|
return [];
|
|
70
76
|
}
|
|
71
|
-
const result = results
|
|
72
|
-
.filter(r => r.status === 'fulfilled')
|
|
73
|
-
.flatMap(r => r.value);
|
|
77
|
+
const result = results.filter(r => r.status === "fulfilled").flatMap(r => r.value);
|
|
74
78
|
return result;
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
79
|
+
} finally {
|
|
77
80
|
stopwatch.stop();
|
|
78
|
-
this.logService.trace(
|
|
81
|
+
this.logService.trace(
|
|
82
|
+
`[AiRelatedInformationService]: getRelatedInformation took ${stopwatch.elapsed()}ms`
|
|
83
|
+
);
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
};
|
|
82
|
-
AiRelatedInformationService = AiRelatedInformationService_1 = ( __decorate([
|
|
83
|
-
( __param(0, ILogService))
|
|
84
|
-
], AiRelatedInformationService));
|
|
87
|
+
AiRelatedInformationService = AiRelatedInformationService_1 = ( __decorate([( __param(0, ILogService))], AiRelatedInformationService));
|
|
85
88
|
|
|
86
89
|
export { AiRelatedInformationService };
|
|
@@ -15,7 +15,9 @@ class AiSettingsSearchService extends Disposable {
|
|
|
15
15
|
this._onProviderRegistered = this._register(( new Emitter()));
|
|
16
16
|
this.onProviderRegistered = this._onProviderRegistered.event;
|
|
17
17
|
}
|
|
18
|
-
static {
|
|
18
|
+
static {
|
|
19
|
+
this.MAX_PICKS = 5;
|
|
20
|
+
}
|
|
19
21
|
isEnabled() {
|
|
20
22
|
return this._providers.length > 0;
|
|
21
23
|
}
|
|
@@ -33,15 +35,18 @@ class AiSettingsSearchService extends Disposable {
|
|
|
33
35
|
}
|
|
34
36
|
startSearch(query, token) {
|
|
35
37
|
if (!this.isEnabled()) {
|
|
36
|
-
throw ( new Error(
|
|
38
|
+
throw ( new Error("No settings search providers registered"));
|
|
37
39
|
}
|
|
38
40
|
this._embeddingsResultsPromises.delete(query);
|
|
39
41
|
this._llmRankedResultsPromises.delete(query);
|
|
40
|
-
this._providers.forEach(provider => provider.searchSettings(query, {
|
|
42
|
+
this._providers.forEach(provider => provider.searchSettings(query, {
|
|
43
|
+
limit: AiSettingsSearchService.MAX_PICKS,
|
|
44
|
+
embeddingsOnly: false
|
|
45
|
+
}, token));
|
|
41
46
|
}
|
|
42
47
|
async getEmbeddingsResults(query, token) {
|
|
43
48
|
if (!this.isEnabled()) {
|
|
44
|
-
throw ( new Error(
|
|
49
|
+
throw ( new Error("No settings search providers registered"));
|
|
45
50
|
}
|
|
46
51
|
const existingPromise = this._embeddingsResultsPromises.get(query);
|
|
47
52
|
if (existingPromise) {
|
|
@@ -55,7 +60,7 @@ class AiSettingsSearchService extends Disposable {
|
|
|
55
60
|
}
|
|
56
61
|
async getLLMRankedResults(query, token) {
|
|
57
62
|
if (!this.isEnabled()) {
|
|
58
|
-
throw ( new Error(
|
|
63
|
+
throw ( new Error("No settings search providers registered"));
|
|
59
64
|
}
|
|
60
65
|
const existingPromise = this._llmRankedResultsPromises.get(query);
|
|
61
66
|
if (existingPromise) {
|
|
@@ -75,19 +80,16 @@ class AiSettingsSearchService extends Disposable {
|
|
|
75
80
|
const promise = this._embeddingsResultsPromises.get(result.query);
|
|
76
81
|
if (promise) {
|
|
77
82
|
promise.complete(result.settings);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
83
|
+
} else {
|
|
80
84
|
const parkedPromise = ( new DeferredPromise());
|
|
81
85
|
parkedPromise.complete(result.settings);
|
|
82
86
|
this._embeddingsResultsPromises.set(result.query, parkedPromise);
|
|
83
87
|
}
|
|
84
|
-
}
|
|
85
|
-
else if (result.kind === AiSettingsSearchResultKind.LLM_RANKED) {
|
|
88
|
+
} else if (result.kind === AiSettingsSearchResultKind.LLM_RANKED) {
|
|
86
89
|
const promise = this._llmRankedResultsPromises.get(result.query);
|
|
87
90
|
if (promise) {
|
|
88
91
|
promise.complete(result.settings);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
92
|
+
} else {
|
|
91
93
|
const parkedPromise = ( new DeferredPromise());
|
|
92
94
|
parkedPromise.complete(result.settings);
|
|
93
95
|
this._llmRankedResultsPromises.set(result.query, parkedPromise);
|