@theia/ai-openai 1.67.0-next.3 → 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/src/common/openai-preferences.ts +9 -12
- package/src/node/openai-model-utils.spec.ts +104 -1
- package/src/node/openai-response-api-utils.ts +54 -6
- package/lib/browser/openai-frontend-application-contribution.d.ts +0 -18
- package/lib/browser/openai-frontend-application-contribution.d.ts.map +0 -1
- package/lib/browser/openai-frontend-application-contribution.js +0 -163
- package/lib/browser/openai-frontend-application-contribution.js.map +0 -1
- package/lib/browser/openai-frontend-module.d.ts +0 -4
- package/lib/browser/openai-frontend-module.d.ts.map +0 -1
- package/lib/browser/openai-frontend-module.js +0 -33
- package/lib/browser/openai-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/openai-language-models-manager.d.ts +0 -63
- package/lib/common/openai-language-models-manager.d.ts.map +0 -1
- package/lib/common/openai-language-models-manager.js +0 -22
- package/lib/common/openai-language-models-manager.js.map +0 -1
- package/lib/common/openai-preferences.d.ts +0 -7
- package/lib/common/openai-preferences.d.ts.map +0 -1
- package/lib/common/openai-preferences.js +0 -144
- package/lib/common/openai-preferences.js.map +0 -1
- package/lib/node/openai-backend-module.d.ts +0 -5
- package/lib/node/openai-backend-module.d.ts.map +0 -1
- package/lib/node/openai-backend-module.js +0 -40
- package/lib/node/openai-backend-module.js.map +0 -1
- package/lib/node/openai-language-model.d.ts +0 -80
- package/lib/node/openai-language-model.d.ts.map +0 -1
- package/lib/node/openai-language-model.js +0 -324
- package/lib/node/openai-language-model.js.map +0 -1
- package/lib/node/openai-language-models-manager-impl.d.ts +0 -22
- package/lib/node/openai-language-models-manager-impl.d.ts.map +0 -1
- package/lib/node/openai-language-models-manager-impl.js +0 -162
- package/lib/node/openai-language-models-manager-impl.js.map +0 -1
- package/lib/node/openai-model-utils.spec.d.ts +0 -2
- package/lib/node/openai-model-utils.spec.d.ts.map +0 -1
- package/lib/node/openai-model-utils.spec.js +0 -382
- package/lib/node/openai-model-utils.spec.js.map +0 -1
- package/lib/node/openai-request-api-context.d.ts +0 -4
- package/lib/node/openai-request-api-context.d.ts.map +0 -1
- package/lib/node/openai-request-api-context.js +0 -18
- package/lib/node/openai-request-api-context.js.map +0 -1
- package/lib/node/openai-response-api-utils.d.ts +0 -42
- package/lib/node/openai-response-api-utils.d.ts.map +0 -1
- package/lib/node/openai-response-api-utils.js +0 -677
- package/lib/node/openai-response-api-utils.js.map +0 -1
- package/lib/node/openai-streaming-iterator.d.ts +0 -24
- package/lib/node/openai-streaming-iterator.d.ts.map +0 -1
- package/lib/node/openai-streaming-iterator.js +0 -176
- package/lib/node/openai-streaming-iterator.js.map +0 -1
- package/lib/node/openai-streaming-iterator.spec.d.ts +0 -2
- package/lib/node/openai-streaming-iterator.spec.d.ts.map +0 -1
- package/lib/node/openai-streaming-iterator.spec.js +0 -207
- package/lib/node/openai-streaming-iterator.spec.js.map +0 -1
package/README.md
CHANGED
|
@@ -92,6 +92,7 @@ path and without the `api-version` parameter, e.g. _`https://<my_prefix>.openai.
|
|
|
92
92
|
|
|
93
93
|
## Additional Information
|
|
94
94
|
|
|
95
|
+
- [API documentation for `@theia/ai-openai`](https://eclipse-theia.github.io/theia/docs/next/modules/_theia_ai-openai.html)
|
|
95
96
|
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
96
97
|
- [Theia - Website](https://theia-ide.org/)
|
|
97
98
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-openai",
|
|
3
|
-
"version": "1.67.0-next.
|
|
3
|
+
"version": "1.67.0-next.56+d8f18cc386c",
|
|
4
4
|
"description": "Theia - OpenAI 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
|
"openai": "^6.3.0",
|
|
11
11
|
"tslib": "^2.6.2",
|
|
12
12
|
"undici": "^7.16.0"
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"nyc": {
|
|
51
51
|
"extends": "../../configs/nyc.json"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "d8f18cc386c45a736cd193d42eab02c8f64c6b10"
|
|
54
54
|
}
|
|
@@ -36,18 +36,12 @@ on the machine running Theia. Use the environment variable `OPENAI_API_KEY` to s
|
|
|
36
36
|
description: nls.localize('theia/ai/openai/models/description', 'Official OpenAI models to use'),
|
|
37
37
|
title: AI_CORE_PREFERENCES_TITLE,
|
|
38
38
|
default: [
|
|
39
|
-
'gpt-
|
|
40
|
-
'gpt-4.1',
|
|
41
|
-
'gpt-4.1-nano',
|
|
42
|
-
'gpt-4.1-mini',
|
|
43
|
-
'gpt-4o-mini',
|
|
44
|
-
'o3',
|
|
45
|
-
'o3-mini',
|
|
46
|
-
'o4-mini',
|
|
47
|
-
'o4-mini-high',
|
|
39
|
+
'gpt-5.1',
|
|
48
40
|
'gpt-5',
|
|
49
41
|
'gpt-5-mini',
|
|
50
|
-
'gpt-
|
|
42
|
+
'gpt-4.1',
|
|
43
|
+
'gpt-4.1-mini',
|
|
44
|
+
'gpt-4o'
|
|
51
45
|
],
|
|
52
46
|
items: {
|
|
53
47
|
type: 'string'
|
|
@@ -58,9 +52,12 @@ on the machine running Theia. Use the environment variable `OPENAI_API_KEY` to s
|
|
|
58
52
|
default: false,
|
|
59
53
|
title: AI_CORE_PREFERENCES_TITLE,
|
|
60
54
|
markdownDescription: nls.localize('theia/ai/openai/useResponseApi/mdDescription',
|
|
61
|
-
'Use the newer OpenAI Response API instead of the Chat Completion API for official OpenAI models
|
|
55
|
+
'Use the newer OpenAI Response API instead of the Chat Completion API for official OpenAI models.\
|
|
56
|
+
\
|
|
57
|
+
This setting only applies to official OpenAI models - custom providers must configure this individually.\
|
|
62
58
|
\
|
|
63
|
-
|
|
59
|
+
Note that for the response API, tool call definitions must satisfy Open AI\'s [strict schema definition](https://platform.openai.com/docs/guides/function-calling#strict-mode).\
|
|
60
|
+
Best effort is made to convert non-conformant schemas, but errors are still possible.')
|
|
64
61
|
},
|
|
65
62
|
[CUSTOM_ENDPOINTS_PREF]: {
|
|
66
63
|
type: 'array',
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
import { expect } from 'chai';
|
|
17
17
|
import { OpenAiModelUtils } from './openai-language-model';
|
|
18
18
|
import { LanguageModelMessage } from '@theia/ai-core';
|
|
19
|
-
import { OpenAiResponseApiUtils } from './openai-response-api-utils';
|
|
19
|
+
import { OpenAiResponseApiUtils, recursiveStrictJSONSchema } from './openai-response-api-utils';
|
|
20
|
+
import type { JSONSchema, JSONSchemaDefinition } from 'openai/lib/jsonschema';
|
|
20
21
|
|
|
21
22
|
const utils = new OpenAiModelUtils();
|
|
22
23
|
const responseUtils = new OpenAiResponseApiUtils();
|
|
@@ -396,4 +397,106 @@ describe('OpenAiModelUtils - processMessagesForResponseApi', () => {
|
|
|
396
397
|
.to.throw('unhandled case');
|
|
397
398
|
});
|
|
398
399
|
});
|
|
400
|
+
|
|
401
|
+
describe('recursiveStrictJSONSchema', () => {
|
|
402
|
+
it('should return the same object and not modify it when schema has no properties to strictify', () => {
|
|
403
|
+
const schema: JSONSchema = { type: 'string', description: 'Simple string' };
|
|
404
|
+
const originalJson = JSON.stringify(schema);
|
|
405
|
+
|
|
406
|
+
const result = recursiveStrictJSONSchema(schema);
|
|
407
|
+
|
|
408
|
+
expect(result).to.equal(schema);
|
|
409
|
+
expect(JSON.stringify(schema)).to.equal(originalJson);
|
|
410
|
+
const resultObj = result as JSONSchema;
|
|
411
|
+
expect(resultObj).to.not.have.property('additionalProperties');
|
|
412
|
+
expect(resultObj).to.not.have.property('required');
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it('should not mutate original but return a new strictified schema when branching applies (properties/items)', () => {
|
|
416
|
+
const original: JSONSchema = {
|
|
417
|
+
type: 'object',
|
|
418
|
+
properties: {
|
|
419
|
+
path: { type: 'string' },
|
|
420
|
+
data: {
|
|
421
|
+
type: 'array',
|
|
422
|
+
items: {
|
|
423
|
+
type: 'object',
|
|
424
|
+
properties: {
|
|
425
|
+
a: { type: 'string' }
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
const originalClone = JSON.parse(JSON.stringify(original));
|
|
432
|
+
|
|
433
|
+
const resultDef = recursiveStrictJSONSchema(original);
|
|
434
|
+
const result = resultDef as JSONSchema;
|
|
435
|
+
|
|
436
|
+
expect(result).to.not.equal(original);
|
|
437
|
+
expect(original).to.deep.equal(originalClone);
|
|
438
|
+
|
|
439
|
+
expect(result.additionalProperties).to.equal(false);
|
|
440
|
+
expect(result.required).to.have.members(['path', 'data']);
|
|
441
|
+
|
|
442
|
+
const itemsDef = (result.properties?.data as JSONSchema).items as JSONSchemaDefinition;
|
|
443
|
+
expect(itemsDef).to.be.ok;
|
|
444
|
+
const itemsObj = itemsDef as JSONSchema;
|
|
445
|
+
expect(itemsObj.additionalProperties).to.equal(false);
|
|
446
|
+
expect(itemsObj.required).to.have.members(['a']);
|
|
447
|
+
|
|
448
|
+
const originalItems = ((original.properties!.data as JSONSchema).items) as JSONSchema;
|
|
449
|
+
expect(originalItems).to.not.have.property('additionalProperties');
|
|
450
|
+
expect(originalItems).to.not.have.property('required');
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
it('should strictify nested parameters schema and not mutate the original', () => {
|
|
454
|
+
const replacementProperties: Record<string, JSONSchema> = {
|
|
455
|
+
oldContent: { type: 'string', description: 'The exact content to be replaced. Must match exactly, including whitespace, comments, etc.' },
|
|
456
|
+
newContent: { type: 'string', description: 'The new content to insert in place of matched old content.' },
|
|
457
|
+
multiple: { type: 'boolean', description: 'Set to true if multiple occurrences of the oldContent are expected to be replaced.' }
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
const parameters: JSONSchema = {
|
|
461
|
+
type: 'object',
|
|
462
|
+
properties: {
|
|
463
|
+
path: { type: 'string', description: 'The path of the file where content will be replaced.' },
|
|
464
|
+
replacements: {
|
|
465
|
+
type: 'array',
|
|
466
|
+
items: {
|
|
467
|
+
type: 'object',
|
|
468
|
+
properties: replacementProperties,
|
|
469
|
+
required: ['oldContent', 'newContent']
|
|
470
|
+
},
|
|
471
|
+
description: 'An array of replacement objects, each containing oldContent and newContent strings.'
|
|
472
|
+
},
|
|
473
|
+
reset: {
|
|
474
|
+
type: 'boolean',
|
|
475
|
+
description: 'Set to true to clear any existing pending changes for this file and start fresh. Default is false, which merges with existing changes.'
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
required: ['path', 'replacements']
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
const originalClone = JSON.parse(JSON.stringify(parameters));
|
|
482
|
+
|
|
483
|
+
const strictifiedDef = recursiveStrictJSONSchema(parameters);
|
|
484
|
+
const strictified = strictifiedDef as JSONSchema;
|
|
485
|
+
|
|
486
|
+
expect(strictified).to.not.equal(parameters);
|
|
487
|
+
expect(parameters).to.deep.equal(originalClone);
|
|
488
|
+
|
|
489
|
+
expect(strictified.additionalProperties).to.equal(false);
|
|
490
|
+
expect(strictified.required).to.have.members(['path', 'replacements', 'reset']);
|
|
491
|
+
|
|
492
|
+
const items = (strictified.properties!.replacements as JSONSchema).items as JSONSchema;
|
|
493
|
+
expect(items.additionalProperties).to.equal(false);
|
|
494
|
+
expect(items.required).to.have.members(['oldContent', 'newContent', 'multiple']);
|
|
495
|
+
|
|
496
|
+
const origItems = ((parameters.properties!.replacements as JSONSchema).items) as JSONSchema;
|
|
497
|
+
expect(origItems.required).to.deep.equal(['oldContent', 'newContent']);
|
|
498
|
+
expect(origItems).to.not.have.property('additionalProperties');
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
|
|
399
502
|
});
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
TokenUsageService,
|
|
24
24
|
ToolCallErrorResult,
|
|
25
25
|
ToolRequest,
|
|
26
|
+
ToolRequestParameters,
|
|
26
27
|
UserRequest
|
|
27
28
|
} from '@theia/ai-core';
|
|
28
29
|
import { CancellationToken, unreachable } from '@theia/core';
|
|
@@ -40,6 +41,7 @@ import type {
|
|
|
40
41
|
} from 'openai/resources/responses/responses';
|
|
41
42
|
import type { ResponsesModel } from 'openai/resources/shared';
|
|
42
43
|
import { DeveloperMessageSettings, OpenAiModelUtils } from './openai-language-model';
|
|
44
|
+
import { JSONSchema, JSONSchemaDefinition } from 'openai/lib/jsonschema';
|
|
43
45
|
|
|
44
46
|
interface ToolCall {
|
|
45
47
|
id: string;
|
|
@@ -152,17 +154,17 @@ export class OpenAiResponseApiUtils {
|
|
|
152
154
|
// The Response API is very strict re: JSON schema: all properties must be listed as required,
|
|
153
155
|
// and additional properties must be disallowed.
|
|
154
156
|
// https://platform.openai.com/docs/guides/function-calling#strict-mode
|
|
155
|
-
parameters:
|
|
156
|
-
...tool.parameters,
|
|
157
|
-
additionalProperties: false,
|
|
158
|
-
required: tool.parameters.properties ? Object.keys(tool.parameters.properties) : []
|
|
159
|
-
},
|
|
157
|
+
parameters: this.recursiveStrictToolCallParameters(tool.parameters),
|
|
160
158
|
strict: true
|
|
161
159
|
}));
|
|
162
160
|
console.debug(`Converted ${tools.length} tools for Response API:`, converted.map(t => t.name));
|
|
163
161
|
return converted;
|
|
164
162
|
}
|
|
165
163
|
|
|
164
|
+
recursiveStrictToolCallParameters(schema: ToolRequestParameters): FunctionTool['parameters'] {
|
|
165
|
+
return recursiveStrictJSONSchema(schema) as FunctionTool['parameters'];
|
|
166
|
+
}
|
|
167
|
+
|
|
166
168
|
protected createSimpleResponseApiStreamIterator(
|
|
167
169
|
stream: AsyncIterable<ResponseStreamEvent>,
|
|
168
170
|
requestId: string,
|
|
@@ -427,7 +429,6 @@ class ResponseApiToolCallIterator implements AsyncIterableIterator<LanguageModel
|
|
|
427
429
|
if (this.cancellationToken?.isCancellationRequested) {
|
|
428
430
|
break;
|
|
429
431
|
}
|
|
430
|
-
|
|
431
432
|
await this.handleStreamEvent(event);
|
|
432
433
|
}
|
|
433
434
|
} else {
|
|
@@ -799,3 +800,50 @@ export function processSystemMessages(
|
|
|
799
800
|
}
|
|
800
801
|
return messages;
|
|
801
802
|
}
|
|
803
|
+
|
|
804
|
+
export function recursiveStrictJSONSchema(schema: JSONSchemaDefinition): JSONSchemaDefinition {
|
|
805
|
+
if (typeof schema === 'boolean') { return schema; }
|
|
806
|
+
let result: JSONSchema | undefined = undefined;
|
|
807
|
+
if (schema.properties) {
|
|
808
|
+
result ??= { ...schema };
|
|
809
|
+
result.additionalProperties = false;
|
|
810
|
+
result.required = Object.keys(schema.properties);
|
|
811
|
+
result.properties = Object.fromEntries(Object.entries(schema.properties).map(([key, props]) => [key, recursiveStrictJSONSchema(props)]));
|
|
812
|
+
}
|
|
813
|
+
if (schema.items) {
|
|
814
|
+
result ??= { ...schema };
|
|
815
|
+
result.items = Array.isArray(schema.items)
|
|
816
|
+
? schema.items.map(recursiveStrictJSONSchema)
|
|
817
|
+
: recursiveStrictJSONSchema(schema.items);
|
|
818
|
+
}
|
|
819
|
+
if (schema.oneOf) {
|
|
820
|
+
result ??= { ...schema };
|
|
821
|
+
result.oneOf = schema.oneOf.map(recursiveStrictJSONSchema);
|
|
822
|
+
}
|
|
823
|
+
if (schema.anyOf) {
|
|
824
|
+
result ??= { ...schema };
|
|
825
|
+
result.anyOf = schema.anyOf.map(recursiveStrictJSONSchema);
|
|
826
|
+
}
|
|
827
|
+
if (schema.allOf) {
|
|
828
|
+
result ??= { ...schema };
|
|
829
|
+
result.allOf = schema.allOf.map(recursiveStrictJSONSchema);
|
|
830
|
+
}
|
|
831
|
+
if (schema.if) {
|
|
832
|
+
result ??= { ...schema };
|
|
833
|
+
result.if = recursiveStrictJSONSchema(schema.if);
|
|
834
|
+
}
|
|
835
|
+
if (schema.then) {
|
|
836
|
+
result ??= { ...schema };
|
|
837
|
+
result.then = recursiveStrictJSONSchema(schema.then);
|
|
838
|
+
}
|
|
839
|
+
if (schema.else) {
|
|
840
|
+
result ??= { ...schema };
|
|
841
|
+
result.else = recursiveStrictJSONSchema(schema.else);
|
|
842
|
+
}
|
|
843
|
+
if (schema.not) {
|
|
844
|
+
result ??= { ...schema };
|
|
845
|
+
result.not = recursiveStrictJSONSchema(schema.not);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
return result ?? schema;
|
|
849
|
+
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
2
|
-
import { OpenAiLanguageModelsManager, OpenAiModelDescription } from '../common';
|
|
3
|
-
import { AICorePreferences } from '@theia/ai-core/lib/common/ai-core-preferences';
|
|
4
|
-
import { PreferenceService } from '@theia/core';
|
|
5
|
-
export declare class OpenAiFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
6
|
-
protected preferenceService: PreferenceService;
|
|
7
|
-
protected manager: OpenAiLanguageModelsManager;
|
|
8
|
-
protected aiCorePreferences: AICorePreferences;
|
|
9
|
-
protected prevModels: string[];
|
|
10
|
-
protected prevCustomModels: Partial<OpenAiModelDescription>[];
|
|
11
|
-
onStart(): void;
|
|
12
|
-
protected handleModelChanges(newModels: string[]): void;
|
|
13
|
-
protected handleCustomModelChanges(newCustomModels: Partial<OpenAiModelDescription>[]): void;
|
|
14
|
-
protected updateAllModels(): void;
|
|
15
|
-
protected createOpenAIModelDescription(modelId: string): OpenAiModelDescription;
|
|
16
|
-
protected createCustomModelDescriptionsFromPreferences(preferences: Partial<OpenAiModelDescription>[]): OpenAiModelDescription[];
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=openai-frontend-application-contribution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAsB,MAAM,WAAW,CAAC;AAEpG,OAAO,EAAE,iBAAiB,EAA+B,MAAM,+CAA+C,CAAC;AAC/G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,qBACa,qCAAsC,YAAW,+BAA+B;IAGzF,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAG/C,SAAS,CAAC,OAAO,EAAE,2BAA2B,CAAC;IAG/C,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,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;IAuCf,SAAS,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAYvD,SAAS,CAAC,wBAAwB,CAAC,eAAe,EAAE,OAAO,CAAC,sBAAsB,CAAC,EAAE,GAAG,IAAI;IAuB5F,SAAS,CAAC,eAAe,IAAI,IAAI;IAQjC,SAAS,CAAC,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB;IAiB/E,SAAS,CAAC,4CAA4C,CAClD,WAAW,EAAE,OAAO,CAAC,sBAAsB,CAAC,EAAE,GAC/C,sBAAsB,EAAE;CAyB9B"}
|
|
@@ -1,163 +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.OpenAiFrontendApplicationContribution = 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 openai_preferences_1 = require("../common/openai-preferences");
|
|
23
|
-
const ai_core_preferences_1 = require("@theia/ai-core/lib/common/ai-core-preferences");
|
|
24
|
-
const core_1 = require("@theia/core");
|
|
25
|
-
let OpenAiFrontendApplicationContribution = class OpenAiFrontendApplicationContribution {
|
|
26
|
-
constructor() {
|
|
27
|
-
this.prevModels = [];
|
|
28
|
-
this.prevCustomModels = [];
|
|
29
|
-
}
|
|
30
|
-
onStart() {
|
|
31
|
-
this.preferenceService.ready.then(() => {
|
|
32
|
-
const apiKey = this.preferenceService.get(openai_preferences_1.API_KEY_PREF, undefined);
|
|
33
|
-
this.manager.setApiKey(apiKey);
|
|
34
|
-
const proxyUri = this.preferenceService.get('http.proxy', undefined);
|
|
35
|
-
this.manager.setProxyUrl(proxyUri);
|
|
36
|
-
const models = this.preferenceService.get(openai_preferences_1.MODELS_PREF, []);
|
|
37
|
-
this.manager.createOrUpdateLanguageModels(...models.map(modelId => this.createOpenAIModelDescription(modelId)));
|
|
38
|
-
this.prevModels = [...models];
|
|
39
|
-
const customModels = this.preferenceService.get(openai_preferences_1.CUSTOM_ENDPOINTS_PREF, []);
|
|
40
|
-
this.manager.createOrUpdateLanguageModels(...this.createCustomModelDescriptionsFromPreferences(customModels));
|
|
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
|
-
this.updateAllModels();
|
|
46
|
-
}
|
|
47
|
-
else if (event.preferenceName === openai_preferences_1.MODELS_PREF) {
|
|
48
|
-
this.handleModelChanges(event.newValue);
|
|
49
|
-
}
|
|
50
|
-
else if (event.preferenceName === openai_preferences_1.CUSTOM_ENDPOINTS_PREF) {
|
|
51
|
-
this.handleCustomModelChanges(event.newValue);
|
|
52
|
-
}
|
|
53
|
-
else if (event.preferenceName === openai_preferences_1.USE_RESPONSE_API_PREF) {
|
|
54
|
-
this.updateAllModels();
|
|
55
|
-
}
|
|
56
|
-
else if (event.preferenceName === 'http.proxy') {
|
|
57
|
-
this.manager.setProxyUrl(event.newValue);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
this.aiCorePreferences.onPreferenceChanged(event => {
|
|
61
|
-
if (event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_MAX_RETRIES) {
|
|
62
|
-
this.updateAllModels();
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
handleModelChanges(newModels) {
|
|
68
|
-
const oldModels = new Set(this.prevModels);
|
|
69
|
-
const updatedModels = new Set(newModels);
|
|
70
|
-
const modelsToRemove = [...oldModels].filter(model => !updatedModels.has(model));
|
|
71
|
-
const modelsToAdd = [...updatedModels].filter(model => !oldModels.has(model));
|
|
72
|
-
this.manager.removeLanguageModels(...modelsToRemove.map(model => `openai/${model}`));
|
|
73
|
-
this.manager.createOrUpdateLanguageModels(...modelsToAdd.map(modelId => this.createOpenAIModelDescription(modelId)));
|
|
74
|
-
this.prevModels = newModels;
|
|
75
|
-
}
|
|
76
|
-
handleCustomModelChanges(newCustomModels) {
|
|
77
|
-
const oldModels = this.createCustomModelDescriptionsFromPreferences(this.prevCustomModels);
|
|
78
|
-
const newModels = this.createCustomModelDescriptionsFromPreferences(newCustomModels);
|
|
79
|
-
const modelsToRemove = oldModels.filter(model => !newModels.some(newModel => newModel.id === model.id));
|
|
80
|
-
const modelsToAddOrUpdate = newModels.filter(newModel => !oldModels.some(model => model.id === newModel.id &&
|
|
81
|
-
model.model === newModel.model &&
|
|
82
|
-
model.url === newModel.url &&
|
|
83
|
-
model.deployment === newModel.deployment &&
|
|
84
|
-
model.apiKey === newModel.apiKey &&
|
|
85
|
-
model.apiVersion === newModel.apiVersion &&
|
|
86
|
-
model.developerMessageSettings === newModel.developerMessageSettings &&
|
|
87
|
-
model.supportsStructuredOutput === newModel.supportsStructuredOutput &&
|
|
88
|
-
model.enableStreaming === newModel.enableStreaming &&
|
|
89
|
-
model.useResponseApi === newModel.useResponseApi));
|
|
90
|
-
this.manager.removeLanguageModels(...modelsToRemove.map(model => model.id));
|
|
91
|
-
this.manager.createOrUpdateLanguageModels(...modelsToAddOrUpdate);
|
|
92
|
-
this.prevCustomModels = [...newCustomModels];
|
|
93
|
-
}
|
|
94
|
-
updateAllModels() {
|
|
95
|
-
const models = this.preferenceService.get(openai_preferences_1.MODELS_PREF, []);
|
|
96
|
-
this.manager.createOrUpdateLanguageModels(...models.map(modelId => this.createOpenAIModelDescription(modelId)));
|
|
97
|
-
const customModels = this.preferenceService.get(openai_preferences_1.CUSTOM_ENDPOINTS_PREF, []);
|
|
98
|
-
this.manager.createOrUpdateLanguageModels(...this.createCustomModelDescriptionsFromPreferences(customModels));
|
|
99
|
-
}
|
|
100
|
-
createOpenAIModelDescription(modelId) {
|
|
101
|
-
var _a;
|
|
102
|
-
const id = `${common_1.OPENAI_PROVIDER_ID}/${modelId}`;
|
|
103
|
-
const maxRetries = (_a = this.aiCorePreferences.get(ai_core_preferences_1.PREFERENCE_NAME_MAX_RETRIES)) !== null && _a !== void 0 ? _a : 3;
|
|
104
|
-
const useResponseApi = this.preferenceService.get(openai_preferences_1.USE_RESPONSE_API_PREF, false);
|
|
105
|
-
return {
|
|
106
|
-
id: id,
|
|
107
|
-
model: modelId,
|
|
108
|
-
apiKey: true,
|
|
109
|
-
apiVersion: true,
|
|
110
|
-
developerMessageSettings: openAIModelsNotSupportingDeveloperMessages.includes(modelId) ? 'user' : 'developer',
|
|
111
|
-
enableStreaming: !openAIModelsWithDisabledStreaming.includes(modelId),
|
|
112
|
-
supportsStructuredOutput: !openAIModelsWithoutStructuredOutput.includes(modelId),
|
|
113
|
-
maxRetries: maxRetries,
|
|
114
|
-
useResponseApi: useResponseApi
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
createCustomModelDescriptionsFromPreferences(preferences) {
|
|
118
|
-
var _a;
|
|
119
|
-
const maxRetries = (_a = this.aiCorePreferences.get(ai_core_preferences_1.PREFERENCE_NAME_MAX_RETRIES)) !== null && _a !== void 0 ? _a : 3;
|
|
120
|
-
return preferences.reduce((acc, pref) => {
|
|
121
|
-
var _a, _b, _c, _d, _e;
|
|
122
|
-
if (!pref.model || !pref.url || typeof pref.model !== 'string' || typeof pref.url !== 'string') {
|
|
123
|
-
return acc;
|
|
124
|
-
}
|
|
125
|
-
return [
|
|
126
|
-
...acc,
|
|
127
|
-
{
|
|
128
|
-
id: pref.id && typeof pref.id === 'string' ? pref.id : pref.model,
|
|
129
|
-
model: pref.model,
|
|
130
|
-
url: pref.url,
|
|
131
|
-
deployment: typeof pref.deployment === 'string' && pref.deployment ? pref.deployment : undefined,
|
|
132
|
-
apiKey: typeof pref.apiKey === 'string' || pref.apiKey === true ? pref.apiKey : undefined,
|
|
133
|
-
apiVersion: typeof pref.apiVersion === 'string' || pref.apiVersion === true ? pref.apiVersion : undefined,
|
|
134
|
-
developerMessageSettings: (_a = pref.developerMessageSettings) !== null && _a !== void 0 ? _a : 'developer',
|
|
135
|
-
supportsStructuredOutput: (_b = pref.supportsStructuredOutput) !== null && _b !== void 0 ? _b : true,
|
|
136
|
-
enableStreaming: (_c = pref.enableStreaming) !== null && _c !== void 0 ? _c : true,
|
|
137
|
-
maxRetries: (_d = pref.maxRetries) !== null && _d !== void 0 ? _d : maxRetries,
|
|
138
|
-
useResponseApi: (_e = pref.useResponseApi) !== null && _e !== void 0 ? _e : false
|
|
139
|
-
}
|
|
140
|
-
];
|
|
141
|
-
}, []);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
exports.OpenAiFrontendApplicationContribution = OpenAiFrontendApplicationContribution;
|
|
145
|
-
tslib_1.__decorate([
|
|
146
|
-
(0, inversify_1.inject)(core_1.PreferenceService),
|
|
147
|
-
tslib_1.__metadata("design:type", Object)
|
|
148
|
-
], OpenAiFrontendApplicationContribution.prototype, "preferenceService", void 0);
|
|
149
|
-
tslib_1.__decorate([
|
|
150
|
-
(0, inversify_1.inject)(common_1.OpenAiLanguageModelsManager),
|
|
151
|
-
tslib_1.__metadata("design:type", Object)
|
|
152
|
-
], OpenAiFrontendApplicationContribution.prototype, "manager", void 0);
|
|
153
|
-
tslib_1.__decorate([
|
|
154
|
-
(0, inversify_1.inject)(ai_core_preferences_1.AICorePreferences),
|
|
155
|
-
tslib_1.__metadata("design:type", Object)
|
|
156
|
-
], OpenAiFrontendApplicationContribution.prototype, "aiCorePreferences", void 0);
|
|
157
|
-
exports.OpenAiFrontendApplicationContribution = OpenAiFrontendApplicationContribution = tslib_1.__decorate([
|
|
158
|
-
(0, inversify_1.injectable)()
|
|
159
|
-
], OpenAiFrontendApplicationContribution);
|
|
160
|
-
const openAIModelsWithDisabledStreaming = [];
|
|
161
|
-
const openAIModelsNotSupportingDeveloperMessages = ['o1-preview', 'o1-mini'];
|
|
162
|
-
const openAIModelsWithoutStructuredOutput = ['o1-preview', 'gpt-4-turbo', 'gpt-4', 'gpt-3.5-turbo', 'o1-mini', 'gpt-4o-2024-05-13'];
|
|
163
|
-
//# sourceMappingURL=openai-frontend-application-contribution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;AAGhF,4DAAkE;AAClE,sCAAoG;AACpG,qEAAuH;AACvH,uFAA+G;AAC/G,sCAAgD;AAGzC,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAA3C;QAWO,eAAU,GAAa,EAAE,CAAC;QAC1B,qBAAgB,GAAsC,EAAE,CAAC;IAgIvE,CAAC;IA9HG,OAAO;QACH,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAS,iCAAY,EAAE,SAAS,CAAC,CAAC;YAC3E,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAE/B,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAS,YAAY,EAAE,SAAS,CAAC,CAAC;YAC7E,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAEnC,MAAM,MAAM,GAAG,IAAI,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A,IAAI,CAAC,UAAU,mCAAI,UAAU;oBACzC,cAAc,EAAE,MAAA,IAAI,CAAC,cAAc,mCAAI,KAAK;iBAC/C;aACJ,CAAC;QACN,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC;CACJ,CAAA;AA5IY,sFAAqC;AAGpC;IADT,IAAA,kBAAM,EAAC,wBAAiB,CAAC;;gFACqB;AAGrC;IADT,IAAA,kBAAM,EAAC,oCAA2B,CAAC;;sEACW;AAGrC;IADT,IAAA,kBAAM,EAAC,uCAAiB,CAAC;;gFACqB;gDATtC,qCAAqC;IADjD,IAAA,sBAAU,GAAE;GACA,qCAAqC,CA4IjD;AAED,MAAM,iCAAiC,GAAa,EAAE,CAAC;AACvD,MAAM,0CAA0C,GAAG,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAC7E,MAAM,mCAAmC,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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;;AAO/D,wBAQG"}
|
|
@@ -1,33 +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
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
19
|
-
const openai_preferences_1 = require("../common/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
|
-
const core_1 = require("@theia/core");
|
|
24
|
-
exports.default = new inversify_1.ContainerModule(bind => {
|
|
25
|
-
bind(core_1.PreferenceContribution).toConstantValue({ schema: openai_preferences_1.OpenAiPreferencesSchema });
|
|
26
|
-
bind(openai_frontend_application_contribution_1.OpenAiFrontendApplicationContribution).toSelf().inSingletonScope();
|
|
27
|
-
bind(browser_1.FrontendApplicationContribution).toService(openai_frontend_application_contribution_1.OpenAiFrontendApplicationContribution);
|
|
28
|
-
bind(common_1.OpenAiLanguageModelsManager).toDynamicValue(ctx => {
|
|
29
|
-
const provider = ctx.container.get(browser_1.RemoteConnectionProvider);
|
|
30
|
-
return provider.createProxy(common_1.OPENAI_LANGUAGE_MODELS_MANAGER_PATH);
|
|
31
|
-
}).inSingletonScope();
|
|
32
|
-
});
|
|
33
|
-
//# sourceMappingURL=openai-frontend-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,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 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
|
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,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"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export declare const OPENAI_LANGUAGE_MODELS_MANAGER_PATH = "/services/open-ai/language-model-manager";
|
|
2
|
-
export declare const OpenAiLanguageModelsManager: unique symbol;
|
|
3
|
-
export declare const OPENAI_PROVIDER_ID = "openai";
|
|
4
|
-
export interface OpenAiModelDescription {
|
|
5
|
-
/**
|
|
6
|
-
* The identifier of the model which will be shown in the UI.
|
|
7
|
-
*/
|
|
8
|
-
id: string;
|
|
9
|
-
/**
|
|
10
|
-
* The model ID as used by the OpenAI API.
|
|
11
|
-
*/
|
|
12
|
-
model: string;
|
|
13
|
-
/**
|
|
14
|
-
* The OpenAI API compatible endpoint where the model is hosted. If not provided the default OpenAI endpoint will be used.
|
|
15
|
-
*/
|
|
16
|
-
url?: string;
|
|
17
|
-
/**
|
|
18
|
-
* The key for the model. If 'true' is provided the global OpenAI API key will be used.
|
|
19
|
-
*/
|
|
20
|
-
apiKey: string | true | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* The version for the api. If 'true' is provided the global OpenAI version will be used.
|
|
23
|
-
*/
|
|
24
|
-
apiVersion: string | true | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Optional deployment name for Azure OpenAI.
|
|
27
|
-
*/
|
|
28
|
-
deployment?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Indicate whether the streaming API shall be used.
|
|
31
|
-
*/
|
|
32
|
-
enableStreaming: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Property to configure the developer message of the model. Setting this property to 'user', 'system', or 'developer' will use that string as the role for the system message.
|
|
35
|
-
* Setting it to 'mergeWithFollowingUserMessage' will prefix the following user message with the system message or convert the system message to user if the following message
|
|
36
|
-
* is not a user message. 'skip' will remove the system message altogether.
|
|
37
|
-
* Defaults to 'developer'.
|
|
38
|
-
*/
|
|
39
|
-
developerMessageSettings?: 'user' | 'system' | 'developer' | 'mergeWithFollowingUserMessage' | 'skip';
|
|
40
|
-
/**
|
|
41
|
-
* Flag to configure whether the OpenAPI model supports structured output. Default is `true`.
|
|
42
|
-
*/
|
|
43
|
-
supportsStructuredOutput: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Maximum number of retry attempts when a request fails. Default is 3.
|
|
46
|
-
*/
|
|
47
|
-
maxRetries: number;
|
|
48
|
-
/**
|
|
49
|
-
* Flag to configure whether to use the newer OpenAI Response API instead of the Chat Completion API.
|
|
50
|
-
* For official OpenAI models, this defaults to `true`. For custom providers, users must explicitly enable it.
|
|
51
|
-
* Default is `false` for custom models.
|
|
52
|
-
*/
|
|
53
|
-
useResponseApi?: boolean;
|
|
54
|
-
}
|
|
55
|
-
export interface OpenAiLanguageModelsManager {
|
|
56
|
-
apiKey: string | undefined;
|
|
57
|
-
setApiKey(key: string | undefined): void;
|
|
58
|
-
setApiVersion(version: string | undefined): void;
|
|
59
|
-
setProxyUrl(proxyUrl: string | undefined): void;
|
|
60
|
-
createOrUpdateLanguageModels(...models: OpenAiModelDescription[]): Promise<void>;
|
|
61
|
-
removeLanguageModels(...modelIds: string[]): void;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=openai-language-models-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAEjF,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,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,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACtC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,+BAA+B,GAAG,MAAM,CAAC;IACtG;;OAEG;IACH,wBAAwB,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AACD,MAAM,WAAW,2BAA2B;IACxC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACzC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACjD,W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