@theia/ai-openai 1.46.0-next.241
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 +50 -0
- package/lib/browser/openai-frontend-application-contribution.d.ts +18 -0
- package/lib/browser/openai-frontend-application-contribution.d.ts.map +1 -0
- package/lib/browser/openai-frontend-application-contribution.js +143 -0
- package/lib/browser/openai-frontend-application-contribution.js.map +1 -0
- package/lib/browser/openai-frontend-module.d.ts +4 -0
- package/lib/browser/openai-frontend-module.d.ts.map +1 -0
- package/lib/browser/openai-frontend-module.js +32 -0
- package/lib/browser/openai-frontend-module.js.map +1 -0
- package/lib/browser/openai-preferences.d.ts +6 -0
- package/lib/browser/openai-preferences.d.ts.map +1 -0
- package/lib/browser/openai-preferences.js +84 -0
- package/lib/browser/openai-preferences.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/common/openai-language-models-manager.d.ts +37 -0
- package/lib/common/openai-language-models-manager.d.ts.map +1 -0
- package/lib/common/openai-language-models-manager.js +21 -0
- package/lib/common/openai-language-models-manager.js.map +1 -0
- package/lib/node/openai-backend-module.d.ts +5 -0
- package/lib/node/openai-backend-module.d.ts.map +1 -0
- package/lib/node/openai-backend-module.js +29 -0
- package/lib/node/openai-backend-module.js.map +1 -0
- package/lib/node/openai-language-model.d.ts +36 -0
- package/lib/node/openai-language-model.d.ts.map +1 -0
- package/lib/node/openai-language-model.js +210 -0
- package/lib/node/openai-language-model.js.map +1 -0
- package/lib/node/openai-language-models-manager-impl.d.ts +11 -0
- package/lib/node/openai-language-models-manager-impl.d.ts.map +1 -0
- package/lib/node/openai-language-models-manager-impl.js +80 -0
- package/lib/node/openai-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 +54 -0
- package/src/browser/openai-frontend-application-contribution.ts +162 -0
- package/src/browser/openai-frontend-module.ts +31 -0
- package/src/browser/openai-preferences.ts +84 -0
- package/src/common/index.ts +16 -0
- package/src/common/openai-language-models-manager.ts +49 -0
- package/src/node/openai-backend-module.ts +30 -0
- package/src/node/openai-language-model.ts +234 -0
- package/src/node/openai-language-models-manager-impl.ts +85 -0
- package/src/package.spec.ts +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
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 - Open AI EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/ai-openai` integrates OpenAI's models with Theia AI.
|
|
16
|
+
The OpenAI API key and the models to use can be configured via preferences.
|
|
17
|
+
Alternatively the OpenAI API key can also be handed in via the `OPENAI_API_KEY` variable.
|
|
18
|
+
|
|
19
|
+
### Custom models
|
|
20
|
+
|
|
21
|
+
The extension also supports OpenAI compatible models hosted on different end points.
|
|
22
|
+
You can configure the end points via the `ai-features.openAiCustom.customOpenAiModels` preference:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
{
|
|
26
|
+
model: string
|
|
27
|
+
url: string
|
|
28
|
+
id?: string
|
|
29
|
+
apiKey?: string | true
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- `model` and `url` are mandatory attributes, indicating the end point and model to use
|
|
34
|
+
- `id` is an optional attribute which is used in the UI to refer to this configuration
|
|
35
|
+
- `apiKey` is either the key to access the API served at the given URL or `true` to use the global OpenAI API key. If not given 'no-key' will be used.
|
|
36
|
+
|
|
37
|
+
## Additional Information
|
|
38
|
+
|
|
39
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
40
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
45
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
46
|
+
|
|
47
|
+
## Trademark
|
|
48
|
+
|
|
49
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
50
|
+
<https://www.eclipse.org/theia>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
|
|
2
|
+
import { OpenAiLanguageModelsManager, OpenAiModelDescription } from '../common';
|
|
3
|
+
import { RequestSetting } from '@theia/ai-core/lib/browser/ai-core-preferences';
|
|
4
|
+
export declare class OpenAiFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
5
|
+
protected preferenceService: PreferenceService;
|
|
6
|
+
protected manager: OpenAiLanguageModelsManager;
|
|
7
|
+
protected prevModels: string[];
|
|
8
|
+
protected prevCustomModels: Partial<OpenAiModelDescription>[];
|
|
9
|
+
onStart(): void;
|
|
10
|
+
protected handleModelChanges(newModels: string[]): void;
|
|
11
|
+
private getRequestSettingsPref;
|
|
12
|
+
protected handleCustomModelChanges(newCustomModels: Partial<OpenAiModelDescription>[]): void;
|
|
13
|
+
protected handleRequestSettingsChanges(newSettings: RequestSetting[]): void;
|
|
14
|
+
protected createOpenAIModelDescription(modelId: string, requestSettings: RequestSetting[]): OpenAiModelDescription;
|
|
15
|
+
protected createCustomModelDescriptionsFromPreferences(preferences: Partial<OpenAiModelDescription>[], requestSettings: RequestSetting[]): OpenAiModelDescription[];
|
|
16
|
+
protected getMatchingRequestSetting(modelId: string, providerId: string, requestSettings: RequestSetting[]): RequestSetting | undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=openai-frontend-application-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/openai-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;AAEhF,OAAO,EAAoC,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAIlH,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;IACpC,SAAS,CAAC,gBAAgB,EAAE,OAAO,CAAC,sBAAsB,CAAC,EAAE,CAAM;IAEnE,OAAO,IAAI,IAAI;IA4Bf,SAAS,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAavD,OAAO,CAAC,sBAAsB;IAI9B,SAAS,CAAC,wBAAwB,CAAC,eAAe,EAAE,OAAO,CAAC,sBAAsB,CAAC,EAAE,GAAG,IAAI;IAmB5F,SAAS,CAAC,4BAA4B,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,IAAI;IAQ3E,SAAS,CAAC,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,sBAAsB;IAYlH,SAAS,CAAC,4CAA4C,CAClD,WAAW,EAAE,OAAO,CAAC,sBAAsB,CAAC,EAAE,EAC9C,eAAe,EAAE,cAAc,EAAE,GAClC,sBAAsB,EAAE;IAqB3B,SAAS,CAAC,yBAAyB,CAC/B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,cAAc,EAAE,GAClC,cAAc,GAAG,SAAS;CAWhC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 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.OpenAiFrontendApplicationContribution = 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 openai_preferences_1 = require("./openai-preferences");
|
|
24
|
+
const ai_core_preferences_1 = require("@theia/ai-core/lib/browser/ai-core-preferences");
|
|
25
|
+
const OPENAI_PROVIDER_ID = 'openai';
|
|
26
|
+
let OpenAiFrontendApplicationContribution = class OpenAiFrontendApplicationContribution {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.prevModels = [];
|
|
29
|
+
this.prevCustomModels = [];
|
|
30
|
+
}
|
|
31
|
+
onStart() {
|
|
32
|
+
this.preferenceService.ready.then(() => {
|
|
33
|
+
const apiKey = this.preferenceService.get(openai_preferences_1.API_KEY_PREF, undefined);
|
|
34
|
+
this.manager.setApiKey(apiKey);
|
|
35
|
+
const models = this.preferenceService.get(openai_preferences_1.MODELS_PREF, []);
|
|
36
|
+
const requestSettings = this.getRequestSettingsPref();
|
|
37
|
+
this.manager.createOrUpdateLanguageModels(...models.map(modelId => this.createOpenAIModelDescription(modelId, requestSettings)));
|
|
38
|
+
this.prevModels = [...models];
|
|
39
|
+
const customModels = this.preferenceService.get(openai_preferences_1.CUSTOM_ENDPOINTS_PREF, []);
|
|
40
|
+
this.manager.createOrUpdateLanguageModels(...this.createCustomModelDescriptionsFromPreferences(customModels, this.getRequestSettingsPref()));
|
|
41
|
+
this.prevCustomModels = [...customModels];
|
|
42
|
+
this.preferenceService.onPreferenceChanged(event => {
|
|
43
|
+
if (event.preferenceName === openai_preferences_1.API_KEY_PREF) {
|
|
44
|
+
this.manager.setApiKey(event.newValue);
|
|
45
|
+
}
|
|
46
|
+
else if (event.preferenceName === openai_preferences_1.MODELS_PREF) {
|
|
47
|
+
this.handleModelChanges(event.newValue);
|
|
48
|
+
}
|
|
49
|
+
else if (event.preferenceName === openai_preferences_1.CUSTOM_ENDPOINTS_PREF) {
|
|
50
|
+
this.handleCustomModelChanges(event.newValue);
|
|
51
|
+
}
|
|
52
|
+
else if (event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_REQUEST_SETTINGS) {
|
|
53
|
+
this.handleRequestSettingsChanges(event.newValue);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
handleModelChanges(newModels) {
|
|
59
|
+
const oldModels = new Set(this.prevModels);
|
|
60
|
+
const updatedModels = new Set(newModels);
|
|
61
|
+
const modelsToRemove = [...oldModels].filter(model => !updatedModels.has(model));
|
|
62
|
+
const modelsToAdd = [...updatedModels].filter(model => !oldModels.has(model));
|
|
63
|
+
this.manager.removeLanguageModels(...modelsToRemove.map(model => `openai/${model}`));
|
|
64
|
+
const requestSettings = this.getRequestSettingsPref();
|
|
65
|
+
this.manager.createOrUpdateLanguageModels(...modelsToAdd.map(modelId => this.createOpenAIModelDescription(modelId, requestSettings)));
|
|
66
|
+
this.prevModels = newModels;
|
|
67
|
+
}
|
|
68
|
+
getRequestSettingsPref() {
|
|
69
|
+
return this.preferenceService.get(ai_core_preferences_1.PREFERENCE_NAME_REQUEST_SETTINGS, []);
|
|
70
|
+
}
|
|
71
|
+
handleCustomModelChanges(newCustomModels) {
|
|
72
|
+
const requestSettings = this.getRequestSettingsPref();
|
|
73
|
+
const oldModels = this.createCustomModelDescriptionsFromPreferences(this.prevCustomModels, requestSettings);
|
|
74
|
+
const newModels = this.createCustomModelDescriptionsFromPreferences(newCustomModels, requestSettings);
|
|
75
|
+
const modelsToRemove = oldModels.filter(model => !newModels.some(newModel => newModel.id === model.id));
|
|
76
|
+
const modelsToAddOrUpdate = newModels.filter(newModel => !oldModels.some(model => model.id === newModel.id &&
|
|
77
|
+
model.model === newModel.model &&
|
|
78
|
+
model.url === newModel.url &&
|
|
79
|
+
model.apiKey === newModel.apiKey &&
|
|
80
|
+
model.enableStreaming === newModel.enableStreaming));
|
|
81
|
+
this.manager.removeLanguageModels(...modelsToRemove.map(model => model.id));
|
|
82
|
+
this.manager.createOrUpdateLanguageModels(...modelsToAddOrUpdate);
|
|
83
|
+
this.prevCustomModels = [...newCustomModels];
|
|
84
|
+
}
|
|
85
|
+
handleRequestSettingsChanges(newSettings) {
|
|
86
|
+
const models = this.preferenceService.get(openai_preferences_1.MODELS_PREF, []);
|
|
87
|
+
this.manager.createOrUpdateLanguageModels(...models.map(modelId => this.createOpenAIModelDescription(modelId, newSettings)));
|
|
88
|
+
const customModels = this.preferenceService.get(openai_preferences_1.CUSTOM_ENDPOINTS_PREF, []);
|
|
89
|
+
this.manager.createOrUpdateLanguageModels(...this.createCustomModelDescriptionsFromPreferences(customModels, newSettings));
|
|
90
|
+
}
|
|
91
|
+
createOpenAIModelDescription(modelId, requestSettings) {
|
|
92
|
+
const id = `${OPENAI_PROVIDER_ID}/${modelId}`;
|
|
93
|
+
const modelRequestSetting = this.getMatchingRequestSetting(modelId, OPENAI_PROVIDER_ID, requestSettings);
|
|
94
|
+
return {
|
|
95
|
+
id: id,
|
|
96
|
+
model: modelId,
|
|
97
|
+
apiKey: true,
|
|
98
|
+
enableStreaming: !openAIModelsWithDisabledStreaming.includes(modelId),
|
|
99
|
+
defaultRequestSettings: modelRequestSetting === null || modelRequestSetting === void 0 ? void 0 : modelRequestSetting.requestSettings
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
createCustomModelDescriptionsFromPreferences(preferences, requestSettings) {
|
|
103
|
+
return preferences.reduce((acc, pref) => {
|
|
104
|
+
var _a;
|
|
105
|
+
if (!pref.model || !pref.url || typeof pref.model !== 'string' || typeof pref.url !== 'string') {
|
|
106
|
+
return acc;
|
|
107
|
+
}
|
|
108
|
+
const modelRequestSetting = this.getMatchingRequestSetting(pref.model, OPENAI_PROVIDER_ID, requestSettings);
|
|
109
|
+
return [
|
|
110
|
+
...acc,
|
|
111
|
+
{
|
|
112
|
+
id: pref.id && typeof pref.id === 'string' ? pref.id : pref.model,
|
|
113
|
+
model: pref.model,
|
|
114
|
+
url: pref.url,
|
|
115
|
+
apiKey: typeof pref.apiKey === 'string' || pref.apiKey === true ? pref.apiKey : undefined,
|
|
116
|
+
enableStreaming: (_a = pref.enableStreaming) !== null && _a !== void 0 ? _a : true,
|
|
117
|
+
defaultRequestSettings: modelRequestSetting === null || modelRequestSetting === void 0 ? void 0 : modelRequestSetting.requestSettings
|
|
118
|
+
}
|
|
119
|
+
];
|
|
120
|
+
}, []);
|
|
121
|
+
}
|
|
122
|
+
getMatchingRequestSetting(modelId, providerId, requestSettings) {
|
|
123
|
+
const matchingSettings = requestSettings.filter(setting => (!setting.providerId || setting.providerId === providerId) && setting.modelId === modelId);
|
|
124
|
+
if (matchingSettings.length > 1) {
|
|
125
|
+
console.warn(`Multiple entries found for provider "${providerId}" and model "${modelId}". Using the first match.`);
|
|
126
|
+
}
|
|
127
|
+
return matchingSettings[0];
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
exports.OpenAiFrontendApplicationContribution = OpenAiFrontendApplicationContribution;
|
|
131
|
+
tslib_1.__decorate([
|
|
132
|
+
(0, inversify_1.inject)(browser_1.PreferenceService),
|
|
133
|
+
tslib_1.__metadata("design:type", Object)
|
|
134
|
+
], OpenAiFrontendApplicationContribution.prototype, "preferenceService", void 0);
|
|
135
|
+
tslib_1.__decorate([
|
|
136
|
+
(0, inversify_1.inject)(common_1.OpenAiLanguageModelsManager),
|
|
137
|
+
tslib_1.__metadata("design:type", Object)
|
|
138
|
+
], OpenAiFrontendApplicationContribution.prototype, "manager", void 0);
|
|
139
|
+
exports.OpenAiFrontendApplicationContribution = OpenAiFrontendApplicationContribution = tslib_1.__decorate([
|
|
140
|
+
(0, inversify_1.injectable)()
|
|
141
|
+
], OpenAiFrontendApplicationContribution);
|
|
142
|
+
const openAIModelsWithDisabledStreaming = ['o1-preview'];
|
|
143
|
+
//# sourceMappingURL=openai-frontend-application-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/openai-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,6DAAwF;AACxF,wFAAkH;AAElH,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAG7B,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAA3C;QAQO,eAAU,GAAa,EAAE,CAAC;QAC1B,qBAAgB,GAAsC,EAAE,CAAC;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A;AAtIY,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,CAsIjD;AAED,MAAM,iCAAiC,GAAG,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/openai-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) 2024 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 openai_preferences_1 = require("./openai-preferences");
|
|
20
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
21
|
+
const openai_frontend_application_contribution_1 = require("./openai-frontend-application-contribution");
|
|
22
|
+
const common_1 = require("../common");
|
|
23
|
+
exports.default = new inversify_1.ContainerModule(bind => {
|
|
24
|
+
bind(browser_1.PreferenceContribution).toConstantValue({ schema: openai_preferences_1.OpenAiPreferencesSchema });
|
|
25
|
+
bind(openai_frontend_application_contribution_1.OpenAiFrontendApplicationContribution).toSelf().inSingletonScope();
|
|
26
|
+
bind(browser_1.FrontendApplicationContribution).toService(openai_frontend_application_contribution_1.OpenAiFrontendApplicationContribution);
|
|
27
|
+
bind(common_1.OpenAiLanguageModelsManager).toDynamicValue(ctx => {
|
|
28
|
+
const provider = ctx.container.get(browser_1.RemoteConnectionProvider);
|
|
29
|
+
return provider.createProxy(common_1.OPENAI_LANGUAGE_MODELS_MANAGER_PATH);
|
|
30
|
+
}).inSingletonScope();
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=openai-frontend-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-frontend-module.js","sourceRoot":"","sources":["../../src/browser/openai-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,6 @@
|
|
|
1
|
+
import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
|
|
2
|
+
export declare const API_KEY_PREF = "ai-features.openAiOfficial.openAiApiKey";
|
|
3
|
+
export declare const MODELS_PREF = "ai-features.openAiOfficial.officialOpenAiModels";
|
|
4
|
+
export declare const CUSTOM_ENDPOINTS_PREF = "ai-features.openAiCustom.customOpenAiModels";
|
|
5
|
+
export declare const OpenAiPreferencesSchema: PreferenceSchema;
|
|
6
|
+
//# sourceMappingURL=openai-preferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-preferences.d.ts","sourceRoot":"","sources":["../../src/browser/openai-preferences.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6DAA6D,CAAC;AAG/F,eAAO,MAAM,YAAY,4CAA4C,CAAC;AACtE,eAAO,MAAM,WAAW,oDAAoD,CAAC;AAC7E,eAAO,MAAM,qBAAqB,gDAAgD,CAAC;AAEnF,eAAO,MAAM,uBAAuB,EAAE,gBA4DrC,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 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.OpenAiPreferencesSchema = exports.CUSTOM_ENDPOINTS_PREF = 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
|
+
exports.API_KEY_PREF = 'ai-features.openAiOfficial.openAiApiKey';
|
|
21
|
+
exports.MODELS_PREF = 'ai-features.openAiOfficial.officialOpenAiModels';
|
|
22
|
+
exports.CUSTOM_ENDPOINTS_PREF = 'ai-features.openAiCustom.customOpenAiModels';
|
|
23
|
+
exports.OpenAiPreferencesSchema = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
[exports.API_KEY_PREF]: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
markdownDescription: 'Enter an API Key of your official OpenAI Account. **Please note:** By using this preference the Open AI API key will be stored in clear text\
|
|
29
|
+
on the machine running Theia. Use the environment variable `OPENAI_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: 'Official OpenAI models to use',
|
|
35
|
+
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
36
|
+
default: ['gpt-4o', 'gpt-4o-2024-08-06', 'gpt-4o-2024-05-13', 'gpt-4o-mini', 'gpt-4-turbo', 'gpt-4', 'gpt-3.5-turbo', 'o1-preview'],
|
|
37
|
+
items: {
|
|
38
|
+
type: 'string'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
[exports.CUSTOM_ENDPOINTS_PREF]: {
|
|
42
|
+
type: 'array',
|
|
43
|
+
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
44
|
+
markdownDescription: 'Integrate custom models compatible with the OpenAI API, for example via `vllm`. The required attributes are `model` and `url`.\
|
|
45
|
+
\n\
|
|
46
|
+
Optionally, you can\
|
|
47
|
+
\n\
|
|
48
|
+
- specify a unique `id` to identify the custom model in the UI. If none is given `model` will be used as `id`.\
|
|
49
|
+
\n\
|
|
50
|
+
- provide an `apiKey` to access the API served at the given url. Use `true` to indicate the use of the global OpenAI API key.\
|
|
51
|
+
\n\
|
|
52
|
+
- specify `enableStreaming: false` to indicate that streaming shall not be used.\
|
|
53
|
+
\n\
|
|
54
|
+
Refer to [our documentation](https://theia-ide.org/docs/user_ai/#openai-compatible-models-eg-via-vllm) for more information.',
|
|
55
|
+
default: [],
|
|
56
|
+
items: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
model: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
title: 'Model ID'
|
|
62
|
+
},
|
|
63
|
+
url: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
title: 'The Open AI API compatible endpoint where the model is hosted'
|
|
66
|
+
},
|
|
67
|
+
id: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
title: 'A unique identifier which is used in the UI to identify the custom model',
|
|
70
|
+
},
|
|
71
|
+
apiKey: {
|
|
72
|
+
type: ['string', 'boolean'],
|
|
73
|
+
title: 'Either the key to access the API served at the given url or `true` to use the global OpenAI API key',
|
|
74
|
+
},
|
|
75
|
+
enableStreaming: {
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
title: 'Indicates whether the streaming API shall be used. `true` by default.',
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=openai-preferences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-preferences.js","sourceRoot":"","sources":["../../src/browser/openai-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;AAE9E,QAAA,YAAY,GAAG,yCAAyC,CAAC;AACzD,QAAA,WAAW,GAAG,iDAAiD,CAAC;AAChE,QAAA,qBAAqB,GAAG,6CAA6C,CAAC;AAEtE,QAAA,uBAAuB,GAAqB;IACrD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,CAAC,oBAAY,CAAC,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,mBAAmB,EAAE;iHACgF;YACrG,KAAK,EAAE,+CAAyB;SACnC;QACD,CAAC,mBAAW,CAAC,EAAE;YACX,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,+BAA+B;YAC5C,KAAK,EAAE,+CAAyB;YAChC,OAAO,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,CAAC;YACnI,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;aACjB;SACJ;QACD,CAAC,6BAAqB,CAAC,EAAE;YACrB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,+CAAyB;YAChC,mBAAmB,EAAE;;;;;;;;;;yIAUwG;YAC7H,OAAO,EAAE,EAAE;YACX,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,KAAK,EAAE;wBACH,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,UAAU;qBACpB;oBACD,GAAG,EAAE;wBACD,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,+DAA+D;qBACzE;oBACD,EAAE,EAAE;wBACA,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,0EAA0E;qBACpF;oBACD,MAAM,EAAE;wBACJ,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;wBAC3B,KAAK,EAAE,qGAAqG;qBAC/G;oBACD,eAAe,EAAE;wBACb,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,uEAAuE;qBACjF;iBACJ;aACJ;SACJ;KACJ;CACJ,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) 2024 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("./openai-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,37 @@
|
|
|
1
|
+
export declare const OPENAI_LANGUAGE_MODELS_MANAGER_PATH = "/services/open-ai/language-model-manager";
|
|
2
|
+
export declare const OpenAiLanguageModelsManager: unique symbol;
|
|
3
|
+
export interface OpenAiModelDescription {
|
|
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 OpenAI API.
|
|
10
|
+
*/
|
|
11
|
+
model: string;
|
|
12
|
+
/**
|
|
13
|
+
* The OpenAI API compatible endpoint where the model is hosted. If not provided the default OpenAI endpoint will be used.
|
|
14
|
+
*/
|
|
15
|
+
url?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The key for the model. If 'true' is provided the global OpenAI API key will be used.
|
|
18
|
+
*/
|
|
19
|
+
apiKey: string | true | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Indicate whether the streaming API shall be used.
|
|
22
|
+
*/
|
|
23
|
+
enableStreaming: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Default request settings for the OpenAI model.
|
|
26
|
+
*/
|
|
27
|
+
defaultRequestSettings?: {
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface OpenAiLanguageModelsManager {
|
|
32
|
+
apiKey: string | undefined;
|
|
33
|
+
setApiKey(key: string | undefined): void;
|
|
34
|
+
createOrUpdateLanguageModels(...models: OpenAiModelDescription[]): Promise<void>;
|
|
35
|
+
removeLanguageModels(...modelIds: string[]): void;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=openai-language-models-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-language-models-manager.d.ts","sourceRoot":"","sources":["../../src/common/openai-language-models-manager.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,mCAAmC,6CAA6C,CAAC;AAC9F,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,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,sBAAsB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACvD;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.OpenAiLanguageModelsManager = exports.OPENAI_LANGUAGE_MODELS_MANAGER_PATH = void 0;
|
|
4
|
+
// *****************************************************************************
|
|
5
|
+
// Copyright (C) 2024 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.OPENAI_LANGUAGE_MODELS_MANAGER_PATH = '/services/open-ai/language-model-manager';
|
|
20
|
+
exports.OpenAiLanguageModelsManager = Symbol('OpenAiLanguageModelsManager');
|
|
21
|
+
//# sourceMappingURL=openai-language-models-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-language-models-manager.js","sourceRoot":"","sources":["../../src/common/openai-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,0CAA0C,CAAC;AACjF,QAAA,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/openai-backend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAK/D,eAAO,MAAM,kBAAkB,eAA+B,CAAC;;AAE/D,wBAMG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 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.OpenAiModelFactory = void 0;
|
|
19
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
20
|
+
const openai_language_models_manager_1 = require("../common/openai-language-models-manager");
|
|
21
|
+
const core_1 = require("@theia/core");
|
|
22
|
+
const openai_language_models_manager_impl_1 = require("./openai-language-models-manager-impl");
|
|
23
|
+
exports.OpenAiModelFactory = Symbol('OpenAiModelFactory');
|
|
24
|
+
exports.default = new inversify_1.ContainerModule(bind => {
|
|
25
|
+
bind(openai_language_models_manager_impl_1.OpenAiLanguageModelsManagerImpl).toSelf().inSingletonScope();
|
|
26
|
+
bind(openai_language_models_manager_1.OpenAiLanguageModelsManager).toService(openai_language_models_manager_impl_1.OpenAiLanguageModelsManagerImpl);
|
|
27
|
+
bind(core_1.ConnectionHandler).toDynamicValue(ctx => new core_1.RpcConnectionHandler(openai_language_models_manager_1.OPENAI_LANGUAGE_MODELS_MANAGER_PATH, () => ctx.container.get(openai_language_models_manager_1.OpenAiLanguageModelsManager))).inSingletonScope();
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=openai-backend-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-backend-module.js","sourceRoot":"","sources":["../../src/node/openai-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;AAE3E,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAE/D,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LanguageModel, LanguageModelParsedResponse, LanguageModelRequest, LanguageModelResponse, LanguageModelTextResponse } from '@theia/ai-core';
|
|
2
|
+
import { CancellationToken } from '@theia/core';
|
|
3
|
+
import OpenAI from 'openai';
|
|
4
|
+
import { RunnableToolFunctionWithoutParse } from 'openai/lib/RunnableFunction';
|
|
5
|
+
export declare const OpenAiModelIdentifier: unique symbol;
|
|
6
|
+
export declare class OpenAiModel implements LanguageModel {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
model: string;
|
|
9
|
+
enableStreaming: boolean;
|
|
10
|
+
apiKey: () => string | undefined;
|
|
11
|
+
url: string | undefined;
|
|
12
|
+
defaultRequestSettings?: {
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
} | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* @param id the unique id for this language model. It will be used to identify the model in the UI.
|
|
17
|
+
* @param model the model id as it is used by the OpenAI API
|
|
18
|
+
* @param enableStreaming whether the streaming API shall be used
|
|
19
|
+
* @param apiKey a function that returns the API key to use for this model, called on each request
|
|
20
|
+
* @param url the OpenAI API compatible endpoint where the model is hosted. If not provided the default OpenAI endpoint will be used.
|
|
21
|
+
* @param defaultRequestSettings optional default settings for requests made using this model.
|
|
22
|
+
*/
|
|
23
|
+
constructor(id: string, model: string, enableStreaming: boolean, apiKey: () => string | undefined, url: string | undefined, defaultRequestSettings?: {
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
} | undefined);
|
|
26
|
+
protected getSettings(request: LanguageModelRequest): Record<string, unknown>;
|
|
27
|
+
request(request: LanguageModelRequest, cancellationToken?: CancellationToken): Promise<LanguageModelResponse>;
|
|
28
|
+
protected handleNonStreamingRequest(openai: OpenAI, request: LanguageModelRequest): Promise<LanguageModelTextResponse>;
|
|
29
|
+
protected isNonStreamingModel(_model: string): boolean;
|
|
30
|
+
protected supportsStructuredOutput(): boolean;
|
|
31
|
+
protected handleStructuredOutputRequest(openai: OpenAI, request: LanguageModelRequest): Promise<LanguageModelParsedResponse>;
|
|
32
|
+
private getCompletionContent;
|
|
33
|
+
protected createTools(request: LanguageModelRequest): RunnableToolFunctionWithoutParse[] | undefined;
|
|
34
|
+
protected initializeOpenAi(): OpenAI;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=openai-language-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-language-model.d.ts","sourceRoot":"","sources":["../../src/node/openai-language-model.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,aAAa,EACb,2BAA2B,EAC3B,oBAAoB,EAEpB,qBAAqB,EAErB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAG/E,eAAO,MAAM,qBAAqB,eAAkC,CAAC;AAoBrE,qBAAa,WAAY,YAAW,aAAa;aAWzB,EAAE,EAAE,MAAM;IACnB,KAAK,EAAE,MAAM;IACb,eAAe,EAAE,OAAO;IACxB,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS;IAChC,GAAG,EAAE,MAAM,GAAG,SAAS;IACvB,sBAAsB,CAAC;;;IAdlC;;;;;;;OAOG;gBAEiB,EAAE,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,OAAO,EACxB,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS,EAChC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,sBAAsB,CAAC;;iBAA4B;IAG9D,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQvE,OAAO,CAAC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAiFnG,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAe5H,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAItD,SAAS,CAAC,wBAAwB,IAAI,OAAO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