@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.
Files changed (57) hide show
  1. package/README.md +1 -0
  2. package/package.json +6 -6
  3. package/src/common/openai-preferences.ts +9 -12
  4. package/src/node/openai-model-utils.spec.ts +104 -1
  5. package/src/node/openai-response-api-utils.ts +54 -6
  6. package/lib/browser/openai-frontend-application-contribution.d.ts +0 -18
  7. package/lib/browser/openai-frontend-application-contribution.d.ts.map +0 -1
  8. package/lib/browser/openai-frontend-application-contribution.js +0 -163
  9. package/lib/browser/openai-frontend-application-contribution.js.map +0 -1
  10. package/lib/browser/openai-frontend-module.d.ts +0 -4
  11. package/lib/browser/openai-frontend-module.d.ts.map +0 -1
  12. package/lib/browser/openai-frontend-module.js +0 -33
  13. package/lib/browser/openai-frontend-module.js.map +0 -1
  14. package/lib/common/index.d.ts +0 -2
  15. package/lib/common/index.d.ts.map +0 -1
  16. package/lib/common/index.js +0 -20
  17. package/lib/common/index.js.map +0 -1
  18. package/lib/common/openai-language-models-manager.d.ts +0 -63
  19. package/lib/common/openai-language-models-manager.d.ts.map +0 -1
  20. package/lib/common/openai-language-models-manager.js +0 -22
  21. package/lib/common/openai-language-models-manager.js.map +0 -1
  22. package/lib/common/openai-preferences.d.ts +0 -7
  23. package/lib/common/openai-preferences.d.ts.map +0 -1
  24. package/lib/common/openai-preferences.js +0 -144
  25. package/lib/common/openai-preferences.js.map +0 -1
  26. package/lib/node/openai-backend-module.d.ts +0 -5
  27. package/lib/node/openai-backend-module.d.ts.map +0 -1
  28. package/lib/node/openai-backend-module.js +0 -40
  29. package/lib/node/openai-backend-module.js.map +0 -1
  30. package/lib/node/openai-language-model.d.ts +0 -80
  31. package/lib/node/openai-language-model.d.ts.map +0 -1
  32. package/lib/node/openai-language-model.js +0 -324
  33. package/lib/node/openai-language-model.js.map +0 -1
  34. package/lib/node/openai-language-models-manager-impl.d.ts +0 -22
  35. package/lib/node/openai-language-models-manager-impl.d.ts.map +0 -1
  36. package/lib/node/openai-language-models-manager-impl.js +0 -162
  37. package/lib/node/openai-language-models-manager-impl.js.map +0 -1
  38. package/lib/node/openai-model-utils.spec.d.ts +0 -2
  39. package/lib/node/openai-model-utils.spec.d.ts.map +0 -1
  40. package/lib/node/openai-model-utils.spec.js +0 -382
  41. package/lib/node/openai-model-utils.spec.js.map +0 -1
  42. package/lib/node/openai-request-api-context.d.ts +0 -4
  43. package/lib/node/openai-request-api-context.d.ts.map +0 -1
  44. package/lib/node/openai-request-api-context.js +0 -18
  45. package/lib/node/openai-request-api-context.js.map +0 -1
  46. package/lib/node/openai-response-api-utils.d.ts +0 -42
  47. package/lib/node/openai-response-api-utils.d.ts.map +0 -1
  48. package/lib/node/openai-response-api-utils.js +0 -677
  49. package/lib/node/openai-response-api-utils.js.map +0 -1
  50. package/lib/node/openai-streaming-iterator.d.ts +0 -24
  51. package/lib/node/openai-streaming-iterator.d.ts.map +0 -1
  52. package/lib/node/openai-streaming-iterator.js +0 -176
  53. package/lib/node/openai-streaming-iterator.js.map +0 -1
  54. package/lib/node/openai-streaming-iterator.spec.d.ts +0 -2
  55. package/lib/node/openai-streaming-iterator.spec.d.ts.map +0 -1
  56. package/lib/node/openai-streaming-iterator.spec.js +0 -207
  57. package/lib/node/openai-streaming-iterator.spec.js.map +0 -1
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OPENAI_PROVIDER_ID = exports.OpenAiLanguageModelsManager = exports.OPENAI_LANGUAGE_MODELS_MANAGER_PATH = void 0;
4
- // *****************************************************************************
5
- // Copyright (C) 2024 EclipseSource GmbH.
6
- //
7
- // This program and the accompanying materials are made available under the
8
- // terms of the Eclipse Public License v. 2.0 which is available at
9
- // http://www.eclipse.org/legal/epl-2.0.
10
- //
11
- // This Source Code may also be made available under the following Secondary
12
- // Licenses when the conditions for such availability set forth in the Eclipse
13
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
14
- // with the GNU Classpath Exception which is available at
15
- // https://www.gnu.org/software/classpath/license.html.
16
- //
17
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
18
- // *****************************************************************************
19
- exports.OPENAI_LANGUAGE_MODELS_MANAGER_PATH = '/services/open-ai/language-model-manager';
20
- exports.OpenAiLanguageModelsManager = Symbol('OpenAiLanguageModelsManager');
21
- exports.OPENAI_PROVIDER_ID = 'openai';
22
- //# sourceMappingURL=openai-language-models-manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai-language-models-manager.js","sourceRoot":"","sources":["../../src/common/openai-language-models-manager.ts"],"names":[],"mappings":";;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AACnE,QAAA,mCAAmC,GAAG,0CAA0C,CAAC;AACjF,QAAA,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAEpE,QAAA,kBAAkB,GAAG,QAAQ,CAAC"}
@@ -1,7 +0,0 @@
1
- import { PreferenceSchema } from '@theia/core';
2
- export declare const API_KEY_PREF = "ai-features.openAiOfficial.openAiApiKey";
3
- export declare const MODELS_PREF = "ai-features.openAiOfficial.officialOpenAiModels";
4
- export declare const USE_RESPONSE_API_PREF = "ai-features.openAiOfficial.useResponseApi";
5
- export declare const CUSTOM_ENDPOINTS_PREF = "ai-features.openAiCustom.customOpenAiModels";
6
- export declare const OpenAiPreferencesSchema: PreferenceSchema;
7
- //# sourceMappingURL=openai-preferences.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai-preferences.d.ts","sourceRoot":"","sources":["../../src/common/openai-preferences.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAO,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,YAAY,4CAA4C,CAAC;AACtE,eAAO,MAAM,WAAW,oDAAoD,CAAC;AAC7E,eAAO,MAAM,qBAAqB,8CAA8C,CAAC;AACjF,eAAO,MAAM,qBAAqB,gDAAgD,CAAC;AAEnF,eAAO,MAAM,uBAAuB,EAAE,gBAgIrC,CAAC"}
@@ -1,144 +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.OpenAiPreferencesSchema = exports.CUSTOM_ENDPOINTS_PREF = exports.USE_RESPONSE_API_PREF = exports.MODELS_PREF = exports.API_KEY_PREF = void 0;
19
- const ai_core_preferences_1 = require("@theia/ai-core/lib/common/ai-core-preferences");
20
- const core_1 = require("@theia/core");
21
- exports.API_KEY_PREF = 'ai-features.openAiOfficial.openAiApiKey';
22
- exports.MODELS_PREF = 'ai-features.openAiOfficial.officialOpenAiModels';
23
- exports.USE_RESPONSE_API_PREF = 'ai-features.openAiOfficial.useResponseApi';
24
- exports.CUSTOM_ENDPOINTS_PREF = 'ai-features.openAiCustom.customOpenAiModels';
25
- exports.OpenAiPreferencesSchema = {
26
- properties: {
27
- [exports.API_KEY_PREF]: {
28
- type: 'string',
29
- markdownDescription: core_1.nls.localize('theia/ai/openai/apiKey/mdDescription', 'Enter an API Key of your official OpenAI Account. **Please note:** By using this preference the Open AI API key will be stored in clear text \
30
- on the machine running Theia. Use the environment variable `OPENAI_API_KEY` to set the key securely.'),
31
- title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
32
- },
33
- [exports.MODELS_PREF]: {
34
- type: 'array',
35
- description: core_1.nls.localize('theia/ai/openai/models/description', 'Official OpenAI models to use'),
36
- title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
37
- default: [
38
- 'gpt-4o',
39
- 'gpt-4.1',
40
- 'gpt-4.1-nano',
41
- 'gpt-4.1-mini',
42
- 'gpt-4o-mini',
43
- 'o3',
44
- 'o3-mini',
45
- 'o4-mini',
46
- 'o4-mini-high',
47
- 'gpt-5',
48
- 'gpt-5-mini',
49
- 'gpt-5-nano'
50
- ],
51
- items: {
52
- type: 'string'
53
- }
54
- },
55
- [exports.USE_RESPONSE_API_PREF]: {
56
- type: 'boolean',
57
- default: false,
58
- title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
59
- markdownDescription: core_1.nls.localize('theia/ai/openai/useResponseApi/mdDescription', 'Use the newer OpenAI Response API instead of the Chat Completion API for official OpenAI models. \
60
- \
61
- This setting only applies to official OpenAI models - custom providers must configure this individually.')
62
- },
63
- [exports.CUSTOM_ENDPOINTS_PREF]: {
64
- type: 'array',
65
- title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
66
- markdownDescription: core_1.nls.localize('theia/ai/openai/customEndpoints/mdDescription', 'Integrate custom models compatible with the OpenAI API, for example via `vllm`. The required attributes are `model` and `url`.\
67
- \n\
68
- Optionally, you can\
69
- \n\
70
- - specify a unique `id` to identify the custom model in the UI. If none is given `model` will be used as `id`.\
71
- \n\
72
- - provide an `apiKey` to access the API served at the given url. Use `true` to indicate the use of the global OpenAI API key.\
73
- \n\
74
- - provide an `apiVersion` to access the API served at the given url in Azure. Use `true` to indicate the use of the global OpenAI API version.\
75
- \n\
76
- - provide a `deployment` name for your Azure deployment.\
77
- \n\
78
- - set `developerMessageSettings` to one of `user`, `system`, `developer`, `mergeWithFollowingUserMessage`, or `skip` to control how the developer message is\
79
- included (where `user`, `system`, and `developer` will be used as a role, `mergeWithFollowingUserMessage` will prefix the following user message with the system\
80
- message or convert the system message to user message if the next message is not a user message. `skip` will just remove the system message).\
81
- Defaulting to `developer`.\
82
- \n\
83
- - specify `supportsStructuredOutput: false` to indicate that structured output shall not be used.\
84
- \n\
85
- - specify `enableStreaming: false` to indicate that streaming shall not be used.\
86
- \n\
87
- - specify `useResponseApi: true` to use the newer OpenAI Response API instead of the Chat Completion API (requires compatible endpoint).\
88
- \n\
89
- Refer to [our documentation](https://theia-ide.org/docs/user_ai/#openai-compatible-models-eg-via-vllm) for more information.'),
90
- default: [],
91
- items: {
92
- type: 'object',
93
- properties: {
94
- model: {
95
- type: 'string',
96
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/modelId/title', 'Model ID')
97
- },
98
- url: {
99
- type: 'string',
100
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/url/title', 'The Open AI API compatible endpoint where the model is hosted')
101
- },
102
- id: {
103
- type: 'string',
104
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/id/title', 'A unique identifier which is used in the UI to identify the custom model'),
105
- },
106
- apiKey: {
107
- type: ['string', 'boolean'],
108
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/apiKey/title', 'Either the key to access the API served at the given url or `true` to use the global OpenAI API key'),
109
- },
110
- apiVersion: {
111
- type: ['string', 'boolean'],
112
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/apiVersion/title', 'Either the version to access the API served at the given url in Azure or `true` to use the global OpenAI API version'),
113
- },
114
- deployment: {
115
- type: 'string',
116
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/deployment/title', 'The deployment name to access the API served at the given url in Azure'),
117
- },
118
- developerMessageSettings: {
119
- type: 'string',
120
- enum: ['user', 'system', 'developer', 'mergeWithFollowingUserMessage', 'skip'],
121
- default: 'developer',
122
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/developerMessageSettings/title', 'Controls the handling of system messages: `user`, `system`, and `developer` will be used as a role, `mergeWithFollowingUserMessage` will prefix\
123
- the following user message with the system message or convert the system message to user message if the next message is not a user message.\
124
- `skip` will just remove the system message), defaulting to `developer`.')
125
- },
126
- supportsStructuredOutput: {
127
- type: 'boolean',
128
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/supportsStructuredOutput/title', 'Indicates whether the model supports structured output. `true` by default.'),
129
- },
130
- enableStreaming: {
131
- type: 'boolean',
132
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/enableStreaming/title', 'Indicates whether the streaming API shall be used. `true` by default.'),
133
- },
134
- useResponseApi: {
135
- type: 'boolean',
136
- title: core_1.nls.localize('theia/ai/openai/customEndpoints/useResponseApi/title', 'Use the newer OpenAI Response API instead of the Chat Completion API. `false` by default for custom providers.'
137
- + 'Note: Will automatically fall back to Chat Completions API when tools are used.'),
138
- }
139
- }
140
- }
141
- }
142
- }
143
- };
144
- //# sourceMappingURL=openai-preferences.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai-preferences.js","sourceRoot":"","sources":["../../src/common/openai-preferences.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,uFAA0F;AAC1F,sCAAoD;AAEvC,QAAA,YAAY,GAAG,yCAAyC,CAAC;AACzD,QAAA,WAAW,GAAG,iDAAiD,CAAC;AAChE,QAAA,qBAAqB,GAAG,2CAA2C,CAAC;AACpE,QAAA,qBAAqB,GAAG,6CAA6C,CAAC;AAEtE,QAAA,uBAAuB,GAAqB;IACrD,UAAU,EAAE;QACR,CAAC,oBAAY,CAAC,EAAE;YACZ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core/shared/inversify';
2
- export declare const OpenAiModelFactory: unique symbol;
3
- declare const _default: ContainerModule;
4
- export default _default;
5
- //# sourceMappingURL=openai-backend-module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/openai-backend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAS/D,eAAO,MAAM,kBAAkB,eAA+B,CAAC;;AAW/D,wBAKG"}
@@ -1,40 +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.OpenAiModelFactory = void 0;
19
- const inversify_1 = require("@theia/core/shared/inversify");
20
- const openai_language_models_manager_1 = require("../common/openai-language-models-manager");
21
- const core_1 = require("@theia/core");
22
- const openai_language_models_manager_impl_1 = require("./openai-language-models-manager-impl");
23
- const connection_container_module_1 = require("@theia/core/lib/node/messaging/connection-container-module");
24
- const openai_language_model_1 = require("./openai-language-model");
25
- const openai_response_api_utils_1 = require("./openai-response-api-utils");
26
- const openai_preferences_1 = require("../common/openai-preferences");
27
- exports.OpenAiModelFactory = Symbol('OpenAiModelFactory');
28
- // We use a connection module to handle AI services separately for each frontend.
29
- const openAiConnectionModule = connection_container_module_1.ConnectionContainerModule.create(({ bind, bindBackendService, bindFrontendService }) => {
30
- bind(openai_language_models_manager_impl_1.OpenAiLanguageModelsManagerImpl).toSelf().inSingletonScope();
31
- bind(openai_language_models_manager_1.OpenAiLanguageModelsManager).toService(openai_language_models_manager_impl_1.OpenAiLanguageModelsManagerImpl);
32
- bind(core_1.ConnectionHandler).toDynamicValue(ctx => new core_1.RpcConnectionHandler(openai_language_models_manager_1.OPENAI_LANGUAGE_MODELS_MANAGER_PATH, () => ctx.container.get(openai_language_models_manager_1.OpenAiLanguageModelsManager))).inSingletonScope();
33
- });
34
- exports.default = new inversify_1.ContainerModule(bind => {
35
- bind(core_1.PreferenceContribution).toConstantValue({ schema: openai_preferences_1.OpenAiPreferencesSchema });
36
- bind(openai_language_model_1.OpenAiModelUtils).toSelf().inSingletonScope();
37
- bind(openai_response_api_utils_1.OpenAiResponseApiUtils).toSelf().inSingletonScope();
38
- bind(connection_container_module_1.ConnectionContainerModule).toConstantValue(openAiConnectionModule);
39
- });
40
- //# sourceMappingURL=openai-backend-module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai-backend-module.js","sourceRoot":"","sources":["../../src/node/openai-backend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,4DAA+D;AAC/D,6FAA4H;AAC5H,sCAA8F;AAC9F,+FAAwF;AACxF,4GAAuG;AACvG,mEAA2D;AAC3D,2EAAqE;AACrE,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,wCAAgB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACnD,IAAI,CAAC,kDAAsB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACzD,IAAI,CAAC,uDAAyB,CAAC,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;AAC5E,CAAC,CAAC,CAAC"}
@@ -1,80 +0,0 @@
1
- import { LanguageModel, LanguageModelParsedResponse, LanguageModelRequest, LanguageModelMessage, LanguageModelResponse, LanguageModelTextResponse, TokenUsageService, UserRequest, LanguageModelStatus } from '@theia/ai-core';
2
- import { CancellationToken } from '@theia/core';
3
- import { OpenAI } from 'openai';
4
- import { RunnableToolFunctionWithoutParse } from 'openai/lib/RunnableFunction';
5
- import { ChatCompletionMessageParam } from 'openai/resources';
6
- import type { FinalRequestOptions } from 'openai/internal/request-options';
7
- import type { RunnerOptions } from 'openai/lib/AbstractChatCompletionRunner';
8
- import { OpenAiResponseApiUtils } from './openai-response-api-utils';
9
- export declare class MistralFixedOpenAI extends OpenAI {
10
- protected prepareOptions(options: FinalRequestOptions): Promise<void>;
11
- }
12
- export declare const OpenAiModelIdentifier: unique symbol;
13
- export type DeveloperMessageSettings = 'user' | 'system' | 'developer' | 'mergeWithFollowingUserMessage' | 'skip';
14
- export declare class OpenAiModel implements LanguageModel {
15
- readonly id: string;
16
- model: string;
17
- status: LanguageModelStatus;
18
- enableStreaming: boolean;
19
- apiKey: () => string | undefined;
20
- apiVersion: () => string | undefined;
21
- supportsStructuredOutput: boolean;
22
- url: string | undefined;
23
- deployment: string | undefined;
24
- openAiModelUtils: OpenAiModelUtils;
25
- responseApiUtils: OpenAiResponseApiUtils;
26
- developerMessageSettings: DeveloperMessageSettings;
27
- maxRetries: number;
28
- useResponseApi: boolean;
29
- protected readonly tokenUsageService?: TokenUsageService | undefined;
30
- protected proxy?: string | undefined;
31
- /**
32
- * The options for the OpenAI runner.
33
- */
34
- protected runnerOptions: RunnerOptions;
35
- /**
36
- * @param id the unique id for this language model. It will be used to identify the model in the UI.
37
- * @param model the model id as it is used by the OpenAI API
38
- * @param enableStreaming whether the streaming API shall be used
39
- * @param apiKey a function that returns the API key to use for this model, called on each request
40
- * @param apiVersion a function that returns the OpenAPI version to use for this model, called on each request
41
- * @param developerMessageSettings how to handle system messages
42
- * @param url the OpenAI API compatible endpoint where the model is hosted. If not provided the default OpenAI endpoint will be used.
43
- * @param maxRetries the maximum number of retry attempts when a request fails
44
- * @param useResponseApi whether to use the newer OpenAI Response API instead of the Chat Completion API
45
- */
46
- constructor(id: string, model: string, status: LanguageModelStatus, enableStreaming: boolean, apiKey: () => string | undefined, apiVersion: () => string | undefined, supportsStructuredOutput: boolean, url: string | undefined, deployment: string | undefined, openAiModelUtils: OpenAiModelUtils, responseApiUtils: OpenAiResponseApiUtils, developerMessageSettings?: DeveloperMessageSettings, maxRetries?: number, useResponseApi?: boolean, tokenUsageService?: TokenUsageService | undefined, proxy?: string | undefined);
47
- protected getSettings(request: LanguageModelRequest): Record<string, unknown>;
48
- request(request: UserRequest, cancellationToken?: CancellationToken): Promise<LanguageModelResponse>;
49
- protected handleChatCompletionsRequest(openai: OpenAI, request: UserRequest, cancellationToken?: CancellationToken): Promise<LanguageModelResponse>;
50
- protected handleNonStreamingRequest(openai: OpenAI, request: UserRequest): Promise<LanguageModelTextResponse>;
51
- protected isNonStreamingModel(_model: string): boolean;
52
- protected handleStructuredOutputRequest(openai: OpenAI, request: UserRequest): Promise<LanguageModelParsedResponse>;
53
- protected createTools(request: LanguageModelRequest): RunnableToolFunctionWithoutParse[] | undefined;
54
- protected initializeOpenAi(): OpenAI;
55
- protected handleResponseApiRequest(openai: OpenAI, request: UserRequest, cancellationToken?: CancellationToken): Promise<LanguageModelResponse>;
56
- protected processMessages(messages: LanguageModelMessage[]): ChatCompletionMessageParam[];
57
- }
58
- /**
59
- * Utility class for processing messages for the OpenAI language model.
60
- *
61
- * Adopters can rebind this class to implement custom message processing behavior.
62
- */
63
- export declare class OpenAiModelUtils {
64
- protected processSystemMessages(messages: LanguageModelMessage[], developerMessageSettings: DeveloperMessageSettings): LanguageModelMessage[];
65
- protected toOpenAiRole(message: LanguageModelMessage, developerMessageSettings: DeveloperMessageSettings): 'developer' | 'user' | 'assistant' | 'system';
66
- protected toOpenAIMessage(message: LanguageModelMessage, developerMessageSettings: DeveloperMessageSettings): ChatCompletionMessageParam;
67
- /**
68
- * Processes the provided list of messages by applying system message adjustments and converting
69
- * them to the format expected by the OpenAI API.
70
- *
71
- * Adopters can rebind this processing to implement custom behavior.
72
- *
73
- * @param messages the list of messages to process.
74
- * @param developerMessageSettings how system and developer messages are handled during processing.
75
- * @param model the OpenAI model identifier. Currently not used, but allows subclasses to implement model-specific behavior.
76
- * @returns an array of messages formatted for the OpenAI API.
77
- */
78
- processMessages(messages: LanguageModelMessage[], developerMessageSettings: DeveloperMessageSettings, model?: string): ChatCompletionMessageParam[];
79
- }
80
- //# sourceMappingURL=openai-language-model.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai-language-model.d.ts","sourceRoot":"","sources":["../../src/node/openai-language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