@theia/ai-ollama 1.67.0-next.13 → 1.67.0-next.56
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 +1 -0
- package/package.json +6 -6
- package/lib/browser/ollama-frontend-application-contribution.d.ts +0 -12
- package/lib/browser/ollama-frontend-application-contribution.d.ts.map +0 -1
- package/lib/browser/ollama-frontend-application-contribution.js +0 -75
- package/lib/browser/ollama-frontend-application-contribution.js.map +0 -1
- package/lib/browser/ollama-frontend-module.d.ts +0 -4
- package/lib/browser/ollama-frontend-module.d.ts.map +0 -1
- package/lib/browser/ollama-frontend-module.js +0 -33
- package/lib/browser/ollama-frontend-module.js.map +0 -1
- package/lib/common/index.d.ts +0 -2
- package/lib/common/index.d.ts.map +0 -1
- package/lib/common/index.js +0 -20
- package/lib/common/index.js.map +0 -1
- package/lib/common/ollama-language-models-manager.d.ts +0 -19
- package/lib/common/ollama-language-models-manager.d.ts.map +0 -1
- package/lib/common/ollama-language-models-manager.js +0 -21
- package/lib/common/ollama-language-models-manager.js.map +0 -1
- package/lib/common/ollama-preferences.d.ts +0 -5
- package/lib/common/ollama-preferences.d.ts.map +0 -1
- package/lib/common/ollama-preferences.js +0 -39
- package/lib/common/ollama-preferences.js.map +0 -1
- package/lib/node/ollama-backend-module.d.ts +0 -5
- package/lib/node/ollama-backend-module.d.ts.map +0 -1
- package/lib/node/ollama-backend-module.js +0 -36
- package/lib/node/ollama-backend-module.js.map +0 -1
- package/lib/node/ollama-language-model.d.ts +0 -69
- package/lib/node/ollama-language-model.d.ts.map +0 -1
- package/lib/node/ollama-language-model.js +0 -369
- package/lib/node/ollama-language-model.js.map +0 -1
- package/lib/node/ollama-language-models-manager-impl.d.ts +0 -13
- package/lib/node/ollama-language-models-manager-impl.d.ts.map +0 -1
- package/lib/node/ollama-language-models-manager-impl.js +0 -70
- package/lib/node/ollama-language-models-manager-impl.js.map +0 -1
- package/lib/package.spec.d.ts +0 -2
- package/lib/package.spec.d.ts.map +0 -1
- package/lib/package.spec.js +0 -64
- package/lib/package.spec.js.map +0 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ The `@theia/ai-ollama` integrates Ollama's models with Theia AI.
|
|
|
21
21
|
|
|
22
22
|
## License
|
|
23
23
|
|
|
24
|
+
- [API documentation for `@theia/ai-ollama`](https://eclipse-theia.github.io/theia/docs/next/modules/_theia_ai-ollama.html)
|
|
24
25
|
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
25
26
|
- [(Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
26
27
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-ollama",
|
|
3
|
-
"version": "1.67.0-next.
|
|
3
|
+
"version": "1.67.0-next.56+d8f18cc386c",
|
|
4
4
|
"description": "Theia - Ollama Integration",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/ai-core": "1.67.0-next.
|
|
7
|
-
"@theia/core": "1.67.0-next.
|
|
8
|
-
"@theia/filesystem": "1.67.0-next.
|
|
9
|
-
"@theia/workspace": "1.67.0-next.
|
|
6
|
+
"@theia/ai-core": "1.67.0-next.56+d8f18cc386c",
|
|
7
|
+
"@theia/core": "1.67.0-next.56+d8f18cc386c",
|
|
8
|
+
"@theia/filesystem": "1.67.0-next.56+d8f18cc386c",
|
|
9
|
+
"@theia/workspace": "1.67.0-next.56+d8f18cc386c",
|
|
10
10
|
"ollama": "^0.5.16",
|
|
11
11
|
"tslib": "^2.6.2"
|
|
12
12
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"nyc": {
|
|
50
50
|
"extends": "../../configs/nyc.json"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "d8f18cc386c45a736cd193d42eab02c8f64c6b10"
|
|
53
53
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
2
|
-
import { OllamaLanguageModelsManager, OllamaModelDescription } from '../common';
|
|
3
|
-
import { PreferenceService } from '@theia/core';
|
|
4
|
-
export declare class OllamaFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
5
|
-
protected preferenceService: PreferenceService;
|
|
6
|
-
protected manager: OllamaLanguageModelsManager;
|
|
7
|
-
protected prevModels: string[];
|
|
8
|
-
onStart(): void;
|
|
9
|
-
protected handleModelChanges(newModels: string[]): void;
|
|
10
|
-
protected createOllamaModelDescription(modelId: string): OllamaModelDescription;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=ollama-frontend-application-contribution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/ollama-frontend-application-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,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;CAQlF"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2024 TypeFox 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.OllamaFrontendApplicationContribution = void 0;
|
|
19
|
-
const tslib_1 = require("tslib");
|
|
20
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
-
const common_1 = require("../common");
|
|
22
|
-
const ollama_preferences_1 = require("../common/ollama-preferences");
|
|
23
|
-
const core_1 = require("@theia/core");
|
|
24
|
-
const OLLAMA_PROVIDER_ID = 'ollama';
|
|
25
|
-
let OllamaFrontendApplicationContribution = class OllamaFrontendApplicationContribution {
|
|
26
|
-
constructor() {
|
|
27
|
-
this.prevModels = [];
|
|
28
|
-
}
|
|
29
|
-
onStart() {
|
|
30
|
-
this.preferenceService.ready.then(() => {
|
|
31
|
-
const host = this.preferenceService.get(ollama_preferences_1.HOST_PREF, 'http://localhost:11434');
|
|
32
|
-
this.manager.setHost(host);
|
|
33
|
-
const models = this.preferenceService.get(ollama_preferences_1.MODELS_PREF, []);
|
|
34
|
-
this.manager.createOrUpdateLanguageModels(...models.map(modelId => this.createOllamaModelDescription(modelId)));
|
|
35
|
-
this.prevModels = [...models];
|
|
36
|
-
this.preferenceService.onPreferenceChanged(event => {
|
|
37
|
-
if (event.preferenceName === ollama_preferences_1.HOST_PREF) {
|
|
38
|
-
this.manager.setHost(event.newValue);
|
|
39
|
-
}
|
|
40
|
-
else if (event.preferenceName === ollama_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);
|
|
52
|
-
this.manager.createOrUpdateLanguageModels(...modelsToAdd.map(modelId => this.createOllamaModelDescription(modelId)));
|
|
53
|
-
this.prevModels = newModels;
|
|
54
|
-
}
|
|
55
|
-
createOllamaModelDescription(modelId) {
|
|
56
|
-
const id = `${OLLAMA_PROVIDER_ID}/${modelId}`;
|
|
57
|
-
return {
|
|
58
|
-
id: id,
|
|
59
|
-
model: modelId
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
exports.OllamaFrontendApplicationContribution = OllamaFrontendApplicationContribution;
|
|
64
|
-
tslib_1.__decorate([
|
|
65
|
-
(0, inversify_1.inject)(core_1.PreferenceService),
|
|
66
|
-
tslib_1.__metadata("design:type", Object)
|
|
67
|
-
], OllamaFrontendApplicationContribution.prototype, "preferenceService", void 0);
|
|
68
|
-
tslib_1.__decorate([
|
|
69
|
-
(0, inversify_1.inject)(common_1.OllamaLanguageModelsManager),
|
|
70
|
-
tslib_1.__metadata("design:type", Object)
|
|
71
|
-
], OllamaFrontendApplicationContribution.prototype, "manager", void 0);
|
|
72
|
-
exports.OllamaFrontendApplicationContribution = OllamaFrontendApplicationContribution = tslib_1.__decorate([
|
|
73
|
-
(0, inversify_1.injectable)()
|
|
74
|
-
], OllamaFrontendApplicationContribution);
|
|
75
|
-
//# sourceMappingURL=ollama-frontend-application-contribution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/ollama-frontend-application-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,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,4DAAkE;AAClE,sCAAgF;AAChF,qEAAsE;AACtE,sCAAgD;AAEhD,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAE7B,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAA3C;QAQO,eAAU,GAAa,EAAE,CAAC;IAyCxC,CAAC;IAvCG,OAAO;QACH,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YACnC,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAS,8BAAS,EAAE,wBAAwB,CAAC,CAAC;YACrF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAE3B,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,8BAAS,EAAE,C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BAAM,EAAC,wBAAiB,CAAC;;gFACqB;AAGrC;IADT,IAAA,kBAAM,EAAC,oCAA2B,CAAC;;sEACW;gDANtC,qCAAqC;IADjD,IAAA,sBAAU,GAAE;GACA,qCAAqC,CAiDjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ollama-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAO/D,wBAQG"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2024 TypeFox 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 ollama_preferences_1 = require("../common/ollama-preferences");
|
|
20
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
21
|
-
const ollama_frontend_application_contribution_1 = require("./ollama-frontend-application-contribution");
|
|
22
|
-
const common_1 = require("../common");
|
|
23
|
-
const core_1 = require("@theia/core");
|
|
24
|
-
exports.default = new inversify_1.ContainerModule(bind => {
|
|
25
|
-
bind(core_1.PreferenceContribution).toConstantValue({ schema: ollama_preferences_1.OllamaPreferencesSchema });
|
|
26
|
-
bind(ollama_frontend_application_contribution_1.OllamaFrontendApplicationContribution).toSelf().inSingletonScope();
|
|
27
|
-
bind(browser_1.FrontendApplicationContribution).toService(ollama_frontend_application_contribution_1.OllamaFrontendApplicationContribution);
|
|
28
|
-
bind(common_1.OllamaLanguageModelsManager).toDynamicValue(ctx => {
|
|
29
|
-
const provider = ctx.container.get(browser_1.RemoteConnectionProvider);
|
|
30
|
-
return provider.createProxy(common_1.OLLAMA_LANGUAGE_MODELS_MANAGER_PATH);
|
|
31
|
-
}).inSingletonScope();
|
|
32
|
-
});
|
|
33
|
-
//# sourceMappingURL=ollama-frontend-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-frontend-module.js","sourceRoot":"","sources":["../../src/browser/ollama-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,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,qEAAuE;AACvE,qDAA+H;AAC/H,yGAAmG;AACnG,sCAA6F;AAC7F,sCAAqD;AAErD,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,6BAAsB,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"}
|
package/lib/common/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAeA,cAAc,kCAAkC,CAAC"}
|
package/lib/common/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
// *****************************************************************************
|
|
5
|
-
// Copyright (C) 2024 TypeFox 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("./ollama-language-models-manager"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
package/lib/common/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;AAAA,gFAAgF;AAChF,mCAAmC;AACnC,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"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const OLLAMA_LANGUAGE_MODELS_MANAGER_PATH = "/services/ollama/language-model-manager";
|
|
2
|
-
export declare const OllamaLanguageModelsManager: unique symbol;
|
|
3
|
-
export interface OllamaModelDescription {
|
|
4
|
-
/**
|
|
5
|
-
* The identifier of the model which will be shown in the UI.
|
|
6
|
-
*/
|
|
7
|
-
id: string;
|
|
8
|
-
/**
|
|
9
|
-
* The name or ID of the model in the Ollama environment.
|
|
10
|
-
*/
|
|
11
|
-
model: string;
|
|
12
|
-
}
|
|
13
|
-
export interface OllamaLanguageModelsManager {
|
|
14
|
-
host: string | undefined;
|
|
15
|
-
setHost(host: string | undefined): void;
|
|
16
|
-
createOrUpdateLanguageModels(...models: OllamaModelDescription[]): Promise<void>;
|
|
17
|
-
removeLanguageModels(...modelIds: string[]): void;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=ollama-language-models-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-language-models-manager.d.ts","sourceRoot":"","sources":["../../src/common/ollama-language-models-manager.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mCAAmC,4CAA4C,CAAC;AAC7F,eAAO,MAAM,2BAA2B,eAAwC,CAAC;AAEjF,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,2BAA2B;IACxC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACxC,4BAA4B,CAAC,GAAG,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjF,oBAAoB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CACrD"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2024 TypeFox 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.OllamaLanguageModelsManager = exports.OLLAMA_LANGUAGE_MODELS_MANAGER_PATH = void 0;
|
|
19
|
-
exports.OLLAMA_LANGUAGE_MODELS_MANAGER_PATH = '/services/ollama/language-model-manager';
|
|
20
|
-
exports.OllamaLanguageModelsManager = Symbol('OllamaLanguageModelsManager');
|
|
21
|
-
//# sourceMappingURL=ollama-language-models-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-language-models-manager.js","sourceRoot":"","sources":["../../src/common/ollama-language-models-manager.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,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;;;AAEnE,QAAA,mCAAmC,GAAG,yCAAyC,CAAC;AAChF,QAAA,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { PreferenceSchema } from '@theia/core/lib/common';
|
|
2
|
-
export declare const HOST_PREF = "ai-features.ollama.ollamaHost";
|
|
3
|
-
export declare const MODELS_PREF = "ai-features.ollama.ollamaModels";
|
|
4
|
-
export declare const OllamaPreferencesSchema: PreferenceSchema;
|
|
5
|
-
//# sourceMappingURL=ollama-preferences.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-preferences.d.ts","sourceRoot":"","sources":["../../src/common/ollama-preferences.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,eAAO,MAAM,SAAS,kCAAkC,CAAC;AACzD,eAAO,MAAM,WAAW,oCAAoC,CAAC;AAE7D,eAAO,MAAM,uBAAuB,EAAE,gBAgBrC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2024 TypeFox 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.OllamaPreferencesSchema = exports.MODELS_PREF = exports.HOST_PREF = void 0;
|
|
19
|
-
const ai_core_preferences_1 = require("@theia/ai-core/lib/common/ai-core-preferences");
|
|
20
|
-
exports.HOST_PREF = 'ai-features.ollama.ollamaHost';
|
|
21
|
-
exports.MODELS_PREF = 'ai-features.ollama.ollamaModels';
|
|
22
|
-
exports.OllamaPreferencesSchema = {
|
|
23
|
-
properties: {
|
|
24
|
-
[exports.HOST_PREF]: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
27
|
-
default: 'http://localhost:11434'
|
|
28
|
-
},
|
|
29
|
-
[exports.MODELS_PREF]: {
|
|
30
|
-
type: 'array',
|
|
31
|
-
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
32
|
-
default: ['llama3', 'gemma2'],
|
|
33
|
-
items: {
|
|
34
|
-
type: 'string'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=ollama-preferences.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-preferences.js","sourceRoot":"","sources":["../../src/common/ollama-preferences.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,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,uFAA0F;AAG7E,QAAA,SAAS,GAAG,+BAA+B,CAAC;AAC5C,QAAA,WAAW,GAAG,iCAAiC,CAAC;AAEhD,QAAA,uBAAuB,GAAqB;IACrD,UAAU,EAAE;QACR,CAAC,iBAAS,CAAC,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,+CAAyB;YAChC,OAAO,EAAE,wBAAwB;SACpC;QACD,CAAC,mBAAW,CAAC,EAAE;YACX,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,+CAAyB;YAChC,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;YAC7B,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;aACjB;SACJ;KACJ;CACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/ollama-backend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAO/D,eAAO,MAAM,kBAAkB,eAA+B,CAAC;;AAW/D,wBAGG"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2024 TypeFox 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.OllamaModelFactory = void 0;
|
|
19
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
20
|
-
const ollama_language_models_manager_1 = require("../common/ollama-language-models-manager");
|
|
21
|
-
const core_1 = require("@theia/core");
|
|
22
|
-
const ollama_language_models_manager_impl_1 = require("./ollama-language-models-manager-impl");
|
|
23
|
-
const connection_container_module_1 = require("@theia/core/lib/node/messaging/connection-container-module");
|
|
24
|
-
const ollama_preferences_1 = require("../common/ollama-preferences");
|
|
25
|
-
exports.OllamaModelFactory = Symbol('OllamaModelFactory');
|
|
26
|
-
// We use a connection module to handle AI services separately for each frontend.
|
|
27
|
-
const ollamaConnectionModule = connection_container_module_1.ConnectionContainerModule.create(({ bind, bindBackendService, bindFrontendService }) => {
|
|
28
|
-
bind(ollama_language_models_manager_impl_1.OllamaLanguageModelsManagerImpl).toSelf().inSingletonScope();
|
|
29
|
-
bind(ollama_language_models_manager_1.OllamaLanguageModelsManager).toService(ollama_language_models_manager_impl_1.OllamaLanguageModelsManagerImpl);
|
|
30
|
-
bind(core_1.ConnectionHandler).toDynamicValue(ctx => new core_1.RpcConnectionHandler(ollama_language_models_manager_1.OLLAMA_LANGUAGE_MODELS_MANAGER_PATH, () => ctx.container.get(ollama_language_models_manager_1.OllamaLanguageModelsManager))).inSingletonScope();
|
|
31
|
-
});
|
|
32
|
-
exports.default = new inversify_1.ContainerModule(bind => {
|
|
33
|
-
bind(core_1.PreferenceContribution).toConstantValue({ schema: ollama_preferences_1.OllamaPreferencesSchema });
|
|
34
|
-
bind(connection_container_module_1.ConnectionContainerModule).toConstantValue(ollamaConnectionModule);
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=ollama-backend-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-backend-module.js","sourceRoot":"","sources":["../../src/node/ollama-backend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,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,sCAA8F;AAC9F,+FAAwF;AACxF,4GAAuG;AACvG,qEAAuE;AAE1D,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAE/D,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,6BAAsB,CAAC,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,4CAAuB,EAAE,CAAC,CAAC;IAClF,IAAI,CAAC,uDAAyB,CAAC,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;AAC5E,CAAC,CAAC,CAAC"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { LanguageModel, LanguageModelParsedResponse, LanguageModelRequest, LanguageModelMessage, LanguageModelResponse, LanguageModelStreamResponse, ToolRequest, TokenUsageService, LanguageModelStatus } from '@theia/ai-core';
|
|
2
|
-
import { CancellationToken } from '@theia/core';
|
|
3
|
-
import { ChatRequest, Message, Ollama, Tool } from 'ollama';
|
|
4
|
-
export declare const OllamaModelIdentifier: unique symbol;
|
|
5
|
-
export declare class OllamaModel implements LanguageModel {
|
|
6
|
-
readonly id: string;
|
|
7
|
-
protected readonly model: string;
|
|
8
|
-
status: LanguageModelStatus;
|
|
9
|
-
protected host: () => string | undefined;
|
|
10
|
-
protected readonly tokenUsageService?: TokenUsageService | undefined;
|
|
11
|
-
protected readonly DEFAULT_REQUEST_SETTINGS: Partial<Omit<ChatRequest, 'stream' | 'model'>>;
|
|
12
|
-
readonly providerId = "ollama";
|
|
13
|
-
readonly vendor: string;
|
|
14
|
-
/**
|
|
15
|
-
* @param id the unique id for this language model. It will be used to identify the model in the UI.
|
|
16
|
-
* @param model the unique model name as used in the Ollama environment.
|
|
17
|
-
* @param hostProvider a function to provide the host URL for the Ollama server.
|
|
18
|
-
*/
|
|
19
|
-
constructor(id: string, model: string, status: LanguageModelStatus, host: () => string | undefined, tokenUsageService?: TokenUsageService | undefined);
|
|
20
|
-
request(request: LanguageModelRequest, cancellationToken?: CancellationToken): Promise<LanguageModelResponse>;
|
|
21
|
-
/**
|
|
22
|
-
* Retrieves the settings for the chat request, merging the request-specific settings with the default settings.
|
|
23
|
-
* @param request The language model request containing specific settings.
|
|
24
|
-
* @returns A partial ChatRequest object containing the merged settings.
|
|
25
|
-
*/
|
|
26
|
-
protected getSettings(request: LanguageModelRequest): Partial<ChatRequest>;
|
|
27
|
-
protected dispatchRequest(ollama: Ollama, ollamaRequest: ExtendedChatRequest, structured: boolean, cancellation?: CancellationToken): Promise<LanguageModelResponse>;
|
|
28
|
-
protected handleStreamingRequest(ollama: Ollama, chatRequest: ExtendedChatRequest, cancellation?: CancellationToken): Promise<LanguageModelStreamResponse>;
|
|
29
|
-
/**
|
|
30
|
-
* Check if the Ollama server supports thinking.
|
|
31
|
-
*
|
|
32
|
-
* Use the Ollama 'show' request to get information about the model, so we can check the capabilities for the 'thinking' capability.
|
|
33
|
-
*
|
|
34
|
-
* @param ollama The Ollama client instance.
|
|
35
|
-
* @param model The name of the Ollama model.
|
|
36
|
-
* @returns A boolean indicating whether the Ollama model supports thinking.
|
|
37
|
-
*/
|
|
38
|
-
protected checkThinkingSupport(ollama: Ollama, model: string): Promise<boolean>;
|
|
39
|
-
protected handleStructuredOutputRequest(ollama: Ollama, chatRequest: ChatRequest): Promise<LanguageModelParsedResponse>;
|
|
40
|
-
protected handleNonStreamingRequest(ollama: Ollama, chatRequest: ExtendedNonStreamingChatRequest, cancellation?: CancellationToken): Promise<LanguageModelResponse>;
|
|
41
|
-
private processToolCalls;
|
|
42
|
-
private recordTokenUsage;
|
|
43
|
-
protected initializeOllama(): Ollama;
|
|
44
|
-
protected toOllamaTool(tool: ToolRequest): ToolWithHandler;
|
|
45
|
-
protected toOllamaMessage(message: LanguageModelMessage): Message | undefined;
|
|
46
|
-
protected toOllamaMessageRole(message: LanguageModelMessage): string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Extended Tool containing a handler
|
|
50
|
-
* @see Tool
|
|
51
|
-
*/
|
|
52
|
-
type ToolWithHandler = Tool & {
|
|
53
|
-
handler: (arg_string: string) => Promise<unknown>;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Extended chat request with mandatory messages and ToolWithHandler tools
|
|
57
|
-
*
|
|
58
|
-
* @see ChatRequest
|
|
59
|
-
* @see ToolWithHandler
|
|
60
|
-
*/
|
|
61
|
-
type ExtendedChatRequest = ChatRequest & {
|
|
62
|
-
messages: Message[];
|
|
63
|
-
tools?: ToolWithHandler[];
|
|
64
|
-
};
|
|
65
|
-
type ExtendedNonStreamingChatRequest = ExtendedChatRequest & {
|
|
66
|
-
stream: false;
|
|
67
|
-
};
|
|
68
|
-
export {};
|
|
69
|
-
//# sourceMappingURL=ollama-language-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3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,GAAG;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,CAAC"}
|
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2024 TypeFox 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.OllamaModel = exports.OllamaModelIdentifier = void 0;
|
|
19
|
-
const ai_core_1 = require("@theia/ai-core");
|
|
20
|
-
const ollama_1 = require("ollama");
|
|
21
|
-
exports.OllamaModelIdentifier = Symbol('OllamaModelIdentifier');
|
|
22
|
-
class OllamaModel {
|
|
23
|
-
/**
|
|
24
|
-
* @param id the unique id for this language model. It will be used to identify the model in the UI.
|
|
25
|
-
* @param model the unique model name as used in the Ollama environment.
|
|
26
|
-
* @param hostProvider a function to provide the host URL for the Ollama server.
|
|
27
|
-
*/
|
|
28
|
-
constructor(id, model, status, host, tokenUsageService) {
|
|
29
|
-
this.id = id;
|
|
30
|
-
this.model = model;
|
|
31
|
-
this.status = status;
|
|
32
|
-
this.host = host;
|
|
33
|
-
this.tokenUsageService = tokenUsageService;
|
|
34
|
-
this.DEFAULT_REQUEST_SETTINGS = {
|
|
35
|
-
keep_alive: '15m',
|
|
36
|
-
// options see: https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values
|
|
37
|
-
options: {}
|
|
38
|
-
};
|
|
39
|
-
this.providerId = 'ollama';
|
|
40
|
-
this.vendor = 'Ollama';
|
|
41
|
-
}
|
|
42
|
-
async request(request, cancellationToken) {
|
|
43
|
-
var _a, _b, _c;
|
|
44
|
-
const settings = this.getSettings(request);
|
|
45
|
-
const ollama = this.initializeOllama();
|
|
46
|
-
const stream = !(((_a = request.settings) === null || _a === void 0 ? void 0 : _a.stream) === false); // true by default, false only if explicitly specified
|
|
47
|
-
const ollamaRequest = {
|
|
48
|
-
model: this.model,
|
|
49
|
-
...this.DEFAULT_REQUEST_SETTINGS,
|
|
50
|
-
...settings,
|
|
51
|
-
messages: request.messages.map(m => this.toOllamaMessage(m)).filter(m => m !== undefined),
|
|
52
|
-
tools: (_b = request.tools) === null || _b === void 0 ? void 0 : _b.map(t => this.toOllamaTool(t)),
|
|
53
|
-
stream
|
|
54
|
-
};
|
|
55
|
-
const structured = ((_c = request.response_format) === null || _c === void 0 ? void 0 : _c.type) === 'json_schema';
|
|
56
|
-
return this.dispatchRequest(ollama, ollamaRequest, structured, cancellationToken);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Retrieves the settings for the chat request, merging the request-specific settings with the default settings.
|
|
60
|
-
* @param request The language model request containing specific settings.
|
|
61
|
-
* @returns A partial ChatRequest object containing the merged settings.
|
|
62
|
-
*/
|
|
63
|
-
getSettings(request) {
|
|
64
|
-
var _a;
|
|
65
|
-
const settings = (_a = request.settings) !== null && _a !== void 0 ? _a : {};
|
|
66
|
-
return {
|
|
67
|
-
options: settings
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
async dispatchRequest(ollama, ollamaRequest, structured, cancellation) {
|
|
71
|
-
// Handle structured output request
|
|
72
|
-
if (structured) {
|
|
73
|
-
return this.handleStructuredOutputRequest(ollama, ollamaRequest);
|
|
74
|
-
}
|
|
75
|
-
if (isNonStreaming(ollamaRequest)) {
|
|
76
|
-
// handle non-streaming request
|
|
77
|
-
return this.handleNonStreamingRequest(ollama, ollamaRequest, cancellation);
|
|
78
|
-
}
|
|
79
|
-
// handle streaming request
|
|
80
|
-
return this.handleStreamingRequest(ollama, ollamaRequest, cancellation);
|
|
81
|
-
}
|
|
82
|
-
async handleStreamingRequest(ollama, chatRequest, cancellation) {
|
|
83
|
-
const responseStream = await ollama.chat({
|
|
84
|
-
...chatRequest,
|
|
85
|
-
stream: true,
|
|
86
|
-
think: await this.checkThinkingSupport(ollama, chatRequest.model)
|
|
87
|
-
});
|
|
88
|
-
cancellation === null || cancellation === void 0 ? void 0 : cancellation.onCancellationRequested(() => {
|
|
89
|
-
responseStream.abort();
|
|
90
|
-
});
|
|
91
|
-
const that = this;
|
|
92
|
-
const asyncIterator = {
|
|
93
|
-
async *[Symbol.asyncIterator]() {
|
|
94
|
-
// Process the response stream and collect thinking, content messages, and tool calls.
|
|
95
|
-
// Tool calls are handled when the response stream is done.
|
|
96
|
-
const toolCalls = [];
|
|
97
|
-
let currentContent = '';
|
|
98
|
-
let currentThought = '';
|
|
99
|
-
// Ollama does not have ids, so we use the most recent chunk.created_at timestamp as repalcement
|
|
100
|
-
let lastUpdated = new Date();
|
|
101
|
-
try {
|
|
102
|
-
for await (const chunk of responseStream) {
|
|
103
|
-
lastUpdated = chunk.created_at;
|
|
104
|
-
const thought = chunk.message.thinking;
|
|
105
|
-
if (thought) {
|
|
106
|
-
currentThought += thought;
|
|
107
|
-
yield { thought, signature: '' };
|
|
108
|
-
}
|
|
109
|
-
const textContent = chunk.message.content;
|
|
110
|
-
if (textContent) {
|
|
111
|
-
currentContent += textContent;
|
|
112
|
-
yield { content: textContent };
|
|
113
|
-
}
|
|
114
|
-
if (chunk.message.tool_calls && chunk.message.tool_calls.length > 0) {
|
|
115
|
-
toolCalls.push(...chunk.message.tool_calls);
|
|
116
|
-
}
|
|
117
|
-
if (chunk.done) {
|
|
118
|
-
that.recordTokenUsage(chunk);
|
|
119
|
-
if (chunk.done_reason && chunk.done_reason !== 'stop') {
|
|
120
|
-
throw new Error('Ollama stopped unexpectedly. Reason: ' + chunk.done_reason);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (toolCalls && toolCalls.length > 0) {
|
|
125
|
-
chatRequest.messages.push({
|
|
126
|
-
role: 'assistant',
|
|
127
|
-
content: currentContent,
|
|
128
|
-
thinking: currentThought,
|
|
129
|
-
tool_calls: toolCalls
|
|
130
|
-
});
|
|
131
|
-
const toolCallsForResponse = await that.processToolCalls(toolCalls, chatRequest, lastUpdated);
|
|
132
|
-
yield { tool_calls: toolCallsForResponse };
|
|
133
|
-
// Continue the conversation with tool results
|
|
134
|
-
const continuedResponse = await that.handleStreamingRequest(ollama, chatRequest, cancellation);
|
|
135
|
-
// Stream the continued response
|
|
136
|
-
for await (const nestedEvent of continuedResponse.stream) {
|
|
137
|
-
yield nestedEvent;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
console.error('Error in Ollama streaming:', error.message);
|
|
143
|
-
throw error;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
return { stream: asyncIterator };
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Check if the Ollama server supports thinking.
|
|
151
|
-
*
|
|
152
|
-
* Use the Ollama 'show' request to get information about the model, so we can check the capabilities for the 'thinking' capability.
|
|
153
|
-
*
|
|
154
|
-
* @param ollama The Ollama client instance.
|
|
155
|
-
* @param model The name of the Ollama model.
|
|
156
|
-
* @returns A boolean indicating whether the Ollama model supports thinking.
|
|
157
|
-
*/
|
|
158
|
-
async checkThinkingSupport(ollama, model) {
|
|
159
|
-
var _a;
|
|
160
|
-
const result = await ollama.show({ model });
|
|
161
|
-
return ((_a = result === null || result === void 0 ? void 0 : result.capabilities) === null || _a === void 0 ? void 0 : _a.includes('thinking')) || false;
|
|
162
|
-
}
|
|
163
|
-
async handleStructuredOutputRequest(ollama, chatRequest) {
|
|
164
|
-
const response = await ollama.chat({
|
|
165
|
-
...chatRequest,
|
|
166
|
-
format: 'json',
|
|
167
|
-
stream: false,
|
|
168
|
-
});
|
|
169
|
-
try {
|
|
170
|
-
return {
|
|
171
|
-
content: response.message.content,
|
|
172
|
-
parsed: JSON.parse(response.message.content)
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
catch (error) {
|
|
176
|
-
// TODO use ILogger
|
|
177
|
-
console.log('Failed to parse structured response from the language model.', error);
|
|
178
|
-
return {
|
|
179
|
-
content: response.message.content,
|
|
180
|
-
parsed: {}
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
async handleNonStreamingRequest(ollama, chatRequest, cancellation) {
|
|
185
|
-
try {
|
|
186
|
-
// even though we have a non-streaming request, we still use the streaming version for two reasons:
|
|
187
|
-
// 1. we can abort the stream if the request is cancelled instead of having to wait for the entire response
|
|
188
|
-
// 2. we can use think: true so the Ollama API separates thinking from content and we can filter out the thoughts in the response
|
|
189
|
-
const responseStream = await ollama.chat({ ...chatRequest, stream: true, think: await this.checkThinkingSupport(ollama, chatRequest.model) });
|
|
190
|
-
cancellation === null || cancellation === void 0 ? void 0 : cancellation.onCancellationRequested(() => {
|
|
191
|
-
responseStream.abort();
|
|
192
|
-
});
|
|
193
|
-
const toolCalls = [];
|
|
194
|
-
let content = '';
|
|
195
|
-
let lastUpdated = new Date();
|
|
196
|
-
// process the response stream
|
|
197
|
-
for await (const chunk of responseStream) {
|
|
198
|
-
// if the response contains content, append it to the result
|
|
199
|
-
const textContent = chunk.message.content;
|
|
200
|
-
if (textContent) {
|
|
201
|
-
content += textContent;
|
|
202
|
-
}
|
|
203
|
-
// record requested tool calls so we can process them later
|
|
204
|
-
if (chunk.message.tool_calls && chunk.message.tool_calls.length > 0) {
|
|
205
|
-
toolCalls.push(...chunk.message.tool_calls);
|
|
206
|
-
}
|
|
207
|
-
// if the response is done, record the token usage and check the done reason
|
|
208
|
-
if (chunk.done) {
|
|
209
|
-
this.recordTokenUsage(chunk);
|
|
210
|
-
lastUpdated = chunk.created_at;
|
|
211
|
-
if (chunk.done_reason && chunk.done_reason !== 'stop') {
|
|
212
|
-
throw new Error('Ollama stopped unexpectedly. Reason: ' + chunk.done_reason);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// process any tool calls by adding all of them to the messages of the conversation
|
|
217
|
-
if (toolCalls && toolCalls.length > 0) {
|
|
218
|
-
chatRequest.messages.push({
|
|
219
|
-
role: 'assistant',
|
|
220
|
-
content: content,
|
|
221
|
-
tool_calls: toolCalls
|
|
222
|
-
});
|
|
223
|
-
await this.processToolCalls(toolCalls, chatRequest, lastUpdated);
|
|
224
|
-
if (cancellation === null || cancellation === void 0 ? void 0 : cancellation.isCancellationRequested) {
|
|
225
|
-
return { text: '' };
|
|
226
|
-
}
|
|
227
|
-
// recurse to get the final response content (the intermediate content remains hidden, it is only part of the conversation)
|
|
228
|
-
return this.handleNonStreamingRequest(ollama, chatRequest);
|
|
229
|
-
}
|
|
230
|
-
// if no tool calls are necessary, return the final response content
|
|
231
|
-
return { text: content };
|
|
232
|
-
}
|
|
233
|
-
catch (error) {
|
|
234
|
-
console.error('Error in ollama call:', error.message);
|
|
235
|
-
throw error;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
async processToolCalls(toolCalls, chatRequest, lastUpdated) {
|
|
239
|
-
var _a, _b;
|
|
240
|
-
const tools = (_a = chatRequest.tools) !== null && _a !== void 0 ? _a : [];
|
|
241
|
-
const toolCallsForResponse = [];
|
|
242
|
-
for (const [idx, toolCall] of toolCalls.entries()) {
|
|
243
|
-
const functionToCall = tools.find(tool => tool.function.name === toolCall.function.name);
|
|
244
|
-
const args = JSON.stringify((_b = toolCall.function) === null || _b === void 0 ? void 0 : _b.arguments);
|
|
245
|
-
let funcResult;
|
|
246
|
-
if (functionToCall) {
|
|
247
|
-
const rawResult = await functionToCall.handler(args);
|
|
248
|
-
funcResult = typeof rawResult === 'string' ? rawResult : JSON.stringify(rawResult);
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
funcResult = 'error: Tool not found';
|
|
252
|
-
}
|
|
253
|
-
chatRequest.messages.push({
|
|
254
|
-
role: 'tool',
|
|
255
|
-
content: `Tool call ${toolCall.function.name} returned: ${String(funcResult)}`,
|
|
256
|
-
});
|
|
257
|
-
toolCallsForResponse.push({
|
|
258
|
-
id: `ollama_${lastUpdated}_${idx}`,
|
|
259
|
-
function: {
|
|
260
|
-
name: toolCall.function.name,
|
|
261
|
-
arguments: args
|
|
262
|
-
},
|
|
263
|
-
result: String(funcResult),
|
|
264
|
-
finished: true
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
return toolCallsForResponse;
|
|
268
|
-
}
|
|
269
|
-
recordTokenUsage(response) {
|
|
270
|
-
if (this.tokenUsageService && response.prompt_eval_count && response.eval_count) {
|
|
271
|
-
this.tokenUsageService.recordTokenUsage(this.id, {
|
|
272
|
-
inputTokens: response.prompt_eval_count,
|
|
273
|
-
outputTokens: response.eval_count,
|
|
274
|
-
requestId: `ollama_${response.created_at}`
|
|
275
|
-
}).catch(error => console.error('Error recording token usage:', error));
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
initializeOllama() {
|
|
279
|
-
const host = this.host();
|
|
280
|
-
if (!host) {
|
|
281
|
-
throw new Error('Please provide OLLAMA_HOST in preferences or via environment variable');
|
|
282
|
-
}
|
|
283
|
-
return new ollama_1.Ollama({ host: host });
|
|
284
|
-
}
|
|
285
|
-
toOllamaTool(tool) {
|
|
286
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
287
|
-
const transform = (props) => {
|
|
288
|
-
if (!props) {
|
|
289
|
-
return undefined;
|
|
290
|
-
}
|
|
291
|
-
const result = {};
|
|
292
|
-
for (const [key, prop] of Object.entries(props)) {
|
|
293
|
-
const type = prop.type;
|
|
294
|
-
if (type) {
|
|
295
|
-
const description = typeof prop.description == 'string' ? prop.description : '';
|
|
296
|
-
result[key] = {
|
|
297
|
-
type: type,
|
|
298
|
-
description: description
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
// TODO: Should handle anyOf, but this is not supported by the Ollama type yet
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return result;
|
|
306
|
-
};
|
|
307
|
-
return {
|
|
308
|
-
type: 'function',
|
|
309
|
-
function: {
|
|
310
|
-
name: tool.name,
|
|
311
|
-
description: (_a = tool.description) !== null && _a !== void 0 ? _a : 'Tool named ' + tool.name,
|
|
312
|
-
parameters: {
|
|
313
|
-
type: (_c = (_b = tool.parameters) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : 'object',
|
|
314
|
-
required: (_e = (_d = tool.parameters) === null || _d === void 0 ? void 0 : _d.required) !== null && _e !== void 0 ? _e : [],
|
|
315
|
-
properties: (_g = transform((_f = tool.parameters) === null || _f === void 0 ? void 0 : _f.properties)) !== null && _g !== void 0 ? _g : {}
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
handler: tool.handler
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
toOllamaMessage(message) {
|
|
322
|
-
const result = {
|
|
323
|
-
role: this.toOllamaMessageRole(message),
|
|
324
|
-
content: ''
|
|
325
|
-
};
|
|
326
|
-
if (ai_core_1.LanguageModelMessage.isTextMessage(message) && message.text.length > 0) {
|
|
327
|
-
result.content = message.text;
|
|
328
|
-
}
|
|
329
|
-
else if (ai_core_1.LanguageModelMessage.isToolUseMessage(message)) {
|
|
330
|
-
result.tool_calls = [{ function: { name: message.name, arguments: message.input } }];
|
|
331
|
-
}
|
|
332
|
-
else if (ai_core_1.LanguageModelMessage.isToolResultMessage(message)) {
|
|
333
|
-
result.content = `Tool call ${message.name} returned: ${message.content}`;
|
|
334
|
-
}
|
|
335
|
-
else if (ai_core_1.LanguageModelMessage.isThinkingMessage(message)) {
|
|
336
|
-
result.thinking = message.thinking;
|
|
337
|
-
}
|
|
338
|
-
else if (ai_core_1.LanguageModelMessage.isImageMessage(message) && ai_core_1.ImageContent.isBase64(message.image)) {
|
|
339
|
-
result.images = [message.image.base64data];
|
|
340
|
-
}
|
|
341
|
-
else {
|
|
342
|
-
console.log(`Unknown message type encountered when converting message to Ollama format: ${JSON.stringify(message)}. Ignoring message.`);
|
|
343
|
-
return undefined;
|
|
344
|
-
}
|
|
345
|
-
return result;
|
|
346
|
-
}
|
|
347
|
-
toOllamaMessageRole(message) {
|
|
348
|
-
if (ai_core_1.LanguageModelMessage.isToolResultMessage(message)) {
|
|
349
|
-
return 'tool';
|
|
350
|
-
}
|
|
351
|
-
const actor = message.actor;
|
|
352
|
-
if (actor === 'ai') {
|
|
353
|
-
return 'assistant';
|
|
354
|
-
}
|
|
355
|
-
if (actor === 'user') {
|
|
356
|
-
return 'user';
|
|
357
|
-
}
|
|
358
|
-
if (actor === 'system') {
|
|
359
|
-
return 'system';
|
|
360
|
-
}
|
|
361
|
-
console.log(`Unknown actor encountered when converting message to Ollama format: ${actor}. Falling back to 'user'.`);
|
|
362
|
-
return 'user'; // default fallback
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
exports.OllamaModel = OllamaModel;
|
|
366
|
-
function isNonStreaming(request) {
|
|
367
|
-
return !request.stream;
|
|
368
|
-
}
|
|
369
|
-
//# sourceMappingURL=ollama-language-model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-language-model.js","sourceRoot":"","sources":["../../src/node/ollama-language-model.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,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;;;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,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;YACpD,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACjB,OAAO,WAAW,CAAC;QACvB,CAAC;QACD,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACnB,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrB,OAAO,QAAQ,CAAC;QACpB,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,uEAAuE,KAAK,2BAA2B,CAAC,CAAC;QACrH,OAAO,MAAM,CAAC,CAAC,mBAAmB;IACtC,CAAC;CACJ;AAxXD,kCAwXC;AAqBD,SAAS,cAAc,CAAC,OAA4B;IAChD,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;AAC3B,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { LanguageModelRegistry, LanguageModelStatus, TokenUsageService } from '@theia/ai-core';
|
|
2
|
-
import { OllamaLanguageModelsManager, OllamaModelDescription } from '../common';
|
|
3
|
-
export declare class OllamaLanguageModelsManagerImpl implements OllamaLanguageModelsManager {
|
|
4
|
-
protected _host: string | undefined;
|
|
5
|
-
protected readonly languageModelRegistry: LanguageModelRegistry;
|
|
6
|
-
protected readonly tokenUsageService: TokenUsageService;
|
|
7
|
-
get host(): string | undefined;
|
|
8
|
-
protected calculateStatus(host: string | undefined): LanguageModelStatus;
|
|
9
|
-
createOrUpdateLanguageModels(...models: OllamaModelDescription[]): Promise<void>;
|
|
10
|
-
removeLanguageModels(...modelIds: string[]): void;
|
|
11
|
-
setHost(host: string | undefined): void;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=ollama-language-models-manager-impl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-language-models-manager-impl.d.ts","sourceRoot":"","sources":["../../src/node/ollama-language-models-manager-impl.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAG/F,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEhF,qBACa,+BAAgC,YAAW,2BAA2B;IAE/E,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAGpC,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAGhE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAExD,IAAI,IAAI,IAAI,MAAM,GAAG,SAAS,CAE7B;IAID,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,mBAAmB;IAIlE,4BAA4B,CAAC,GAAG,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBtF,oBAAoB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAIjD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;CAG1C"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2024 TypeFox 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.OllamaLanguageModelsManagerImpl = void 0;
|
|
19
|
-
const tslib_1 = require("tslib");
|
|
20
|
-
const ai_core_1 = require("@theia/ai-core");
|
|
21
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
-
const ollama_language_model_1 = require("./ollama-language-model");
|
|
23
|
-
let OllamaLanguageModelsManagerImpl = class OllamaLanguageModelsManagerImpl {
|
|
24
|
-
get host() {
|
|
25
|
-
var _a;
|
|
26
|
-
return (_a = this._host) !== null && _a !== void 0 ? _a : process.env.OLLAMA_HOST;
|
|
27
|
-
}
|
|
28
|
-
// Triggered from frontend. In case you want to use the models on the backend
|
|
29
|
-
// without a frontend then call this yourself
|
|
30
|
-
calculateStatus(host) {
|
|
31
|
-
return host ? { status: 'ready' } : { status: 'unavailable', message: 'No Ollama host set' };
|
|
32
|
-
}
|
|
33
|
-
async createOrUpdateLanguageModels(...models) {
|
|
34
|
-
for (const modelDescription of models) {
|
|
35
|
-
const existingModel = await this.languageModelRegistry.getLanguageModel(modelDescription.id);
|
|
36
|
-
const hostProvider = () => this.host;
|
|
37
|
-
if (existingModel) {
|
|
38
|
-
if (!(existingModel instanceof ollama_language_model_1.OllamaModel)) {
|
|
39
|
-
console.warn(`Ollama: model ${modelDescription.id} is not an Ollama model`);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
const status = this.calculateStatus(hostProvider());
|
|
45
|
-
this.languageModelRegistry.addLanguageModels([
|
|
46
|
-
new ollama_language_model_1.OllamaModel(modelDescription.id, modelDescription.model, status, hostProvider, this.tokenUsageService)
|
|
47
|
-
]);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
removeLanguageModels(...modelIds) {
|
|
52
|
-
this.languageModelRegistry.removeLanguageModels(modelIds.map(id => `ollama/${id}`));
|
|
53
|
-
}
|
|
54
|
-
setHost(host) {
|
|
55
|
-
this._host = host || undefined;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
exports.OllamaLanguageModelsManagerImpl = OllamaLanguageModelsManagerImpl;
|
|
59
|
-
tslib_1.__decorate([
|
|
60
|
-
(0, inversify_1.inject)(ai_core_1.LanguageModelRegistry),
|
|
61
|
-
tslib_1.__metadata("design:type", Object)
|
|
62
|
-
], OllamaLanguageModelsManagerImpl.prototype, "languageModelRegistry", void 0);
|
|
63
|
-
tslib_1.__decorate([
|
|
64
|
-
(0, inversify_1.inject)(ai_core_1.TokenUsageService),
|
|
65
|
-
tslib_1.__metadata("design:type", Object)
|
|
66
|
-
], OllamaLanguageModelsManagerImpl.prototype, "tokenUsageService", void 0);
|
|
67
|
-
exports.OllamaLanguageModelsManagerImpl = OllamaLanguageModelsManagerImpl = tslib_1.__decorate([
|
|
68
|
-
(0, inversify_1.injectable)()
|
|
69
|
-
], OllamaLanguageModelsManagerImpl);
|
|
70
|
-
//# sourceMappingURL=ollama-language-models-manager-impl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-language-models-manager-impl.js","sourceRoot":"","sources":["../../src/node/ollama-language-models-manager-impl.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,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,4CAA+F;AAC/F,4DAAkE;AAClE,mEAAsD;AAI/C,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAUxC,IAAI,IAAI;;QACJ,OAAO,MAAA,IAAI,CAAC,KAAK,mCAAI,OAAO,CAAC,GAAG,C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wB;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,SAAS,CAAC;IACnC,CAAC;CACJ,CAAA;AApDY,0EAA+B;AAKrB;IADlB,IAAA,kBAAM,EAAC,+BAAqB,CAAC;;8EACkC;AAG7C;IADlB,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;0EAC8B;0CAR/C,+BAA+B;IAD3C,IAAA,sBAAU,GAAE;GACA,+BAA+B,CAoD3C"}
|
package/lib/package.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
|
package/lib/package.spec.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2025 TypeFox GmbH and others.
|
|
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 ollama_language_model_1 = require("./node/ollama-language-model");
|
|
19
|
-
const chai_1 = require("chai");
|
|
20
|
-
const sinon = require("sinon");
|
|
21
|
-
describe('ai-ollama package', () => {
|
|
22
|
-
it('Transform to Ollama tools', () => {
|
|
23
|
-
var _a, _b, _c;
|
|
24
|
-
const req = createToolRequest();
|
|
25
|
-
const model = new OllamaModelUnderTest();
|
|
26
|
-
const ollamaTool = model.toOllamaTool(req);
|
|
27
|
-
(0, chai_1.expect)(ollamaTool.function.name).equals('example-tool');
|
|
28
|
-
(0, chai_1.expect)(ollamaTool.function.description).equals('Example Tool');
|
|
29
|
-
(0, chai_1.expect)((_a = ollamaTool.function.parameters) === null || _a === void 0 ? void 0 : _a.type).equal('object');
|
|
30
|
-
(0, chai_1.expect)((_b = ollamaTool.function.parameters) === null || _b === void 0 ? void 0 : _b.properties).to.deep.equal(req.parameters.properties);
|
|
31
|
-
(0, chai_1.expect)((_c = ollamaTool.function.parameters) === null || _c === void 0 ? void 0 : _c.required).to.deep.equal(['question']);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
class OllamaModelUnderTest extends ollama_language_model_1.OllamaModel {
|
|
35
|
-
constructor() {
|
|
36
|
-
super('id', 'model', { status: 'ready' }, () => '');
|
|
37
|
-
}
|
|
38
|
-
toOllamaTool(tool) {
|
|
39
|
-
return super.toOllamaTool(tool);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function createToolRequest() {
|
|
43
|
-
return {
|
|
44
|
-
id: 'tool-1',
|
|
45
|
-
name: 'example-tool',
|
|
46
|
-
description: 'Example Tool',
|
|
47
|
-
parameters: {
|
|
48
|
-
type: 'object',
|
|
49
|
-
properties: {
|
|
50
|
-
question: {
|
|
51
|
-
type: 'string',
|
|
52
|
-
description: 'What is the best pizza topping?'
|
|
53
|
-
},
|
|
54
|
-
optional: {
|
|
55
|
-
type: 'string',
|
|
56
|
-
description: 'Optional parameter'
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
required: ['question']
|
|
60
|
-
},
|
|
61
|
-
handler: sinon.stub()
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=package.spec.js.map
|
package/lib/package.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.spec.js","s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