@byline/ai 1.9.0 → 1.10.0
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/dist/@types.d.ts +0 -9
- package/dist/@types.d.ts.map +1 -1
- package/dist/@types.js +0 -10
- package/dist/@types.js.map +1 -1
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +13 -38
- package/dist/execute.js.map +1 -1
- package/dist/generate.d.ts +1 -2
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +53 -49
- package/dist/generate.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/logger.d.ts +2 -2
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +27 -5
- package/dist/lib/logger.js.map +1 -1
- package/dist/models/anthropic/generate.d.ts +51 -8
- package/dist/models/anthropic/generate.d.ts.map +1 -1
- package/dist/models/anthropic/generate.js +261 -18
- package/dist/models/anthropic/generate.js.map +1 -1
- package/dist/models/anthropic/generate.test.node.js +7 -56
- package/dist/models/anthropic/generate.test.node.js.map +1 -1
- package/dist/models/anthropic/patch.d.ts +25 -4
- package/dist/models/anthropic/patch.d.ts.map +1 -1
- package/dist/models/anthropic/patch.js +142 -6
- package/dist/models/anthropic/patch.js.map +1 -1
- package/dist/models/anthropic/patch.test.node.js +7 -57
- package/dist/models/anthropic/patch.test.node.js.map +1 -1
- package/dist/models/google/generate.d.ts +51 -8
- package/dist/models/google/generate.d.ts.map +1 -1
- package/dist/models/google/generate.js +235 -19
- package/dist/models/google/generate.js.map +1 -1
- package/dist/models/google/generate.test.node.js +8 -56
- package/dist/models/google/generate.test.node.js.map +1 -1
- package/dist/models/google/patch.d.ts +25 -4
- package/dist/models/google/patch.d.ts.map +1 -1
- package/dist/models/google/patch.js +154 -6
- package/dist/models/google/patch.js.map +1 -1
- package/dist/models/google/patch.test.node.js +7 -57
- package/dist/models/google/patch.test.node.js.map +1 -1
- package/dist/models/openai/generate.d.ts +57 -8
- package/dist/models/openai/generate.d.ts.map +1 -1
- package/dist/models/openai/generate.js +266 -18
- package/dist/models/openai/generate.js.map +1 -1
- package/dist/models/openai/generate.test.node.js +7 -56
- package/dist/models/openai/generate.test.node.js.map +1 -1
- package/dist/models/openai/patch.d.ts +25 -4
- package/dist/models/openai/patch.d.ts.map +1 -1
- package/dist/models/openai/patch.js +141 -6
- package/dist/models/openai/patch.js.map +1 -1
- package/dist/models/openai/patch.test.node.js +7 -57
- package/dist/models/openai/patch.test.node.js.map +1 -1
- package/dist/patch.d.ts +2 -3
- package/dist/patch.d.ts.map +1 -1
- package/dist/patch.js +18 -16
- package/dist/patch.js.map +1 -1
- package/dist/plugins/ai-plugin-base.d.ts +1 -2
- package/dist/plugins/ai-plugin-base.d.ts.map +1 -1
- package/dist/plugins/ai-plugin-base.js +5 -20
- package/dist/plugins/ai-plugin-base.js.map +1 -1
- package/dist/plugins/lexical/plugin.d.ts.map +1 -1
- package/dist/plugins/lexical/plugin.js +3 -5
- package/dist/plugins/lexical/plugin.js.map +1 -1
- package/dist/plugins/storage.d.ts +1 -2
- package/dist/plugins/storage.d.ts.map +1 -1
- package/dist/plugins/storage.js +2 -4
- package/dist/plugins/storage.js.map +1 -1
- package/dist/plugins/text/plugin.d.ts.map +1 -1
- package/dist/plugins/text/plugin.js +3 -5
- package/dist/plugins/text/plugin.js.map +1 -1
- package/dist/{models/anthropic/anthropic.d.ts → utils/has-text.test.node.d.ts} +2 -2
- package/dist/utils/has-text.test.node.d.ts.map +1 -0
- package/dist/utils/has-text.test.node.js +70 -0
- package/dist/utils/has-text.test.node.js.map +1 -0
- package/package.json +6 -14
- package/dist/models/anthropic/anthropic.d.ts.map +0 -1
- package/dist/models/anthropic/anthropic.js +0 -20
- package/dist/models/anthropic/anthropic.js.map +0 -1
- package/dist/models/anthropic/generate-native.d.ts +0 -59
- package/dist/models/anthropic/generate-native.d.ts.map +0 -1
- package/dist/models/anthropic/generate-native.js +0 -271
- package/dist/models/anthropic/generate-native.js.map +0 -1
- package/dist/models/anthropic/generate-vercel.d.ts +0 -59
- package/dist/models/anthropic/generate-vercel.d.ts.map +0 -1
- package/dist/models/anthropic/generate-vercel.js +0 -126
- package/dist/models/anthropic/generate-vercel.js.map +0 -1
- package/dist/models/anthropic/patch-native.d.ts +0 -33
- package/dist/models/anthropic/patch-native.d.ts.map +0 -1
- package/dist/models/anthropic/patch-native.js +0 -152
- package/dist/models/anthropic/patch-native.js.map +0 -1
- package/dist/models/anthropic/patch-vercel.d.ts +0 -33
- package/dist/models/anthropic/patch-vercel.d.ts.map +0 -1
- package/dist/models/anthropic/patch-vercel.js +0 -47
- package/dist/models/anthropic/patch-vercel.js.map +0 -1
- package/dist/models/google/generate-native.d.ts +0 -59
- package/dist/models/google/generate-native.d.ts.map +0 -1
- package/dist/models/google/generate-native.js +0 -244
- package/dist/models/google/generate-native.js.map +0 -1
- package/dist/models/google/generate-vercel.d.ts +0 -59
- package/dist/models/google/generate-vercel.d.ts.map +0 -1
- package/dist/models/google/generate-vercel.js +0 -133
- package/dist/models/google/generate-vercel.js.map +0 -1
- package/dist/models/google/patch-native.d.ts +0 -33
- package/dist/models/google/patch-native.d.ts.map +0 -1
- package/dist/models/google/patch-native.js +0 -164
- package/dist/models/google/patch-native.js.map +0 -1
- package/dist/models/google/patch-vercel.d.ts +0 -33
- package/dist/models/google/patch-vercel.d.ts.map +0 -1
- package/dist/models/google/patch-vercel.js +0 -49
- package/dist/models/google/patch-vercel.js.map +0 -1
- package/dist/models/openai/generate-native.d.ts +0 -65
- package/dist/models/openai/generate-native.d.ts.map +0 -1
- package/dist/models/openai/generate-native.js +0 -276
- package/dist/models/openai/generate-native.js.map +0 -1
- package/dist/models/openai/generate-vercel.d.ts +0 -59
- package/dist/models/openai/generate-vercel.d.ts.map +0 -1
- package/dist/models/openai/generate-vercel.js +0 -132
- package/dist/models/openai/generate-vercel.js.map +0 -1
- package/dist/models/openai/patch-native.d.ts +0 -33
- package/dist/models/openai/patch-native.d.ts.map +0 -1
- package/dist/models/openai/patch-native.js +0 -151
- package/dist/models/openai/patch-native.js.map +0 -1
- package/dist/models/openai/patch-vercel.d.ts +0 -33
- package/dist/models/openai/patch-vercel.d.ts.map +0 -1
- package/dist/models/openai/patch-vercel.js +0 -49
- package/dist/models/openai/patch-vercel.js.map +0 -1
|
@@ -5,24 +5,272 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import OpenAI from 'openai';
|
|
9
|
+
import { buildGenerateHtmlSystemPrompt, buildGenerateHtmlUserPrompt, buildGenerateSystemPrompt, buildGenerateTextSystemPrompt, buildGenerateTextUserPrompt, } from '../../prompts';
|
|
10
|
+
import { openaiGenerationSchema } from './schema';
|
|
11
|
+
export async function generateHtml(options) {
|
|
12
|
+
const client = new OpenAI({ apiKey: options.apiKey });
|
|
13
|
+
const result = await client.responses.create({
|
|
14
|
+
model: options.model,
|
|
15
|
+
input: [
|
|
16
|
+
{ role: 'system', content: buildGenerateHtmlSystemPrompt() },
|
|
17
|
+
{ role: 'user', content: buildGenerateHtmlUserPrompt(options.prompt) },
|
|
18
|
+
],
|
|
19
|
+
text: {
|
|
20
|
+
format: { type: 'text' },
|
|
21
|
+
},
|
|
22
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
23
|
+
const refusal = result?.output?.[0]?.content?.find((c) => c?.type === 'refusal')?.refusal;
|
|
24
|
+
if (typeof refusal === 'string' && refusal.length > 0) {
|
|
25
|
+
throw new Error(refusal);
|
|
26
|
+
}
|
|
27
|
+
const outputText = getOutputText(result);
|
|
28
|
+
if (typeof outputText === 'string' && outputText.trim().length > 0) {
|
|
29
|
+
return outputText.trim();
|
|
30
|
+
}
|
|
31
|
+
throw new Error('OpenAI did not return any HTML output.');
|
|
32
|
+
}
|
|
33
|
+
export function generateHtmlStreaming(options) {
|
|
34
|
+
const client = new OpenAI({ apiKey: options.apiKey });
|
|
35
|
+
const stream = client.responses.stream({
|
|
36
|
+
model: options.model,
|
|
37
|
+
input: [
|
|
38
|
+
{ role: 'system', content: buildGenerateHtmlSystemPrompt() },
|
|
39
|
+
{ role: 'user', content: buildGenerateHtmlUserPrompt(options.prompt) },
|
|
40
|
+
],
|
|
41
|
+
text: {
|
|
42
|
+
format: { type: 'text' },
|
|
43
|
+
},
|
|
44
|
+
stream: true,
|
|
45
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
46
|
+
const text = (async function* () {
|
|
47
|
+
for await (const event of stream) {
|
|
48
|
+
if (event.type === 'response.output_text.delta') {
|
|
49
|
+
yield event.delta;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
53
|
+
const final = (async () => {
|
|
54
|
+
const result = await stream.finalResponse();
|
|
55
|
+
const refusal = result?.output?.[0]?.content?.find((c) => c?.type === 'refusal')?.refusal;
|
|
56
|
+
if (typeof refusal === 'string' && refusal.length > 0) {
|
|
57
|
+
throw new Error(refusal);
|
|
58
|
+
}
|
|
59
|
+
const outputText = getOutputText(result);
|
|
60
|
+
if (typeof outputText === 'string' && outputText.trim().length > 0) {
|
|
61
|
+
return outputText.trim();
|
|
62
|
+
}
|
|
63
|
+
throw new Error('OpenAI did not return any HTML output.');
|
|
64
|
+
})();
|
|
65
|
+
return { text, final };
|
|
66
|
+
}
|
|
67
|
+
export async function generateText(options) {
|
|
68
|
+
const client = new OpenAI({ apiKey: options.apiKey });
|
|
69
|
+
const maxLength = typeof options.maxLength === 'number' && Number.isFinite(options.maxLength)
|
|
70
|
+
? Math.floor(options.maxLength)
|
|
71
|
+
: undefined;
|
|
72
|
+
const promptWithLength = typeof maxLength === 'number' && maxLength > 0
|
|
73
|
+
? `${options.prompt}\n\nConstraints:\n- Maximum length: ${maxLength} characters.`
|
|
74
|
+
: options.prompt;
|
|
75
|
+
const result = await client.responses.create({
|
|
76
|
+
model: options.model,
|
|
77
|
+
input: [
|
|
78
|
+
{ role: 'system', content: buildGenerateTextSystemPrompt() },
|
|
79
|
+
{ role: 'user', content: buildGenerateTextUserPrompt(promptWithLength) },
|
|
80
|
+
],
|
|
81
|
+
text: {
|
|
82
|
+
format: { type: 'text' },
|
|
83
|
+
},
|
|
84
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
85
|
+
const refusal = result?.output?.[0]?.content?.find((c) => c?.type === 'refusal')?.refusal;
|
|
86
|
+
if (typeof refusal === 'string' && refusal.length > 0) {
|
|
87
|
+
throw new Error(refusal);
|
|
88
|
+
}
|
|
89
|
+
const outputText = getOutputText(result);
|
|
90
|
+
if (typeof outputText !== 'string' || outputText.trim().length === 0) {
|
|
91
|
+
throw new Error('OpenAI did not return any plain text output.');
|
|
92
|
+
}
|
|
93
|
+
const normalized = outputText.trim();
|
|
94
|
+
if (typeof maxLength === 'number' && maxLength > 0) {
|
|
95
|
+
return normalized.length > maxLength ? normalized.slice(0, maxLength).trimEnd() : normalized;
|
|
96
|
+
}
|
|
97
|
+
return normalized;
|
|
98
|
+
}
|
|
99
|
+
export function generateTextStreaming(options) {
|
|
100
|
+
const client = new OpenAI({ apiKey: options.apiKey });
|
|
101
|
+
const maxLength = typeof options.maxLength === 'number' && Number.isFinite(options.maxLength)
|
|
102
|
+
? Math.floor(options.maxLength)
|
|
103
|
+
: undefined;
|
|
104
|
+
const promptWithLength = typeof maxLength === 'number' && maxLength > 0
|
|
105
|
+
? `${options.prompt}\n\nConstraints:\n- Maximum length: ${maxLength} characters.`
|
|
106
|
+
: options.prompt;
|
|
107
|
+
const stream = client.responses.stream({
|
|
108
|
+
model: options.model,
|
|
109
|
+
input: [
|
|
110
|
+
{ role: 'system', content: buildGenerateTextSystemPrompt() },
|
|
111
|
+
{ role: 'user', content: buildGenerateTextUserPrompt(promptWithLength) },
|
|
112
|
+
],
|
|
113
|
+
text: {
|
|
114
|
+
format: { type: 'text' },
|
|
115
|
+
},
|
|
116
|
+
stream: true,
|
|
117
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
118
|
+
const text = (async function* () {
|
|
119
|
+
let remaining = typeof maxLength === 'number' && maxLength > 0 ? maxLength : undefined;
|
|
120
|
+
for await (const event of stream) {
|
|
121
|
+
if (event.type !== 'response.output_text.delta') {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (typeof remaining === 'number') {
|
|
125
|
+
if (remaining <= 0) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const chunk = event.delta.slice(0, remaining);
|
|
129
|
+
remaining -= chunk.length;
|
|
130
|
+
if (chunk.length > 0) {
|
|
131
|
+
yield chunk;
|
|
132
|
+
}
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
yield event.delta;
|
|
136
|
+
}
|
|
137
|
+
})();
|
|
138
|
+
const final = (async () => {
|
|
139
|
+
const result = await stream.finalResponse();
|
|
140
|
+
const refusal = result?.output?.[0]?.content?.find((c) => c?.type === 'refusal')?.refusal;
|
|
141
|
+
if (typeof refusal === 'string' && refusal.length > 0) {
|
|
142
|
+
throw new Error(refusal);
|
|
143
|
+
}
|
|
144
|
+
const outputText = getOutputText(result);
|
|
145
|
+
if (typeof outputText !== 'string' || outputText.trim().length === 0) {
|
|
146
|
+
throw new Error('OpenAI did not return any plain text output.');
|
|
147
|
+
}
|
|
148
|
+
const normalized = outputText.trim();
|
|
149
|
+
if (typeof maxLength === 'number' && maxLength > 0) {
|
|
150
|
+
return normalized.length > maxLength ? normalized.slice(0, maxLength).trimEnd() : normalized;
|
|
151
|
+
}
|
|
152
|
+
return normalized;
|
|
153
|
+
})();
|
|
154
|
+
return { text, final };
|
|
155
|
+
}
|
|
156
|
+
const getOutputText = (result) => {
|
|
157
|
+
if (typeof result?.output_text === 'string') {
|
|
158
|
+
return result.output_text;
|
|
159
|
+
}
|
|
160
|
+
if (Array.isArray(result?.output)) {
|
|
161
|
+
const texts = [];
|
|
162
|
+
for (const output of result.output) {
|
|
163
|
+
if (output?.type !== 'message' || !Array.isArray(output?.content)) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
for (const content of output.content) {
|
|
167
|
+
if (content?.type === 'output_text' && typeof content?.text === 'string') {
|
|
168
|
+
texts.push(content.text);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (texts.length > 0) {
|
|
173
|
+
return texts.join('');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return undefined;
|
|
12
177
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
178
|
+
const parseGeneratedDoc = (result) => {
|
|
179
|
+
const parsed = result.output_parsed;
|
|
180
|
+
if (parsed && typeof parsed === 'object') {
|
|
181
|
+
return parsed;
|
|
182
|
+
}
|
|
183
|
+
const outputText = getOutputText(result);
|
|
184
|
+
if (typeof outputText === 'string' && outputText.trim().length > 0) {
|
|
185
|
+
try {
|
|
186
|
+
const json = JSON.parse(outputText);
|
|
187
|
+
if (json && typeof json === 'object') {
|
|
188
|
+
return json;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
// fall through to error below
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
throw new Error('OpenAI structured output did not return a parsed object.');
|
|
27
196
|
};
|
|
197
|
+
/***
|
|
198
|
+
* Generates a document from OpenAI using structured outputs.
|
|
199
|
+
*/
|
|
200
|
+
export async function generateDoc(options) {
|
|
201
|
+
const client = new OpenAI({ apiKey: options.apiKey });
|
|
202
|
+
// OpenAI Structured Outputs expects `text.format` to be a json_schema format.
|
|
203
|
+
// Our `openaiGenerationSchema` matches the OpenAI shape (name/strict/schema),
|
|
204
|
+
// but we add the required discriminator here.
|
|
205
|
+
const format = {
|
|
206
|
+
type: 'json_schema',
|
|
207
|
+
...openaiGenerationSchema,
|
|
208
|
+
};
|
|
209
|
+
const result = await client.responses.parse({
|
|
210
|
+
model: options.model,
|
|
211
|
+
input: [
|
|
212
|
+
{
|
|
213
|
+
role: 'system',
|
|
214
|
+
content: buildGenerateSystemPrompt(),
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
role: 'user',
|
|
218
|
+
content: options.prompt,
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
text: {
|
|
222
|
+
format,
|
|
223
|
+
},
|
|
224
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
225
|
+
// console.log(result.usage)
|
|
226
|
+
// If the model refused, the parsed output will be missing.
|
|
227
|
+
const refusal = result?.output?.[0]?.content?.find((c) => c?.type === 'refusal')?.refusal;
|
|
228
|
+
if (typeof refusal === 'string' && refusal.length > 0) {
|
|
229
|
+
throw new Error(refusal);
|
|
230
|
+
}
|
|
231
|
+
return parseGeneratedDoc(result);
|
|
232
|
+
}
|
|
233
|
+
/***
|
|
234
|
+
* Streams a document generation from OpenAI using structured outputs.
|
|
235
|
+
*/
|
|
236
|
+
export function generateDocStreaming(options) {
|
|
237
|
+
const client = new OpenAI({ apiKey: options.apiKey });
|
|
238
|
+
const format = {
|
|
239
|
+
type: 'json_schema',
|
|
240
|
+
...openaiGenerationSchema,
|
|
241
|
+
};
|
|
242
|
+
const stream = client.responses.stream({
|
|
243
|
+
model: options.model,
|
|
244
|
+
input: [
|
|
245
|
+
{
|
|
246
|
+
role: 'system',
|
|
247
|
+
content: buildGenerateSystemPrompt(),
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
role: 'user',
|
|
251
|
+
content: options.prompt,
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
text: {
|
|
255
|
+
format,
|
|
256
|
+
},
|
|
257
|
+
stream: true,
|
|
258
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
259
|
+
const text = (async function* () {
|
|
260
|
+
for await (const event of stream) {
|
|
261
|
+
if (event.type === 'response.output_text.delta') {
|
|
262
|
+
yield event.delta;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
})();
|
|
266
|
+
const final = (async () => {
|
|
267
|
+
const result = await stream.finalResponse();
|
|
268
|
+
const refusal = result?.output?.[0]?.content?.find((c) => c?.type === 'refusal')?.refusal;
|
|
269
|
+
if (typeof refusal === 'string' && refusal.length > 0) {
|
|
270
|
+
throw new Error(refusal);
|
|
271
|
+
}
|
|
272
|
+
return parseGeneratedDoc(result);
|
|
273
|
+
})();
|
|
274
|
+
return { text, final };
|
|
275
|
+
}
|
|
28
276
|
//# sourceMappingURL=generate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/models/openai/generate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,WAAW,IAAI,iBAAiB,EAChC,oBAAoB,IAAI,0BAA0B,EAClD,YAAY,IAAI,kBAAkB,EAClC,qBAAqB,IAAI,2BAA2B,EACpD,YAAY,IAAI,kBAAkB,EAClC,qBAAqB,IAAI,2BAA2B,GACrD,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,WAAW,IAAI,iBAAiB,EAChC,oBAAoB,IAAI,0BAA0B,EAClD,YAAY,IAAI,kBAAkB,EAClC,qBAAqB,IAAI,2BAA2B,EACpD,YAAY,IAAI,kBAAkB,EAClC,qBAAqB,IAAI,2BAA2B,GACrD,MAAM,mBAAmB,CAAA;AAG1B,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAQ,EAAE,EAAE;IACzC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAA;AACjE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAQ,EAAE,EAAE;IAClD,OAAO,G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MAAM,KAAK,GAAG,CAAC,KAAK,IAAI,EAAE;QACxB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAA;QAE3C,MAAM,OAAO,GAAI,MAAc,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CACzD,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,SAAS,CAClC,EAAE,OAAO,CAAA;QACV,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,CAAC;QAED,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC,CAAC,EAAE,CAAA;IAEJ,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AACxB,CAAC"}
|
|
@@ -7,39 +7,31 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
9
9
|
import { getAiServerConfig as getServerConfig } from '../../config/ai-config';
|
|
10
|
-
import { generateDoc
|
|
11
|
-
import { generateDocStreaming as generateDocStreamingVercel, generateDoc as generateDocVercel, } from './generate-vercel';
|
|
10
|
+
import { generateDoc, generateDocStreaming } from './generate';
|
|
12
11
|
const MODEL = 'gpt-5.2';
|
|
13
12
|
describe('openai generate', () => {
|
|
14
13
|
beforeEach(async () => { });
|
|
15
14
|
const runReal = process.env.AI_RUN_REAL_TESTS === 'true';
|
|
16
15
|
if (runReal) {
|
|
17
|
-
|
|
18
|
-
* Generates a document from OpenAI using structured outputs.
|
|
19
|
-
*/
|
|
20
|
-
it.skip('makes a real OpenAI request (manual run) from native provider', async () => {
|
|
16
|
+
it.skip('makes a real OpenAI request (manual run)', async () => {
|
|
21
17
|
const config = getServerConfig();
|
|
22
18
|
if (!config.ai.openai.apiKey) {
|
|
23
19
|
throw new Error('OPENAI_API_KEY is required for real OpenAI tests.');
|
|
24
20
|
}
|
|
25
|
-
const result = await
|
|
21
|
+
const result = await generateDoc({
|
|
26
22
|
apiKey: config.ai.openai.apiKey,
|
|
27
23
|
model: MODEL,
|
|
28
24
|
prompt: 'Create a haiku poem about a child by the sea.',
|
|
29
25
|
});
|
|
30
|
-
// console.log(result)
|
|
31
26
|
expect(result).toBeTruthy();
|
|
32
27
|
expect(typeof result).toBe('object');
|
|
33
28
|
}, 30000);
|
|
34
|
-
|
|
35
|
-
* Generates a document from OpenAI using structured outputs via streaming.
|
|
36
|
-
*/
|
|
37
|
-
it.skip('streams a real OpenAI response (manual run) from native provider', async () => {
|
|
29
|
+
it.skip('streams a real OpenAI response (manual run)', async () => {
|
|
38
30
|
const config = getServerConfig();
|
|
39
31
|
if (!config.ai.openai.apiKey) {
|
|
40
32
|
throw new Error('OPENAI_API_KEY is required for real OpenAI tests.');
|
|
41
33
|
}
|
|
42
|
-
const streamResult =
|
|
34
|
+
const streamResult = generateDocStreaming({
|
|
43
35
|
apiKey: config.ai.openai.apiKey,
|
|
44
36
|
model: MODEL,
|
|
45
37
|
prompt: 'Create a haiku poem about a child by the sea.',
|
|
@@ -47,51 +39,10 @@ describe('openai generate', () => {
|
|
|
47
39
|
let streamedText = '';
|
|
48
40
|
for await (const chunk of streamResult.text) {
|
|
49
41
|
streamedText += chunk;
|
|
50
|
-
console.log('STREAM CHUNK (OpenAI
|
|
42
|
+
console.log('STREAM CHUNK (OpenAI):', chunk);
|
|
51
43
|
}
|
|
52
44
|
const final = await streamResult.final;
|
|
53
|
-
console.log('FINAL RESULT (OpenAI
|
|
54
|
-
expect(streamedText.length).toBeGreaterThanOrEqual(0);
|
|
55
|
-
expect(final).toBeTruthy();
|
|
56
|
-
expect(typeof final).toBe('object');
|
|
57
|
-
}, 30000);
|
|
58
|
-
/***
|
|
59
|
-
* Generates a document from OpenAI using structured outputs.
|
|
60
|
-
*/
|
|
61
|
-
it.skip('makes a real OpenAI request (manual run) from vercel provider', async () => {
|
|
62
|
-
const config = getServerConfig();
|
|
63
|
-
if (!config.ai.openai.apiKey) {
|
|
64
|
-
throw new Error('OPENAI_API_KEY is required for real OpenAI tests.');
|
|
65
|
-
}
|
|
66
|
-
const result = await generateDocVercel({
|
|
67
|
-
apiKey: config.ai.openai.apiKey,
|
|
68
|
-
model: MODEL,
|
|
69
|
-
prompt: 'Create a haiku poem about a child by the sea.',
|
|
70
|
-
});
|
|
71
|
-
// console.log(result)
|
|
72
|
-
expect(result).toBeTruthy();
|
|
73
|
-
expect(typeof result).toBe('object');
|
|
74
|
-
}, 30000);
|
|
75
|
-
/***
|
|
76
|
-
* Generates a document from OpenAI using structured outputs via streaming.
|
|
77
|
-
*/
|
|
78
|
-
it.skip('streams a real OpenAI response (manual run) from vercel provider', async () => {
|
|
79
|
-
const config = getServerConfig();
|
|
80
|
-
if (!config.ai.openai.apiKey) {
|
|
81
|
-
throw new Error('OPENAI_API_KEY is required for real OpenAI tests.');
|
|
82
|
-
}
|
|
83
|
-
const streamResult = generateDocStreamingVercel({
|
|
84
|
-
apiKey: config.ai.openai.apiKey,
|
|
85
|
-
model: MODEL,
|
|
86
|
-
prompt: 'Create a haiku poem about a child by the sea.',
|
|
87
|
-
});
|
|
88
|
-
let streamedText = '';
|
|
89
|
-
for await (const chunk of streamResult.text) {
|
|
90
|
-
streamedText += chunk;
|
|
91
|
-
console.log('STREAM CHUNK (OpenAI Vercel):', chunk);
|
|
92
|
-
}
|
|
93
|
-
const final = await streamResult.final;
|
|
94
|
-
console.log('FINAL RESULT (OpenAI Vercel):', final);
|
|
45
|
+
console.log('FINAL RESULT (OpenAI):', final);
|
|
95
46
|
expect(streamedText.length).toBeGreaterThanOrEqual(0);
|
|
96
47
|
expect(final).toBeTruthy();
|
|
97
48
|
expect(typeof final).toBe('object');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.test.node.js","sourceRoot":"","sources":["../../../src/models/openai/generate.test.node.ts"],"names":[],"mappings":"AAA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E,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -5,8 +5,29 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import type { LexicalTextEditsResponse } from '../../utils/lexical-text-edits';
|
|
9
|
+
export type PatchDocStreamingResult = {
|
|
10
|
+
text: AsyncIterable<string>;
|
|
11
|
+
final: Promise<LexicalTextEditsResponse>;
|
|
12
|
+
};
|
|
13
|
+
export declare function patchDoc(options: {
|
|
14
|
+
apiKey: string;
|
|
15
|
+
model: string;
|
|
16
|
+
prompt: string;
|
|
17
|
+
textNodes: Array<{
|
|
18
|
+
id: number;
|
|
19
|
+
text: string;
|
|
20
|
+
}>;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
}): Promise<LexicalTextEditsResponse>;
|
|
23
|
+
export declare function patchDocStreaming(options: {
|
|
24
|
+
apiKey: string;
|
|
25
|
+
model: string;
|
|
26
|
+
prompt: string;
|
|
27
|
+
textNodes: Array<{
|
|
28
|
+
id: number;
|
|
29
|
+
text: string;
|
|
30
|
+
}>;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}): PatchDocStreamingResult;
|
|
12
33
|
//# sourceMappingURL=patch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../src/models/openai/patch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../src/models/openai/patch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAsC1E,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3B,KAAK,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAA;CACzC,CAAA;AAgDD,wBAAsB,QAAQ,CAAC,OAAO,EAAE;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAsCpC;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GAAG,uBAAuB,CAmD1B"}
|
|
@@ -5,12 +5,147 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
return
|
|
8
|
+
import OpenAI from 'openai';
|
|
9
|
+
import { buildPatchSystemPrompt } from '../../prompts';
|
|
10
|
+
const buildPatchUserPrompt = (instruction, textNodes) => {
|
|
11
|
+
return [
|
|
12
|
+
`INSTRUCTION: ${instruction}`,
|
|
13
|
+
'',
|
|
14
|
+
'INPUT_TEXT_NODES_JSON:',
|
|
15
|
+
JSON.stringify(textNodes),
|
|
16
|
+
].join('\n');
|
|
12
17
|
};
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
const openaiPatchSchema = {
|
|
19
|
+
name: 'lexical_text_edits_v1',
|
|
20
|
+
strict: true,
|
|
21
|
+
schema: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
properties: {
|
|
25
|
+
edits: {
|
|
26
|
+
type: 'array',
|
|
27
|
+
items: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
properties: {
|
|
31
|
+
id: { type: 'number' },
|
|
32
|
+
text: { type: 'string' },
|
|
33
|
+
},
|
|
34
|
+
required: ['id', 'text'],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ['edits'],
|
|
39
|
+
},
|
|
15
40
|
};
|
|
41
|
+
const getOutputText = (result) => {
|
|
42
|
+
if (typeof result?.output_text === 'string') {
|
|
43
|
+
return result.output_text;
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(result?.output)) {
|
|
46
|
+
const texts = [];
|
|
47
|
+
for (const output of result.output) {
|
|
48
|
+
if (output?.type !== 'message' || !Array.isArray(output?.content)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
for (const content of output.content) {
|
|
52
|
+
if (content?.type === 'output_text' && typeof content?.text === 'string') {
|
|
53
|
+
texts.push(content.text);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (texts.length > 0) {
|
|
58
|
+
return texts.join('');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
};
|
|
63
|
+
const parsePatchResponse = (result) => {
|
|
64
|
+
const parsed = result.output_parsed;
|
|
65
|
+
if (parsed && typeof parsed === 'object') {
|
|
66
|
+
return parsed;
|
|
67
|
+
}
|
|
68
|
+
const outputText = getOutputText(result);
|
|
69
|
+
if (typeof outputText === 'string' && outputText.trim().length > 0) {
|
|
70
|
+
try {
|
|
71
|
+
const json = JSON.parse(outputText);
|
|
72
|
+
if (json && typeof json === 'object') {
|
|
73
|
+
return json;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// fall through to error below
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
throw new Error('OpenAI structured output did not return a parsed object.');
|
|
81
|
+
};
|
|
82
|
+
export async function patchDoc(options) {
|
|
83
|
+
const client = new OpenAI({ apiKey: options.apiKey });
|
|
84
|
+
const format = {
|
|
85
|
+
type: 'json_schema',
|
|
86
|
+
...openaiPatchSchema,
|
|
87
|
+
};
|
|
88
|
+
const result = await client.responses.parse({
|
|
89
|
+
model: options.model,
|
|
90
|
+
input: [
|
|
91
|
+
{
|
|
92
|
+
role: 'system',
|
|
93
|
+
content: buildPatchSystemPrompt(),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
role: 'user',
|
|
97
|
+
content: buildPatchUserPrompt(options.prompt, options.textNodes),
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
text: {
|
|
101
|
+
format,
|
|
102
|
+
},
|
|
103
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
104
|
+
// console.log(result.usage)
|
|
105
|
+
const refusal = result?.output?.[0]?.content?.find((c) => c?.type === 'refusal')?.refusal;
|
|
106
|
+
if (typeof refusal === 'string' && refusal.length > 0) {
|
|
107
|
+
throw new Error(refusal);
|
|
108
|
+
}
|
|
109
|
+
return parsePatchResponse(result);
|
|
110
|
+
}
|
|
111
|
+
export function patchDocStreaming(options) {
|
|
112
|
+
const client = new OpenAI({ apiKey: options.apiKey });
|
|
113
|
+
const format = {
|
|
114
|
+
type: 'json_schema',
|
|
115
|
+
...openaiPatchSchema,
|
|
116
|
+
};
|
|
117
|
+
const stream = client.responses.stream({
|
|
118
|
+
model: options.model,
|
|
119
|
+
input: [
|
|
120
|
+
{
|
|
121
|
+
role: 'system',
|
|
122
|
+
content: buildPatchSystemPrompt(),
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
role: 'user',
|
|
126
|
+
content: buildPatchUserPrompt(options.prompt, options.textNodes),
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
text: {
|
|
130
|
+
format,
|
|
131
|
+
},
|
|
132
|
+
stream: true,
|
|
133
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
134
|
+
const text = (async function* () {
|
|
135
|
+
for await (const event of stream) {
|
|
136
|
+
if (event.type === 'response.output_text.delta') {
|
|
137
|
+
yield event.delta;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
})();
|
|
141
|
+
const final = (async () => {
|
|
142
|
+
const result = await stream.finalResponse();
|
|
143
|
+
const refusal = result?.output?.[0]?.content?.find((c) => c?.type === 'refusal')?.refusal;
|
|
144
|
+
if (typeof refusal === 'string' && refusal.length > 0) {
|
|
145
|
+
throw new Error(refusal);
|
|
146
|
+
}
|
|
147
|
+
return parsePatchResponse(result);
|
|
148
|
+
})();
|
|
149
|
+
return { text, final };
|
|
150
|
+
}
|
|
16
151
|
//# sourceMappingURL=patch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../src/models/openai/patch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../src/models/openai/patch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAGlD,MAAM,oBAAoB,GAAG,CAC3B,WAAmB,EACnB,SAA8C,EAC9C,EAAE;IACF,OAAO;QACL,gBAAgB,WAAW,EAAE;QAC7B,EAAE;QACF,wBAAwB;QACxB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;KAC1B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,uBAAuB;IAC7B,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,oBAAoB,EAAE,KAAK;QAC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