@codingame/monaco-vscode-ai-service-override 17.2.1 → 18.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": "18.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": "18.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
package/vscode/src/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearchService.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
2
|
-
import {
|
|
2
|
+
import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
|
3
|
+
import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
3
4
|
import { AiSettingsSearchResult, IAiSettingsSearchProvider } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearch";
|
|
4
5
|
import { IAiSettingsSearchService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearch.service";
|
|
5
|
-
export declare class AiSettingsSearchService implements IAiSettingsSearchService {
|
|
6
|
+
export declare class AiSettingsSearchService extends Disposable implements IAiSettingsSearchService {
|
|
6
7
|
readonly _serviceBrand: undefined;
|
|
7
8
|
private static readonly MAX_PICKS;
|
|
8
9
|
private _providers;
|
|
9
10
|
private _llmRankedResultsPromises;
|
|
10
11
|
private _embeddingsResultsPromises;
|
|
12
|
+
private _onProviderRegistered;
|
|
13
|
+
readonly onProviderRegistered: Event<void>;
|
|
11
14
|
isEnabled(): boolean;
|
|
12
15
|
registerSettingsSearchProvider(provider: IAiSettingsSearchProvider): IDisposable;
|
|
13
|
-
startSearch(query: string, token: CancellationToken): void;
|
|
16
|
+
startSearch(query: string, embeddingsOnly: boolean, token: CancellationToken): void;
|
|
14
17
|
getEmbeddingsResults(query: string, token: CancellationToken): Promise<string[] | null>;
|
|
15
18
|
getLLMRankedResults(query: string, token: CancellationToken): Promise<string[] | null>;
|
|
16
19
|
handleSearchResult(result: AiSettingsSearchResult): void;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
import { DeferredPromise, raceCancellation } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
3
|
+
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
4
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
3
5
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
|
|
4
6
|
import { AiSettingsSearchResultKind } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearch';
|
|
5
7
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
8
|
|
|
7
|
-
class AiSettingsSearchService {
|
|
9
|
+
class AiSettingsSearchService extends Disposable {
|
|
8
10
|
constructor() {
|
|
11
|
+
super(...arguments);
|
|
9
12
|
this._providers = [];
|
|
10
13
|
this._llmRankedResultsPromises = ( new Map());
|
|
11
14
|
this._embeddingsResultsPromises = ( new Map());
|
|
15
|
+
this._onProviderRegistered = this._register(( new Emitter()));
|
|
16
|
+
this.onProviderRegistered = this._onProviderRegistered.event;
|
|
12
17
|
}
|
|
13
18
|
static { this.MAX_PICKS = 5; }
|
|
14
19
|
isEnabled() {
|
|
@@ -16,6 +21,7 @@ class AiSettingsSearchService {
|
|
|
16
21
|
}
|
|
17
22
|
registerSettingsSearchProvider(provider) {
|
|
18
23
|
this._providers.push(provider);
|
|
24
|
+
this._onProviderRegistered.fire();
|
|
19
25
|
return {
|
|
20
26
|
dispose: () => {
|
|
21
27
|
const index = this._providers.indexOf(provider);
|
|
@@ -25,16 +31,23 @@ class AiSettingsSearchService {
|
|
|
25
31
|
}
|
|
26
32
|
};
|
|
27
33
|
}
|
|
28
|
-
startSearch(query, token) {
|
|
34
|
+
startSearch(query, embeddingsOnly, token) {
|
|
29
35
|
if (!this.isEnabled()) {
|
|
30
36
|
throw ( new Error('No settings search providers registered'));
|
|
31
37
|
}
|
|
32
|
-
this.
|
|
38
|
+
this._embeddingsResultsPromises.delete(query);
|
|
39
|
+
this._llmRankedResultsPromises.delete(query);
|
|
40
|
+
this._providers.forEach(provider => provider.searchSettings(query, { limit: AiSettingsSearchService.MAX_PICKS, embeddingsOnly }, token));
|
|
33
41
|
}
|
|
34
42
|
async getEmbeddingsResults(query, token) {
|
|
35
43
|
if (!this.isEnabled()) {
|
|
36
44
|
throw ( new Error('No settings search providers registered'));
|
|
37
45
|
}
|
|
46
|
+
const existingPromise = this._embeddingsResultsPromises.get(query);
|
|
47
|
+
if (existingPromise) {
|
|
48
|
+
const result = await existingPromise.p;
|
|
49
|
+
return result ?? null;
|
|
50
|
+
}
|
|
38
51
|
const promise = ( new DeferredPromise());
|
|
39
52
|
this._embeddingsResultsPromises.set(query, promise);
|
|
40
53
|
const result = await raceCancellation(promise.p, token);
|
|
@@ -44,6 +57,11 @@ class AiSettingsSearchService {
|
|
|
44
57
|
if (!this.isEnabled()) {
|
|
45
58
|
throw ( new Error('No settings search providers registered'));
|
|
46
59
|
}
|
|
60
|
+
const existingPromise = this._llmRankedResultsPromises.get(query);
|
|
61
|
+
if (existingPromise) {
|
|
62
|
+
const result = await existingPromise.p;
|
|
63
|
+
return result ?? null;
|
|
64
|
+
}
|
|
47
65
|
const promise = ( new DeferredPromise());
|
|
48
66
|
this._llmRankedResultsPromises.set(query, promise);
|
|
49
67
|
const result = await raceCancellation(promise.p, token);
|
|
@@ -57,14 +75,22 @@ class AiSettingsSearchService {
|
|
|
57
75
|
const promise = this._embeddingsResultsPromises.get(result.query);
|
|
58
76
|
if (promise) {
|
|
59
77
|
promise.complete(result.settings);
|
|
60
|
-
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const parkedPromise = ( new DeferredPromise());
|
|
81
|
+
parkedPromise.complete(result.settings);
|
|
82
|
+
this._embeddingsResultsPromises.set(result.query, parkedPromise);
|
|
61
83
|
}
|
|
62
84
|
}
|
|
63
85
|
else if (result.kind === AiSettingsSearchResultKind.LLM_RANKED) {
|
|
64
86
|
const promise = this._llmRankedResultsPromises.get(result.query);
|
|
65
87
|
if (promise) {
|
|
66
88
|
promise.complete(result.settings);
|
|
67
|
-
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const parkedPromise = ( new DeferredPromise());
|
|
92
|
+
parkedPromise.complete(result.settings);
|
|
93
|
+
this._llmRankedResultsPromises.set(result.query, parkedPromise);
|
|
68
94
|
}
|
|
69
95
|
}
|
|
70
96
|
}
|