@theia/ai-openai 1.67.0-next.56 → 1.67.0-next.59
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/lib/browser/openai-frontend-application-contribution.d.ts +18 -0
- package/lib/browser/openai-frontend-application-contribution.d.ts.map +1 -0
- package/lib/browser/openai-frontend-application-contribution.js +163 -0
- package/lib/browser/openai-frontend-application-contribution.js.map +1 -0
- package/lib/browser/openai-frontend-module.d.ts +4 -0
- package/lib/browser/openai-frontend-module.d.ts.map +1 -0
- package/lib/browser/openai-frontend-module.js +33 -0
- package/lib/browser/openai-frontend-module.js.map +1 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +20 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/openai-language-models-manager.d.ts +63 -0
- package/lib/common/openai-language-models-manager.d.ts.map +1 -0
- package/lib/common/openai-language-models-manager.js +22 -0
- package/lib/common/openai-language-models-manager.js.map +1 -0
- package/lib/common/openai-preferences.d.ts +7 -0
- package/lib/common/openai-preferences.d.ts.map +1 -0
- package/lib/common/openai-preferences.js +141 -0
- package/lib/common/openai-preferences.js.map +1 -0
- package/lib/node/openai-backend-module.d.ts +5 -0
- package/lib/node/openai-backend-module.d.ts.map +1 -0
- package/lib/node/openai-backend-module.js +40 -0
- package/lib/node/openai-backend-module.js.map +1 -0
- package/lib/node/openai-language-model.d.ts +80 -0
- package/lib/node/openai-language-model.d.ts.map +1 -0
- package/lib/node/openai-language-model.js +324 -0
- package/lib/node/openai-language-model.js.map +1 -0
- package/lib/node/openai-language-models-manager-impl.d.ts +22 -0
- package/lib/node/openai-language-models-manager-impl.d.ts.map +1 -0
- package/lib/node/openai-language-models-manager-impl.js +162 -0
- package/lib/node/openai-language-models-manager-impl.js.map +1 -0
- package/lib/node/openai-model-utils.spec.d.ts +2 -0
- package/lib/node/openai-model-utils.spec.d.ts.map +1 -0
- package/lib/node/openai-model-utils.spec.js +467 -0
- package/lib/node/openai-model-utils.spec.js.map +1 -0
- package/lib/node/openai-request-api-context.d.ts +4 -0
- package/lib/node/openai-request-api-context.d.ts.map +1 -0
- package/lib/node/openai-request-api-context.js +18 -0
- package/lib/node/openai-request-api-context.js.map +1 -0
- package/lib/node/openai-response-api-utils.d.ts +45 -0
- package/lib/node/openai-response-api-utils.d.ts.map +1 -0
- package/lib/node/openai-response-api-utils.js +724 -0
- package/lib/node/openai-response-api-utils.js.map +1 -0
- package/lib/node/openai-streaming-iterator.d.ts +24 -0
- package/lib/node/openai-streaming-iterator.d.ts.map +1 -0
- package/lib/node/openai-streaming-iterator.js +176 -0
- package/lib/node/openai-streaming-iterator.js.map +1 -0
- package/lib/node/openai-streaming-iterator.spec.d.ts +2 -0
- package/lib/node/openai-streaming-iterator.spec.d.ts.map +1 -0
- package/lib/node/openai-streaming-iterator.spec.js +207 -0
- package/lib/node/openai-streaming-iterator.spec.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// *****************************************************************************
|
|
4
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
5
|
+
//
|
|
6
|
+
// This program and the accompanying materials are made available under the
|
|
7
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
8
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
9
|
+
//
|
|
10
|
+
// This Source Code may also be made available under the following Secondary
|
|
11
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
12
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
13
|
+
// with the GNU Classpath Exception which is available at
|
|
14
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
15
|
+
//
|
|
16
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
17
|
+
// *****************************************************************************
|
|
18
|
+
const chai_1 = require("chai");
|
|
19
|
+
const openai_language_model_1 = require("./openai-language-model");
|
|
20
|
+
const openai_response_api_utils_1 = require("./openai-response-api-utils");
|
|
21
|
+
const utils = new openai_language_model_1.OpenAiModelUtils();
|
|
22
|
+
const responseUtils = new openai_response_api_utils_1.OpenAiResponseApiUtils();
|
|
23
|
+
describe('OpenAiModelUtils - processMessages', () => {
|
|
24
|
+
describe("when developerMessageSettings is 'skip'", () => {
|
|
25
|
+
it('should remove all system messages', () => {
|
|
26
|
+
const messages = [
|
|
27
|
+
{ actor: 'system', type: 'text', text: 'system message' },
|
|
28
|
+
{ actor: 'user', type: 'text', text: 'user message' },
|
|
29
|
+
{ actor: 'system', type: 'text', text: 'another system message' },
|
|
30
|
+
];
|
|
31
|
+
const result = utils.processMessages(messages, 'skip', 'gpt-4');
|
|
32
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
33
|
+
{ role: 'user', content: 'user message' }
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
it('should do nothing if there is no system message', () => {
|
|
37
|
+
const messages = [
|
|
38
|
+
{ actor: 'user', type: 'text', text: 'user message' },
|
|
39
|
+
{ actor: 'user', type: 'text', text: 'another user message' },
|
|
40
|
+
{ actor: 'ai', type: 'text', text: 'ai message' }
|
|
41
|
+
];
|
|
42
|
+
const result = utils.processMessages(messages, 'skip', 'gpt-4');
|
|
43
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
44
|
+
{ role: 'user', content: 'user message' },
|
|
45
|
+
{ role: 'user', content: 'another user message' },
|
|
46
|
+
{ role: 'assistant', content: 'ai message' }
|
|
47
|
+
]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe("when developerMessageSettings is 'mergeWithFollowingUserMessage'", () => {
|
|
51
|
+
it('should merge the system message with the next user message, assign role user, and remove the system message', () => {
|
|
52
|
+
const messages = [
|
|
53
|
+
{ actor: 'system', type: 'text', text: 'system msg' },
|
|
54
|
+
{ actor: 'user', type: 'text', text: 'user msg' },
|
|
55
|
+
{ actor: 'ai', type: 'text', text: 'ai message' }
|
|
56
|
+
];
|
|
57
|
+
const result = utils.processMessages(messages, 'mergeWithFollowingUserMessage', 'gpt-4');
|
|
58
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
59
|
+
{ role: 'user', content: 'system msg\nuser msg' },
|
|
60
|
+
{ role: 'assistant', content: 'ai message' }
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
it('should create a new user message if no user message exists, and remove the system message', () => {
|
|
64
|
+
const messages = [
|
|
65
|
+
{ actor: 'system', type: 'text', text: 'system only msg' },
|
|
66
|
+
{ actor: 'ai', type: 'text', text: 'ai message' }
|
|
67
|
+
];
|
|
68
|
+
const result = utils.processMessages(messages, 'mergeWithFollowingUserMessage', 'gpt-4');
|
|
69
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
70
|
+
{ role: 'user', content: 'system only msg' },
|
|
71
|
+
{ role: 'assistant', content: 'ai message' }
|
|
72
|
+
]);
|
|
73
|
+
});
|
|
74
|
+
it('should create a merge multiple system message with the next user message', () => {
|
|
75
|
+
const messages = [
|
|
76
|
+
{ actor: 'user', type: 'text', text: 'user message' },
|
|
77
|
+
{ actor: 'system', type: 'text', text: 'system message' },
|
|
78
|
+
{ actor: 'system', type: 'text', text: 'system message2' },
|
|
79
|
+
{ actor: 'user', type: 'text', text: 'user message2' },
|
|
80
|
+
{ actor: 'ai', type: 'text', text: 'ai message' }
|
|
81
|
+
];
|
|
82
|
+
const result = utils.processMessages(messages, 'mergeWithFollowingUserMessage', 'gpt-4');
|
|
83
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
84
|
+
{ role: 'user', content: 'user message' },
|
|
85
|
+
{ role: 'user', content: 'system message\nsystem message2\nuser message2' },
|
|
86
|
+
{ role: 'assistant', content: 'ai message' }
|
|
87
|
+
]);
|
|
88
|
+
});
|
|
89
|
+
it('should create a new user message from several system messages if the next message is not a user message', () => {
|
|
90
|
+
const messages = [
|
|
91
|
+
{ actor: 'user', type: 'text', text: 'user message' },
|
|
92
|
+
{ actor: 'system', type: 'text', text: 'system message' },
|
|
93
|
+
{ actor: 'system', type: 'text', text: 'system message2' },
|
|
94
|
+
{ actor: 'ai', type: 'text', text: 'ai message' }
|
|
95
|
+
];
|
|
96
|
+
const result = utils.processMessages(messages, 'mergeWithFollowingUserMessage', 'gpt-4');
|
|
97
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
98
|
+
{ role: 'user', content: 'user message' },
|
|
99
|
+
{ role: 'user', content: 'system message\nsystem message2' },
|
|
100
|
+
{ role: 'assistant', content: 'ai message' }
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
describe('when no special merging or skipping is needed', () => {
|
|
105
|
+
it('should leave messages unchanged in ordering and assign roles based on developerMessageSettings', () => {
|
|
106
|
+
const messages = [
|
|
107
|
+
{ actor: 'user', type: 'text', text: 'user message' },
|
|
108
|
+
{ actor: 'system', type: 'text', text: 'system message' },
|
|
109
|
+
{ actor: 'ai', type: 'text', text: 'ai message' }
|
|
110
|
+
];
|
|
111
|
+
// Using a developerMessageSettings that is not merge/skip, e.g., 'developer'
|
|
112
|
+
const result = utils.processMessages(messages, 'developer', 'gpt-4');
|
|
113
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
114
|
+
{ role: 'user', content: 'user message' },
|
|
115
|
+
{ role: 'developer', content: 'system message' },
|
|
116
|
+
{ role: 'assistant', content: 'ai message' }
|
|
117
|
+
]);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
describe('role assignment for system messages when developerMessageSettings is one of the role strings', () => {
|
|
121
|
+
it('should assign role as specified for a system message when developerMessageSettings is "user"', () => {
|
|
122
|
+
const messages = [
|
|
123
|
+
{ actor: 'system', type: 'text', text: 'system msg' },
|
|
124
|
+
{ actor: 'ai', type: 'text', text: 'ai msg' }
|
|
125
|
+
];
|
|
126
|
+
// Since the first message is system and developerMessageSettings is not merge/skip, ordering is not adjusted
|
|
127
|
+
const result = utils.processMessages(messages, 'user', 'gpt-4');
|
|
128
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
129
|
+
{ role: 'user', content: 'system msg' },
|
|
130
|
+
{ role: 'assistant', content: 'ai msg' }
|
|
131
|
+
]);
|
|
132
|
+
});
|
|
133
|
+
it('should assign role as specified for a system message when developerMessageSettings is "system"', () => {
|
|
134
|
+
const messages = [
|
|
135
|
+
{ actor: 'system', type: 'text', text: 'system msg' },
|
|
136
|
+
{ actor: 'ai', type: 'text', text: 'ai msg' }
|
|
137
|
+
];
|
|
138
|
+
const result = utils.processMessages(messages, 'system', 'gpt-4');
|
|
139
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
140
|
+
{ role: 'system', content: 'system msg' },
|
|
141
|
+
{ role: 'assistant', content: 'ai msg' }
|
|
142
|
+
]);
|
|
143
|
+
});
|
|
144
|
+
it('should assign role as specified for a system message when developerMessageSettings is "developer"', () => {
|
|
145
|
+
const messages = [
|
|
146
|
+
{ actor: 'system', type: 'text', text: 'system msg' },
|
|
147
|
+
{ actor: 'user', type: 'text', text: 'user msg' },
|
|
148
|
+
{ actor: 'ai', type: 'text', text: 'ai msg' }
|
|
149
|
+
];
|
|
150
|
+
const result = utils.processMessages(messages, 'developer', 'gpt-4');
|
|
151
|
+
(0, chai_1.expect)(result).to.deep.equal([
|
|
152
|
+
{ role: 'developer', content: 'system msg' },
|
|
153
|
+
{ role: 'user', content: 'user msg' },
|
|
154
|
+
{ role: 'assistant', content: 'ai msg' }
|
|
155
|
+
]);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
describe('OpenAiModelUtils - processMessagesForResponseApi', () => {
|
|
160
|
+
describe("when developerMessageSettings is 'skip'", () => {
|
|
161
|
+
it('should remove all system messages and return no instructions', () => {
|
|
162
|
+
const messages = [
|
|
163
|
+
{ actor: 'system', type: 'text', text: 'system message' },
|
|
164
|
+
{ actor: 'user', type: 'text', text: 'user message' },
|
|
165
|
+
{ actor: 'system', type: 'text', text: 'another system message' },
|
|
166
|
+
];
|
|
167
|
+
const result = responseUtils.processMessages(messages, 'skip', 'gpt-4');
|
|
168
|
+
(0, chai_1.expect)(result.instructions).to.be.undefined;
|
|
169
|
+
(0, chai_1.expect)(result.input).to.deep.equal([
|
|
170
|
+
{
|
|
171
|
+
type: 'message',
|
|
172
|
+
role: 'user',
|
|
173
|
+
content: [{ type: 'input_text', text: 'user message' }]
|
|
174
|
+
}
|
|
175
|
+
]);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
describe("when developerMessageSettings is 'mergeWithFollowingUserMessage'", () => {
|
|
179
|
+
it('should merge system message with user message and return no instructions', () => {
|
|
180
|
+
const messages = [
|
|
181
|
+
{ actor: 'system', type: 'text', text: 'system msg' },
|
|
182
|
+
{ actor: 'user', type: 'text', text: 'user msg' },
|
|
183
|
+
{ actor: 'ai', type: 'text', text: 'ai message' }
|
|
184
|
+
];
|
|
185
|
+
const result = responseUtils.processMessages(messages, 'mergeWithFollowingUserMessage', 'gpt-4');
|
|
186
|
+
(0, chai_1.expect)(result.instructions).to.be.undefined;
|
|
187
|
+
(0, chai_1.expect)(result.input).to.have.lengthOf(2);
|
|
188
|
+
(0, chai_1.expect)(result.input[0]).to.deep.equal({
|
|
189
|
+
type: 'message',
|
|
190
|
+
role: 'user',
|
|
191
|
+
content: [{ type: 'input_text', text: 'system msg\nuser msg' }]
|
|
192
|
+
});
|
|
193
|
+
const assistantMessage = result.input[1];
|
|
194
|
+
(0, chai_1.expect)(assistantMessage).to.deep.include({
|
|
195
|
+
type: 'message',
|
|
196
|
+
role: 'assistant',
|
|
197
|
+
status: 'completed',
|
|
198
|
+
content: [{ type: 'output_text', text: 'ai message', annotations: [] }]
|
|
199
|
+
});
|
|
200
|
+
if (assistantMessage.type === 'message' && 'id' in assistantMessage) {
|
|
201
|
+
(0, chai_1.expect)(assistantMessage.id).to.be.a('string').and.to.match(/^msg_/);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
throw new Error('Expected assistant message to have an id');
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
describe('when system messages should be converted to instructions', () => {
|
|
209
|
+
it('should extract system messages as instructions and convert other messages to input items', () => {
|
|
210
|
+
const messages = [
|
|
211
|
+
{ actor: 'system', type: 'text', text: 'You are a helpful assistant' },
|
|
212
|
+
{ actor: 'user', type: 'text', text: 'Hello!' },
|
|
213
|
+
{ actor: 'ai', type: 'text', text: 'Hi there!' }
|
|
214
|
+
];
|
|
215
|
+
const result = responseUtils.processMessages(messages, 'developer', 'gpt-4');
|
|
216
|
+
(0, chai_1.expect)(result.instructions).to.equal('You are a helpful assistant');
|
|
217
|
+
(0, chai_1.expect)(result.input).to.have.lengthOf(2);
|
|
218
|
+
(0, chai_1.expect)(result.input[0]).to.deep.equal({
|
|
219
|
+
type: 'message',
|
|
220
|
+
role: 'user',
|
|
221
|
+
content: [{ type: 'input_text', text: 'Hello!' }]
|
|
222
|
+
});
|
|
223
|
+
const assistantMessage = result.input[1];
|
|
224
|
+
(0, chai_1.expect)(assistantMessage).to.deep.include({
|
|
225
|
+
type: 'message',
|
|
226
|
+
role: 'assistant',
|
|
227
|
+
status: 'completed',
|
|
228
|
+
content: [{ type: 'output_text', text: 'Hi there!', annotations: [] }]
|
|
229
|
+
});
|
|
230
|
+
if (assistantMessage.type === 'message' && 'id' in assistantMessage) {
|
|
231
|
+
(0, chai_1.expect)(assistantMessage.id).to.be.a('string').and.to.match(/^msg_/);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
throw new Error('Expected assistant message to have an id');
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
it('should combine multiple system messages into instructions', () => {
|
|
238
|
+
const messages = [
|
|
239
|
+
{ actor: 'system', type: 'text', text: 'You are helpful' },
|
|
240
|
+
{ actor: 'system', type: 'text', text: 'Be concise' },
|
|
241
|
+
{ actor: 'user', type: 'text', text: 'What is 2+2?' }
|
|
242
|
+
];
|
|
243
|
+
const result = responseUtils.processMessages(messages, 'developer', 'gpt-4');
|
|
244
|
+
(0, chai_1.expect)(result.instructions).to.equal('You are helpful\nBe concise');
|
|
245
|
+
(0, chai_1.expect)(result.input).to.deep.equal([
|
|
246
|
+
{
|
|
247
|
+
type: 'message',
|
|
248
|
+
role: 'user',
|
|
249
|
+
content: [{ type: 'input_text', text: 'What is 2+2?' }]
|
|
250
|
+
}
|
|
251
|
+
]);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
describe('tool use and tool result messages', () => {
|
|
255
|
+
it('should convert tool use messages to function calls', () => {
|
|
256
|
+
const messages = [
|
|
257
|
+
{ actor: 'user', type: 'text', text: 'Calculate 2+2' },
|
|
258
|
+
{
|
|
259
|
+
actor: 'ai',
|
|
260
|
+
type: 'tool_use',
|
|
261
|
+
id: 'call_123',
|
|
262
|
+
name: 'calculator',
|
|
263
|
+
input: { expression: '2+2' }
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
const result = responseUtils.processMessages(messages, 'developer', 'gpt-4');
|
|
267
|
+
(0, chai_1.expect)(result.input).to.deep.equal([
|
|
268
|
+
{
|
|
269
|
+
type: 'message',
|
|
270
|
+
role: 'user',
|
|
271
|
+
content: [{ type: 'input_text', text: 'Calculate 2+2' }]
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
type: 'function_call',
|
|
275
|
+
call_id: 'call_123',
|
|
276
|
+
name: 'calculator',
|
|
277
|
+
arguments: '{"expression":"2+2"}'
|
|
278
|
+
}
|
|
279
|
+
]);
|
|
280
|
+
});
|
|
281
|
+
it('should convert tool result messages to function call outputs', () => {
|
|
282
|
+
const messages = [
|
|
283
|
+
{
|
|
284
|
+
actor: 'user',
|
|
285
|
+
type: 'tool_result',
|
|
286
|
+
name: 'calculator',
|
|
287
|
+
tool_use_id: 'call_123',
|
|
288
|
+
content: '4'
|
|
289
|
+
}
|
|
290
|
+
];
|
|
291
|
+
const result = responseUtils.processMessages(messages, 'developer', 'gpt-4');
|
|
292
|
+
(0, chai_1.expect)(result.input).to.deep.equal([
|
|
293
|
+
{
|
|
294
|
+
type: 'function_call_output',
|
|
295
|
+
call_id: 'call_123',
|
|
296
|
+
output: '4'
|
|
297
|
+
}
|
|
298
|
+
]);
|
|
299
|
+
});
|
|
300
|
+
it('should stringify non-string tool result content', () => {
|
|
301
|
+
const messages = [
|
|
302
|
+
{
|
|
303
|
+
actor: 'user',
|
|
304
|
+
type: 'tool_result',
|
|
305
|
+
name: 'data_processor',
|
|
306
|
+
tool_use_id: 'call_456',
|
|
307
|
+
content: { result: 'success', data: [1, 2, 3] }
|
|
308
|
+
}
|
|
309
|
+
];
|
|
310
|
+
const result = responseUtils.processMessages(messages, 'developer', 'gpt-4');
|
|
311
|
+
(0, chai_1.expect)(result.input).to.deep.equal([
|
|
312
|
+
{
|
|
313
|
+
type: 'function_call_output',
|
|
314
|
+
call_id: 'call_456',
|
|
315
|
+
output: '{"result":"success","data":[1,2,3]}'
|
|
316
|
+
}
|
|
317
|
+
]);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
describe('image messages', () => {
|
|
321
|
+
it('should convert base64 image messages to input image items', () => {
|
|
322
|
+
const messages = [
|
|
323
|
+
{
|
|
324
|
+
actor: 'user',
|
|
325
|
+
type: 'image',
|
|
326
|
+
image: {
|
|
327
|
+
mimeType: 'image/png',
|
|
328
|
+
base64data: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=='
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
];
|
|
332
|
+
const result = responseUtils.processMessages(messages, 'developer', 'gpt-4');
|
|
333
|
+
(0, chai_1.expect)(result.input).to.deep.equal([
|
|
334
|
+
{
|
|
335
|
+
type: 'message',
|
|
336
|
+
role: 'user',
|
|
337
|
+
content: [{
|
|
338
|
+
type: 'input_image',
|
|
339
|
+
detail: 'auto',
|
|
340
|
+
image_url: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=='
|
|
341
|
+
}]
|
|
342
|
+
}
|
|
343
|
+
]);
|
|
344
|
+
});
|
|
345
|
+
it('should convert URL image messages to input image items', () => {
|
|
346
|
+
const messages = [
|
|
347
|
+
{
|
|
348
|
+
actor: 'user',
|
|
349
|
+
type: 'image',
|
|
350
|
+
image: {
|
|
351
|
+
url: 'https://example.com/image.png'
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
];
|
|
355
|
+
const result = responseUtils.processMessages(messages, 'developer', 'gpt-4');
|
|
356
|
+
(0, chai_1.expect)(result.input).to.deep.equal([
|
|
357
|
+
{
|
|
358
|
+
type: 'message',
|
|
359
|
+
role: 'user',
|
|
360
|
+
content: [{
|
|
361
|
+
type: 'input_image',
|
|
362
|
+
detail: 'auto',
|
|
363
|
+
image_url: 'https://example.com/image.png'
|
|
364
|
+
}]
|
|
365
|
+
}
|
|
366
|
+
]);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
describe('error handling', () => {
|
|
370
|
+
it('should throw error for unknown message types', () => {
|
|
371
|
+
const invalidMessage = {
|
|
372
|
+
actor: 'user',
|
|
373
|
+
type: 'unknown_type',
|
|
374
|
+
someProperty: 'value'
|
|
375
|
+
};
|
|
376
|
+
const messages = [invalidMessage];
|
|
377
|
+
(0, chai_1.expect)(() => responseUtils.processMessages(messages, 'developer', 'gpt-4'))
|
|
378
|
+
.to.throw('unhandled case');
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
describe('recursiveStrictJSONSchema', () => {
|
|
382
|
+
it('should return the same object and not modify it when schema has no properties to strictify', () => {
|
|
383
|
+
const schema = { type: 'string', description: 'Simple string' };
|
|
384
|
+
const originalJson = JSON.stringify(schema);
|
|
385
|
+
const result = (0, openai_response_api_utils_1.recursiveStrictJSONSchema)(schema);
|
|
386
|
+
(0, chai_1.expect)(result).to.equal(schema);
|
|
387
|
+
(0, chai_1.expect)(JSON.stringify(schema)).to.equal(originalJson);
|
|
388
|
+
const resultObj = result;
|
|
389
|
+
(0, chai_1.expect)(resultObj).to.not.have.property('additionalProperties');
|
|
390
|
+
(0, chai_1.expect)(resultObj).to.not.have.property('required');
|
|
391
|
+
});
|
|
392
|
+
it('should not mutate original but return a new strictified schema when branching applies (properties/items)', () => {
|
|
393
|
+
var _a;
|
|
394
|
+
const original = {
|
|
395
|
+
type: 'object',
|
|
396
|
+
properties: {
|
|
397
|
+
path: { type: 'string' },
|
|
398
|
+
data: {
|
|
399
|
+
type: 'array',
|
|
400
|
+
items: {
|
|
401
|
+
type: 'object',
|
|
402
|
+
properties: {
|
|
403
|
+
a: { type: 'string' }
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
const originalClone = JSON.parse(JSON.stringify(original));
|
|
410
|
+
const resultDef = (0, openai_response_api_utils_1.recursiveStrictJSONSchema)(original);
|
|
411
|
+
const result = resultDef;
|
|
412
|
+
(0, chai_1.expect)(result).to.not.equal(original);
|
|
413
|
+
(0, chai_1.expect)(original).to.deep.equal(originalClone);
|
|
414
|
+
(0, chai_1.expect)(result.additionalProperties).to.equal(false);
|
|
415
|
+
(0, chai_1.expect)(result.required).to.have.members(['path', 'data']);
|
|
416
|
+
const itemsDef = ((_a = result.properties) === null || _a === void 0 ? void 0 : _a.data).items;
|
|
417
|
+
(0, chai_1.expect)(itemsDef).to.be.ok;
|
|
418
|
+
const itemsObj = itemsDef;
|
|
419
|
+
(0, chai_1.expect)(itemsObj.additionalProperties).to.equal(false);
|
|
420
|
+
(0, chai_1.expect)(itemsObj.required).to.have.members(['a']);
|
|
421
|
+
const originalItems = (original.properties.data.items);
|
|
422
|
+
(0, chai_1.expect)(originalItems).to.not.have.property('additionalProperties');
|
|
423
|
+
(0, chai_1.expect)(originalItems).to.not.have.property('required');
|
|
424
|
+
});
|
|
425
|
+
it('should strictify nested parameters schema and not mutate the original', () => {
|
|
426
|
+
const replacementProperties = {
|
|
427
|
+
oldContent: { type: 'string', description: 'The exact content to be replaced. Must match exactly, including whitespace, comments, etc.' },
|
|
428
|
+
newContent: { type: 'string', description: 'The new content to insert in place of matched old content.' },
|
|
429
|
+
multiple: { type: 'boolean', description: 'Set to true if multiple occurrences of the oldContent are expected to be replaced.' }
|
|
430
|
+
};
|
|
431
|
+
const parameters = {
|
|
432
|
+
type: 'object',
|
|
433
|
+
properties: {
|
|
434
|
+
path: { type: 'string', description: 'The path of the file where content will be replaced.' },
|
|
435
|
+
replacements: {
|
|
436
|
+
type: 'array',
|
|
437
|
+
items: {
|
|
438
|
+
type: 'object',
|
|
439
|
+
properties: replacementProperties,
|
|
440
|
+
required: ['oldContent', 'newContent']
|
|
441
|
+
},
|
|
442
|
+
description: 'An array of replacement objects, each containing oldContent and newContent strings.'
|
|
443
|
+
},
|
|
444
|
+
reset: {
|
|
445
|
+
type: 'boolean',
|
|
446
|
+
description: 'Set to true to clear any existing pending changes for this file and start fresh. Default is false, which merges with existing changes.'
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
required: ['path', 'replacements']
|
|
450
|
+
};
|
|
451
|
+
const originalClone = JSON.parse(JSON.stringify(parameters));
|
|
452
|
+
const strictifiedDef = (0, openai_response_api_utils_1.recursiveStrictJSONSchema)(parameters);
|
|
453
|
+
const strictified = strictifiedDef;
|
|
454
|
+
(0, chai_1.expect)(strictified).to.not.equal(parameters);
|
|
455
|
+
(0, chai_1.expect)(parameters).to.deep.equal(originalClone);
|
|
456
|
+
(0, chai_1.expect)(strictified.additionalProperties).to.equal(false);
|
|
457
|
+
(0, chai_1.expect)(strictified.required).to.have.members(['path', 'replacements', 'reset']);
|
|
458
|
+
const items = strictified.properties.replacements.items;
|
|
459
|
+
(0, chai_1.expect)(items.additionalProperties).to.equal(false);
|
|
460
|
+
(0, chai_1.expect)(items.required).to.have.members(['oldContent', 'newContent', 'multiple']);
|
|
461
|
+
const origItems = (parameters.properties.replacements.items);
|
|
462
|
+
(0, chai_1.expect)(origItems.required).to.deep.equal(['oldContent', 'newContent']);
|
|
463
|
+
(0, chai_1.expect)(origItems).to.not.have.property('additionalProperties');
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
//# sourceMappingURL=openai-model-utils.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-model-utils.spec.js","sourceRoot":"","sources":["../../src/node/openai-model-utils.spec.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,+BAA8B;AAC9B,mEAA2D;AAE3D,2EAAgG;AAGhG,MAAM,KAAK,GAAG,IAAI,wCAAgB,EAAE,CAAC;AACrC,MAAM,aAAa,GAAG,IAAI,kDAAsB,EAAE,CAAC;AAEnD,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAChD,QAAQ,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACrD,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YACzC,MAAM,QAAQ,GAA2B;gBACrC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE;gBACzD,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE;gBACrD,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,EAAE;aACpE,CAAC;YACF,MAAM,MAAM,GAAG,KAAK,CAAC,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K,CAAC,CAAC;YACzD,IAAA,aAAM,EAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;YAEhF,MAAM,KAAK,GAAI,WAAW,CAAC,UAAW,CAAC,YAA2B,CAAC,KAAmB,CAAC;YACvF,IAAA,aAAM,EAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACnD,IAAA,aAAM,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;YAEjF,MAAM,SAAS,GAAG,CAAE,UAAU,CAAC,UAAW,CAAC,YAA2B,CAAC,KAAK,CAAe,CAAC;YAC5F,IAAA,aAAM,EAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;YACvE,IAAA,aAAM,EAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-request-api-context.d.ts","sourceRoot":"","sources":["../../src/node/openai-request-api-context.ts"],"names":[],"mappings":"AAgBA,UAAU,uBAAuB;IAC7B,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAEpC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
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
|
+
// export class OpenAIRequestApiContext {
|
|
17
|
+
// }
|
|
18
|
+
//# sourceMappingURL=openai-request-api-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-request-api-context.js","sourceRoot":"","sources":["../../src/node/openai-request-api-context.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;AAOhF,yCAAyC;AACzC,IAAI"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LanguageModelMessage, LanguageModelResponse, LanguageModelStreamResponsePart, TokenUsageService, ToolRequest, ToolRequestParameters, UserRequest } from '@theia/ai-core';
|
|
2
|
+
import { CancellationToken } from '@theia/core';
|
|
3
|
+
import { OpenAI } from 'openai';
|
|
4
|
+
import type { RunnerOptions } from 'openai/lib/AbstractChatCompletionRunner';
|
|
5
|
+
import type { FunctionTool, ResponseInputItem, ResponseStreamEvent } from 'openai/resources/responses/responses';
|
|
6
|
+
import { DeveloperMessageSettings, OpenAiModelUtils } from './openai-language-model';
|
|
7
|
+
import { JSONSchemaDefinition } from 'openai/lib/jsonschema';
|
|
8
|
+
/**
|
|
9
|
+
* Utility class for handling OpenAI Response API requests and tool calling cycles.
|
|
10
|
+
*
|
|
11
|
+
* This class encapsulates the complexity of the Response API's multi-turn conversation
|
|
12
|
+
* patterns for tool calling, keeping the main language model class clean and focused.
|
|
13
|
+
*/
|
|
14
|
+
export declare class OpenAiResponseApiUtils {
|
|
15
|
+
/**
|
|
16
|
+
* Handles Response API requests with proper tool calling cycles.
|
|
17
|
+
* Works for both streaming and non-streaming cases.
|
|
18
|
+
*/
|
|
19
|
+
handleRequest(openai: OpenAI, request: UserRequest, settings: Record<string, unknown>, model: string, modelUtils: OpenAiModelUtils, developerMessageSettings: DeveloperMessageSettings, runnerOptions: RunnerOptions, modelId: string, isStreaming: boolean, tokenUsageService?: TokenUsageService, cancellationToken?: CancellationToken): Promise<LanguageModelResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Converts ToolRequest objects to the format expected by the Response API.
|
|
22
|
+
*/
|
|
23
|
+
convertToolsForResponseApi(tools?: ToolRequest[]): FunctionTool[] | undefined;
|
|
24
|
+
recursiveStrictToolCallParameters(schema: ToolRequestParameters): FunctionTool['parameters'];
|
|
25
|
+
protected createSimpleResponseApiStreamIterator(stream: AsyncIterable<ResponseStreamEvent>, requestId: string, modelId: string, tokenUsageService?: TokenUsageService, cancellationToken?: CancellationToken): AsyncIterable<LanguageModelStreamResponsePart>;
|
|
26
|
+
/**
|
|
27
|
+
* Processes the provided list of messages by applying system message adjustments and converting
|
|
28
|
+
* them directly to the format expected by the OpenAI Response API.
|
|
29
|
+
*
|
|
30
|
+
* This method converts messages directly without going through ChatCompletionMessageParam types.
|
|
31
|
+
*
|
|
32
|
+
* @param messages the list of messages to process.
|
|
33
|
+
* @param developerMessageSettings how system and developer messages are handled during processing.
|
|
34
|
+
* @param model the OpenAI model identifier. Currently not used, but allows subclasses to implement model-specific behavior.
|
|
35
|
+
* @returns an object containing instructions and input formatted for the Response API.
|
|
36
|
+
*/
|
|
37
|
+
processMessages(messages: LanguageModelMessage[], developerMessageSettings: DeveloperMessageSettings, model: string): {
|
|
38
|
+
instructions?: string;
|
|
39
|
+
input: ResponseInputItem[];
|
|
40
|
+
};
|
|
41
|
+
protected processSystemMessages(messages: LanguageModelMessage[], developerMessageSettings: DeveloperMessageSettings): LanguageModelMessage[];
|
|
42
|
+
}
|
|
43
|
+
export declare function processSystemMessages(messages: LanguageModelMessage[], developerMessageSettings: DeveloperMessageSettings): LanguageModelMessage[];
|
|
44
|
+
export declare function recursiveStrictJSONSchema(schema: JSONSchemaDefinition): JSONSchemaDefinition;
|
|
45
|
+
//# sourceMappingURL=openai-response-api-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-response-api-utils.d.ts","sourceRoot":"","sources":["../../src/node/openai-response-api-utils.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEH,oBAAoB,EACpB,qBAAqB,EACrB,+BAA+B,EAE/B,iBAAiB,EAEjB,WAAW,EACX,qBAAqB,EACrB,WAAW,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAe,MAAM,aAAa,CAAC;AAG7D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,KAAK,EACR,YAAY,EAIZ,iBAAiB,EACjB,mBAAmB,EACtB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAc,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAYzE;;;;;GAKG;AACH,qBACa,sBAAsB;IAE/B;;;OAGG;IACG,aAAa,CACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,KAAK,EAAE,MAAM,EACb,UAAU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