@theia/ai-google 1.60.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/README.md +32 -0
- package/lib/browser/google-frontend-application-contribution.d.ts +11 -0
- package/lib/browser/google-frontend-application-contribution.d.ts.map +1 -0
- package/lib/browser/google-frontend-application-contribution.js +78 -0
- package/lib/browser/google-frontend-application-contribution.js.map +1 -0
- package/lib/browser/google-frontend-module.d.ts +4 -0
- package/lib/browser/google-frontend-module.d.ts.map +1 -0
- package/lib/browser/google-frontend-module.js +32 -0
- package/lib/browser/google-frontend-module.js.map +1 -0
- package/lib/browser/google-preferences.d.ts +5 -0
- package/lib/browser/google-preferences.d.ts.map +1 -0
- package/lib/browser/google-preferences.js +43 -0
- package/lib/browser/google-preferences.js.map +1 -0
- package/lib/common/google-language-models-manager.d.ts +31 -0
- package/lib/common/google-language-models-manager.d.ts.map +1 -0
- package/lib/common/google-language-models-manager.js +21 -0
- package/lib/common/google-language-models-manager.js.map +1 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +20 -0
- package/lib/common/index.js.map +1 -0
- package/lib/node/google-backend-module.d.ts +4 -0
- package/lib/node/google-backend-module.d.ts.map +1 -0
- package/lib/node/google-backend-module.js +32 -0
- package/lib/node/google-backend-module.js.map +1 -0
- package/lib/node/google-language-model.d.ts +21 -0
- package/lib/node/google-language-model.d.ts.map +1 -0
- package/lib/node/google-language-model.js +315 -0
- package/lib/node/google-language-model.js.map +1 -0
- package/lib/node/google-language-models-manager-impl.d.ts +11 -0
- package/lib/node/google-language-models-manager-impl.d.ts.map +1 -0
- package/lib/node/google-language-models-manager-impl.js +76 -0
- package/lib/node/google-language-models-manager-impl.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +26 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +53 -0
- package/src/browser/google-frontend-application-contribution.ts +78 -0
- package/src/browser/google-frontend-module.ts +31 -0
- package/src/browser/google-preferences.ts +44 -0
- package/src/common/google-language-models-manager.ts +46 -0
- package/src/common/index.ts +16 -0
- package/src/node/google-backend-module.ts +34 -0
- package/src/node/google-language-model.ts +361 -0
- package/src/node/google-language-models-manager-impl.ts +79 -0
- package/src/package.spec.ts +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - Google EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/ai-google` integrates Google's models with Theia AI.
|
|
16
|
+
The Google API key and the models to use can be configured via preferences.
|
|
17
|
+
Alternatively the API key can also be handed in via the `GOOGLE_API_KEY` environment variable.
|
|
18
|
+
|
|
19
|
+
## Additional Information
|
|
20
|
+
|
|
21
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
22
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
27
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
28
|
+
|
|
29
|
+
## Trademark
|
|
30
|
+
|
|
31
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
32
|
+
<https://www.eclipse.org/theia>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
|
|
2
|
+
import { GoogleLanguageModelsManager, GoogleModelDescription } from '../common';
|
|
3
|
+
export declare class GoogleFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
4
|
+
protected preferenceService: PreferenceService;
|
|
5
|
+
protected manager: GoogleLanguageModelsManager;
|
|
6
|
+
protected prevModels: string[];
|
|
7
|
+
onStart(): void;
|
|
8
|
+
protected handleModelChanges(newModels: string[]): void;
|
|
9
|
+
protected createGeminiModelDescription(modelId: string): GoogleModelDescription;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=google-frontend-application-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/google-frontend-application-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE7F,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAKhF,qBACa,qCAAsC,YAAW,+BAA+B;IAGzF,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAG/C,SAAS,CAAC,OAAO,EAAE,2BAA2B,CAAC;IAE/C,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,CAAM;IAEpC,OAAO,IAAI,IAAI;IAmBf,SAAS,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAYvD,SAAS,CAAC,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB;CAYlF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.GoogleFrontendApplicationContribution = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
21
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
+
const common_1 = require("../common");
|
|
23
|
+
const google_preferences_1 = require("./google-preferences");
|
|
24
|
+
const GOOGLE_PROVIDER_ID = 'google';
|
|
25
|
+
let GoogleFrontendApplicationContribution = class GoogleFrontendApplicationContribution {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.prevModels = [];
|
|
28
|
+
}
|
|
29
|
+
onStart() {
|
|
30
|
+
this.preferenceService.ready.then(() => {
|
|
31
|
+
const apiKey = this.preferenceService.get(google_preferences_1.API_KEY_PREF, undefined);
|
|
32
|
+
this.manager.setApiKey(apiKey);
|
|
33
|
+
const models = this.preferenceService.get(google_preferences_1.MODELS_PREF, []);
|
|
34
|
+
this.manager.createOrUpdateLanguageModels(...models.map(modelId => this.createGeminiModelDescription(modelId)));
|
|
35
|
+
this.prevModels = [...models];
|
|
36
|
+
this.preferenceService.onPreferenceChanged(event => {
|
|
37
|
+
if (event.preferenceName === google_preferences_1.API_KEY_PREF) {
|
|
38
|
+
this.manager.setApiKey(event.newValue);
|
|
39
|
+
}
|
|
40
|
+
else if (event.preferenceName === google_preferences_1.MODELS_PREF) {
|
|
41
|
+
this.handleModelChanges(event.newValue);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
handleModelChanges(newModels) {
|
|
47
|
+
const oldModels = new Set(this.prevModels);
|
|
48
|
+
const updatedModels = new Set(newModels);
|
|
49
|
+
const modelsToRemove = [...oldModels].filter(model => !updatedModels.has(model));
|
|
50
|
+
const modelsToAdd = [...updatedModels].filter(model => !oldModels.has(model));
|
|
51
|
+
this.manager.removeLanguageModels(...modelsToRemove.map(model => `${GOOGLE_PROVIDER_ID}/${model}`));
|
|
52
|
+
this.manager.createOrUpdateLanguageModels(...modelsToAdd.map(modelId => this.createGeminiModelDescription(modelId)));
|
|
53
|
+
this.prevModels = newModels;
|
|
54
|
+
}
|
|
55
|
+
createGeminiModelDescription(modelId) {
|
|
56
|
+
const id = `${GOOGLE_PROVIDER_ID}/${modelId}`;
|
|
57
|
+
const description = {
|
|
58
|
+
id: id,
|
|
59
|
+
model: modelId,
|
|
60
|
+
apiKey: true,
|
|
61
|
+
enableStreaming: true
|
|
62
|
+
};
|
|
63
|
+
return description;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.GoogleFrontendApplicationContribution = GoogleFrontendApplicationContribution;
|
|
67
|
+
tslib_1.__decorate([
|
|
68
|
+
(0, inversify_1.inject)(browser_1.PreferenceService),
|
|
69
|
+
tslib_1.__metadata("design:type", Object)
|
|
70
|
+
], GoogleFrontendApplicationContribution.prototype, "preferenceService", void 0);
|
|
71
|
+
tslib_1.__decorate([
|
|
72
|
+
(0, inversify_1.inject)(common_1.GoogleLanguageModelsManager),
|
|
73
|
+
tslib_1.__metadata("design:type", Object)
|
|
74
|
+
], GoogleFrontendApplicationContribution.prototype, "manager", void 0);
|
|
75
|
+
exports.GoogleFrontendApplicationContribution = GoogleFrontendApplicationContribution = tslib_1.__decorate([
|
|
76
|
+
(0, inversify_1.injectable)()
|
|
77
|
+
], GoogleFrontendApplicationContribution);
|
|
78
|
+
//# sourceMappingURL=google-frontend-application-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/google-frontend-application-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,qDAA6F;AAC7F,4DAAkE;AAClE,sCAAgF;AAChF,6DAAiE;AAEjE,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAG7B,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAA3C;QAQO,eAAU,GAAa,EAAE,CAAC;IA6CxC,CAAC;IA3CG,OAAO;QACH,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAS,iCAAY,EAAE,SAAS,CAAC,CAAC;YAC3E,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAE/B,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAW,gCAAW,EAAE,EAAE,CAAC,CAAC;YACrE,IAAI,CAAC,OAAO,CAAC,4BAA4B,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAChH,IAAI,CAAC,UAAU,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;YAE9B,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE;gBAC/C,IAAI,KAAK,CAAC,cAAc,KAAK,iCAAY,EAAE,CAAC;oBACxC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CA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AAe,EAAE,IAAI;SACxB,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ,CAAA;AArDY,sFAAqC;AAGpC;IADT,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;gFACqB;AAGrC;IADT,IAAA,kBAAM,EAAC,oCAA2B,CAAC;;sEACW;gDANtC,qCAAqC;IADjD,IAAA,sBAAU,GAAE;GACA,qCAAqC,CAqDjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/google-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAM/D,wBAQG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
19
|
+
const google_preferences_1 = require("./google-preferences");
|
|
20
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
21
|
+
const google_frontend_application_contribution_1 = require("./google-frontend-application-contribution");
|
|
22
|
+
const common_1 = require("../common");
|
|
23
|
+
exports.default = new inversify_1.ContainerModule(bind => {
|
|
24
|
+
bind(browser_1.PreferenceContribution).toConstantValue({ schema: google_preferences_1.GooglePreferencesSchema });
|
|
25
|
+
bind(google_frontend_application_contribution_1.GoogleFrontendApplicationContribution).toSelf().inSingletonScope();
|
|
26
|
+
bind(browser_1.FrontendApplicationContribution).toService(google_frontend_application_contribution_1.GoogleFrontendApplicationContribution);
|
|
27
|
+
bind(common_1.GoogleLanguageModelsManager).toDynamicValue(ctx => {
|
|
28
|
+
const provider = ctx.container.get(browser_1.RemoteConnectionProvider);
|
|
29
|
+
return provider.createProxy(common_1.GOOGLE_LANGUAGE_MODELS_MANAGER_PATH);
|
|
30
|
+
}).inSingletonScope();
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=google-frontend-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-frontend-module.js","sourceRoot":"","sources":["../../src/browser/google-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,6DAA+D;AAC/D,qDAAuJ;AACvJ,yGAAmG;AACnG,sCAA6F;AAE7F,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,gCAAsB,CAAC,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,4CAAuB,EAAE,CAAC,CAAC;IAClF,IAAI,CAAC,gFAAqC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACxE,IAAI,CAAC,yCAA+B,CAAC,CAAC,SAAS,CAAC,gFAAqC,CAAC,CAAC;IACvF,IAAI,CAAC,oCAA2B,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QACnD,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAA4B,kCAAwB,CAAC,CAAC;QACxF,OAAO,QAAQ,CAAC,WAAW,CAA8B,4CAAmC,CAAC,CAAC;IAClG,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
|
|
2
|
+
export declare const API_KEY_PREF = "ai-features.google.apiKey";
|
|
3
|
+
export declare const MODELS_PREF = "ai-features.google.models";
|
|
4
|
+
export declare const GooglePreferencesSchema: PreferenceSchema;
|
|
5
|
+
//# sourceMappingURL=google-preferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-preferences.d.ts","sourceRoot":"","sources":["../../src/browser/google-preferences.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6DAA6D,CAAC;AAI/F,eAAO,MAAM,YAAY,8BAA8B,CAAC;AACxD,eAAO,MAAM,WAAW,8BAA8B,CAAC;AAEvD,eAAO,MAAM,uBAAuB,EAAE,gBAoBrC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.GooglePreferencesSchema = exports.MODELS_PREF = exports.API_KEY_PREF = void 0;
|
|
19
|
+
const ai_core_preferences_1 = require("@theia/ai-core/lib/browser/ai-core-preferences");
|
|
20
|
+
const core_1 = require("@theia/core");
|
|
21
|
+
exports.API_KEY_PREF = 'ai-features.google.apiKey';
|
|
22
|
+
exports.MODELS_PREF = 'ai-features.google.models';
|
|
23
|
+
exports.GooglePreferencesSchema = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
[exports.API_KEY_PREF]: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
markdownDescription: core_1.nls.localize('theia/ai/google/apiKey/description', 'Enter an API Key of your official Google AI (Gemini) Account. **Please note:** By using this preference the GOOGLE AI API key will be stored in clear text\
|
|
29
|
+
on the machine running Theia. Use the environment variable `GOOGLE_API_KEY` to set the key securely.'),
|
|
30
|
+
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
31
|
+
},
|
|
32
|
+
[exports.MODELS_PREF]: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
description: core_1.nls.localize('theia/ai/google/models/description', 'Official Google Gemini models to use'),
|
|
35
|
+
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
36
|
+
default: ['gemini-2.0-flash', 'gemini-2.5-pro-exp-03-25', 'gemini-2.0-pro-exp-02-05'],
|
|
37
|
+
items: {
|
|
38
|
+
type: 'string'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=google-preferences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-preferences.js","sourceRoot":"","sources":["../../src/browser/google-preferences.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAGhF,wFAA2F;AAC3F,sCAAkC;AAErB,QAAA,YAAY,GAAG,2BAA2B,CAAC;AAC3C,QAAA,WAAW,GAAG,2BAA2B,CAAC;AAE1C,QAAA,uBAAuB,GAAqB;IACrD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,CAAC,oBAAY,CAAC,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,mBAAmB,EAAE,UAAG,CAAC,QAAQ,CAAC,oCAAoC,EAClE;iHACiG,CAAC;YACtG,KAAK,EAAE,+CAAyB;SACnC;QACD,CAAC,mBAAW,CAAC,EAAE;YACX,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,UAAG,CAAC,QAAQ,CAAC,oCAAoC,EAAE,sCAAsC,CAAC;YACvG,KAAK,EAAE,+CAAyB;YAChC,OAAO,EAAE,CAAC,kBAAkB,EAAE,0BAA0B,EAAE,0BAA0B,CAAC;YACrF,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;aACjB;SACJ;KACJ;CACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const GOOGLE_LANGUAGE_MODELS_MANAGER_PATH = "/services/google/language-model-manager";
|
|
2
|
+
export declare const GoogleLanguageModelsManager: unique symbol;
|
|
3
|
+
export interface GoogleModelDescription {
|
|
4
|
+
/**
|
|
5
|
+
* The identifier of the model which will be shown in the UI.
|
|
6
|
+
*/
|
|
7
|
+
id: string;
|
|
8
|
+
/**
|
|
9
|
+
* The model ID as used by the Google Gemini API.
|
|
10
|
+
*/
|
|
11
|
+
model: string;
|
|
12
|
+
/**
|
|
13
|
+
* The key for the model. If 'true' is provided the global Gemini API key will be used.
|
|
14
|
+
*/
|
|
15
|
+
apiKey: string | true | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Indicate whether the streaming API shall be used.
|
|
18
|
+
*/
|
|
19
|
+
enableStreaming: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Maximum number of tokens to generate. Default is 4096.
|
|
22
|
+
*/
|
|
23
|
+
maxTokens?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface GoogleLanguageModelsManager {
|
|
26
|
+
apiKey: string | undefined;
|
|
27
|
+
setApiKey(key: string | undefined): void;
|
|
28
|
+
createOrUpdateLanguageModels(...models: GoogleModelDescription[]): Promise<void>;
|
|
29
|
+
removeLanguageModels(...modelIds: string[]): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=google-language-models-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-language-models-manager.d.ts","sourceRoot":"","sources":["../../src/common/google-language-models-manager.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,mCAAmC,4CAA4C,CAAC;AAC7F,eAAO,MAAM,2BAA2B,eAAwC,CAAC;AACjF,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CAEtB;AACD,MAAM,WAAW,2BAA2B;IACxC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACzC,4BAA4B,CAAC,GAAG,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjF,oBAAoB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;CACpD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GoogleLanguageModelsManager = exports.GOOGLE_LANGUAGE_MODELS_MANAGER_PATH = void 0;
|
|
4
|
+
// *****************************************************************************
|
|
5
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
6
|
+
//
|
|
7
|
+
// This program and the accompanying materials are made available under the
|
|
8
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
9
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
10
|
+
//
|
|
11
|
+
// This Source Code may also be made available under the following Secondary
|
|
12
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
13
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
14
|
+
// with the GNU Classpath Exception which is available at
|
|
15
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
16
|
+
//
|
|
17
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
18
|
+
// *****************************************************************************
|
|
19
|
+
exports.GOOGLE_LANGUAGE_MODELS_MANAGER_PATH = '/services/google/language-model-manager';
|
|
20
|
+
exports.GoogleLanguageModelsManager = Symbol('GoogleLanguageModelsManager');
|
|
21
|
+
//# sourceMappingURL=google-language-models-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-language-models-manager.js","sourceRoot":"","sources":["../../src/common/google-language-models-manager.ts"],"names":[],"mappings":";;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AACnE,QAAA,mCAAmC,GAAG,yCAAyC,CAAC;AAChF,QAAA,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAeA,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
// *****************************************************************************
|
|
5
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
6
|
+
//
|
|
7
|
+
// This program and the accompanying materials are made available under the
|
|
8
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
9
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
10
|
+
//
|
|
11
|
+
// This Source Code may also be made available under the following Secondary
|
|
12
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
13
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
14
|
+
// with the GNU Classpath Exception which is available at
|
|
15
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
16
|
+
//
|
|
17
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
18
|
+
// *****************************************************************************
|
|
19
|
+
tslib_1.__exportStar(require("./google-language-models-manager"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,2EAAiD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/google-backend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAe/D,wBAEG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
19
|
+
const google_language_models_manager_1 = require("../common/google-language-models-manager");
|
|
20
|
+
const core_1 = require("@theia/core");
|
|
21
|
+
const google_language_models_manager_impl_1 = require("./google-language-models-manager-impl");
|
|
22
|
+
const connection_container_module_1 = require("@theia/core/lib/node/messaging/connection-container-module");
|
|
23
|
+
// We use a connection module to handle AI services separately for each frontend.
|
|
24
|
+
const geminiConnectionModule = connection_container_module_1.ConnectionContainerModule.create(({ bind, bindBackendService, bindFrontendService }) => {
|
|
25
|
+
bind(google_language_models_manager_impl_1.GoogleLanguageModelsManagerImpl).toSelf().inSingletonScope();
|
|
26
|
+
bind(google_language_models_manager_1.GoogleLanguageModelsManager).toService(google_language_models_manager_impl_1.GoogleLanguageModelsManagerImpl);
|
|
27
|
+
bind(core_1.ConnectionHandler).toDynamicValue(ctx => new core_1.RpcConnectionHandler(google_language_models_manager_1.GOOGLE_LANGUAGE_MODELS_MANAGER_PATH, () => ctx.container.get(google_language_models_manager_1.GoogleLanguageModelsManager))).inSingletonScope();
|
|
28
|
+
});
|
|
29
|
+
exports.default = new inversify_1.ContainerModule(bind => {
|
|
30
|
+
bind(connection_container_module_1.ConnectionContainerModule).toConstantValue(geminiConnectionModule);
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=google-backend-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-backend-module.js","sourceRoot":"","sources":["../../src/node/google-backend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,6FAA4H;AAC5H,sCAAsE;AACtE,+FAAwF;AACxF,4GAAuG;AAEvG,iFAAiF;AACjF,MAAM,sBAAsB,GAAG,uDAAyB,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,EAAE,EAAE;IAClH,IAAI,CAAC,qEAA+B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAClE,IAAI,CAAC,4DAA2B,CAAC,CAAC,SAAS,CAAC,qEAA+B,CAAC,CAAC;IAC7E,IAAI,CAAC,wBAAiB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CACzC,IAAI,2BAAoB,CAAC,oEAAmC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,4DAA2B,CAAC,CAAC,CACtH,CAAC,gBAAgB,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,uDAAyB,CAAC,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;AAC5E,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LanguageModel, LanguageModelRequest, LanguageModelResponse, LanguageModelStreamResponse, LanguageModelTextResponse } from '@theia/ai-core';
|
|
2
|
+
import { CancellationToken } from '@theia/core';
|
|
3
|
+
import { GoogleGenAI, Content } from '@google/genai';
|
|
4
|
+
export declare const GoogleModelIdentifier: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* Implements the Gemini language model integration for Theia
|
|
7
|
+
*/
|
|
8
|
+
export declare class GoogleModel implements LanguageModel {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
model: string;
|
|
11
|
+
enableStreaming: boolean;
|
|
12
|
+
apiKey: () => string | undefined;
|
|
13
|
+
constructor(id: string, model: string, enableStreaming: boolean, apiKey: () => string | undefined);
|
|
14
|
+
protected getSettings(request: LanguageModelRequest): Readonly<Record<string, unknown>>;
|
|
15
|
+
request(request: LanguageModelRequest, cancellationToken?: CancellationToken): Promise<LanguageModelResponse>;
|
|
16
|
+
protected handleStreamingRequest(genAI: GoogleGenAI, request: LanguageModelRequest, cancellationToken?: CancellationToken, toolMessages?: Content[]): Promise<LanguageModelStreamResponse>;
|
|
17
|
+
private createFunctionDeclarations;
|
|
18
|
+
protected handleNonStreamingRequest(genAI: GoogleGenAI, request: LanguageModelRequest): Promise<LanguageModelTextResponse>;
|
|
19
|
+
protected initializeGemini(): GoogleGenAI;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=google-language-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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