@theia/ai-anthropic 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.
Files changed (44) hide show
  1. package/README.md +1 -0
  2. package/package.json +4 -4
  3. package/src/browser/anthropic-frontend-application-contribution.ts +4 -1
  4. package/src/common/anthropic-preferences.ts +1 -2
  5. package/lib/browser/anthropic-frontend-application-contribution.d.ts +0 -15
  6. package/lib/browser/anthropic-frontend-application-contribution.d.ts.map +0 -1
  7. package/lib/browser/anthropic-frontend-application-contribution.js +0 -118
  8. package/lib/browser/anthropic-frontend-application-contribution.js.map +0 -1
  9. package/lib/browser/anthropic-frontend-module.d.ts +0 -4
  10. package/lib/browser/anthropic-frontend-module.d.ts.map +0 -1
  11. package/lib/browser/anthropic-frontend-module.js +0 -33
  12. package/lib/browser/anthropic-frontend-module.js.map +0 -1
  13. package/lib/common/anthropic-language-models-manager.d.ts +0 -40
  14. package/lib/common/anthropic-language-models-manager.d.ts.map +0 -1
  15. package/lib/common/anthropic-language-models-manager.js +0 -21
  16. package/lib/common/anthropic-language-models-manager.js.map +0 -1
  17. package/lib/common/anthropic-preferences.d.ts +0 -5
  18. package/lib/common/anthropic-preferences.d.ts.map +0 -1
  19. package/lib/common/anthropic-preferences.js +0 -43
  20. package/lib/common/anthropic-preferences.js.map +0 -1
  21. package/lib/common/index.d.ts +0 -2
  22. package/lib/common/index.d.ts.map +0 -1
  23. package/lib/common/index.js +0 -20
  24. package/lib/common/index.js.map +0 -1
  25. package/lib/node/anthropic-backend-module.d.ts +0 -4
  26. package/lib/node/anthropic-backend-module.d.ts.map +0 -1
  27. package/lib/node/anthropic-backend-module.js +0 -34
  28. package/lib/node/anthropic-backend-module.js.map +0 -1
  29. package/lib/node/anthropic-language-model.d.ts +0 -36
  30. package/lib/node/anthropic-language-model.d.ts.map +0 -1
  31. package/lib/node/anthropic-language-model.js +0 -386
  32. package/lib/node/anthropic-language-model.js.map +0 -1
  33. package/lib/node/anthropic-language-model.spec.d.ts +0 -2
  34. package/lib/node/anthropic-language-model.spec.d.ts.map +0 -1
  35. package/lib/node/anthropic-language-model.spec.js +0 -124
  36. package/lib/node/anthropic-language-model.spec.js.map +0 -1
  37. package/lib/node/anthropic-language-models-manager-impl.d.ts +0 -18
  38. package/lib/node/anthropic-language-models-manager-impl.d.ts.map +0 -1
  39. package/lib/node/anthropic-language-models-manager-impl.js +0 -112
  40. package/lib/node/anthropic-language-models-manager-impl.js.map +0 -1
  41. package/lib/package.spec.d.ts +0 -1
  42. package/lib/package.spec.d.ts.map +0 -1
  43. package/lib/package.spec.js +0 -26
  44. package/lib/package.spec.js.map +0 -1
@@ -1,112 +0,0 @@
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.AnthropicLanguageModelsManagerImpl = 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 anthropic_language_model_1 = require("./anthropic-language-model");
23
- let AnthropicLanguageModelsManagerImpl = class AnthropicLanguageModelsManagerImpl {
24
- get apiKey() {
25
- var _a;
26
- return (_a = this._apiKey) !== null && _a !== void 0 ? _a : process.env.ANTHROPIC_API_KEY;
27
- }
28
- async createOrUpdateLanguageModels(...modelDescriptions) {
29
- for (const modelDescription of modelDescriptions) {
30
- const model = await this.languageModelRegistry.getLanguageModel(modelDescription.id);
31
- const apiKeyProvider = () => {
32
- if (modelDescription.apiKey === true) {
33
- return this.apiKey;
34
- }
35
- if (modelDescription.apiKey) {
36
- return modelDescription.apiKey;
37
- }
38
- return undefined;
39
- };
40
- const proxyUrlProvider = () => {
41
- // first check if the proxy url is provided via Theia settings
42
- if (this._proxyUrl) {
43
- return this._proxyUrl;
44
- }
45
- // if not fall back to the environment variables
46
- return process.env['https_proxy'];
47
- };
48
- // Determine status based on API key presence
49
- const effectiveApiKey = apiKeyProvider();
50
- const status = this.getStatusForApiKey(effectiveApiKey);
51
- if (model) {
52
- if (!(model instanceof anthropic_language_model_1.AnthropicModel)) {
53
- console.warn(`Anthropic: model ${modelDescription.id} is not an Anthropic model`);
54
- continue;
55
- }
56
- await this.languageModelRegistry.patchLanguageModel(modelDescription.id, {
57
- model: modelDescription.model,
58
- enableStreaming: modelDescription.enableStreaming,
59
- apiKey: apiKeyProvider,
60
- status,
61
- maxTokens: modelDescription.maxTokens !== undefined ? modelDescription.maxTokens : anthropic_language_model_1.DEFAULT_MAX_TOKENS,
62
- maxRetries: modelDescription.maxRetries
63
- });
64
- }
65
- else {
66
- this.languageModelRegistry.addLanguageModels([
67
- new anthropic_language_model_1.AnthropicModel(modelDescription.id, modelDescription.model, status, modelDescription.enableStreaming, modelDescription.useCaching, apiKeyProvider, modelDescription.maxTokens, modelDescription.maxRetries, this.tokenUsageService, proxyUrlProvider())
68
- ]);
69
- }
70
- }
71
- }
72
- removeLanguageModels(...modelIds) {
73
- this.languageModelRegistry.removeLanguageModels(modelIds);
74
- }
75
- setApiKey(apiKey) {
76
- if (apiKey) {
77
- this._apiKey = apiKey;
78
- }
79
- else {
80
- this._apiKey = undefined;
81
- }
82
- }
83
- setProxyUrl(proxyUrl) {
84
- if (proxyUrl) {
85
- this._proxyUrl = proxyUrl;
86
- }
87
- else {
88
- this._proxyUrl = undefined;
89
- }
90
- }
91
- /**
92
- * Returns the status for a language model based on the presence of an API key.
93
- */
94
- getStatusForApiKey(effectiveApiKey) {
95
- return effectiveApiKey
96
- ? { status: 'ready' }
97
- : { status: 'unavailable', message: 'No API key set' };
98
- }
99
- };
100
- exports.AnthropicLanguageModelsManagerImpl = AnthropicLanguageModelsManagerImpl;
101
- tslib_1.__decorate([
102
- (0, inversify_1.inject)(ai_core_1.LanguageModelRegistry),
103
- tslib_1.__metadata("design:type", Object)
104
- ], AnthropicLanguageModelsManagerImpl.prototype, "languageModelRegistry", void 0);
105
- tslib_1.__decorate([
106
- (0, inversify_1.inject)(ai_core_1.TokenUsageService),
107
- tslib_1.__metadata("design:type", Object)
108
- ], AnthropicLanguageModelsManagerImpl.prototype, "tokenUsageService", void 0);
109
- exports.AnthropicLanguageModelsManagerImpl = AnthropicLanguageModelsManagerImpl = tslib_1.__decorate([
110
- (0, inversify_1.injectable)()
111
- ], AnthropicLanguageModelsManagerImpl);
112
- //# sourceMappingURL=anthropic-language-models-manager-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"anthropic-language-models-manager-impl.js","sourceRoot":"","sources":["../../src/node/anthropic-language-models-manager-impl.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,4CAA+F;AAC/F,4DAAkE;AAClE,yEAAgF;AAIzE,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAW3C,IAAI,MAAM;;QACN,OAAO,MAAA,IAAI,CAAC,OAAO,mCAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,4BAA4B,CAAC,GAAG,iBAA8C;QAChF,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,EAAE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AqB,CAAC;;iFACkC;AAG7C;IADlB,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;6EAC8B;6CAT/C,kCAAkC;IAD9C,IAAA,sBAAU,GAAE;GACA,kCAAkC,CAqG9C"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=package.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 EclipseSource GmbH and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
- /* note: this bogus test file is required so that
17
- we are able to run mocha unit tests on this
18
- package, without having any actual unit tests in it.
19
- This way a coverage report will be generated,
20
- showing 0% coverage, instead of no report.
21
- This file can be removed once we have real unit
22
- tests in place. */
23
- describe('ai-anthropic package', () => {
24
- it('support code coverage statistics', () => true);
25
- });
26
- //# sourceMappingURL=package.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oDAAoD;AACpD,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;;;;;;qBAMqB;AAErB,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAElC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}