@byline/ai 1.9.0 → 1.9.1
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/package.json +4 -10
- package/dist/models/anthropic/anthropic.d.ts +0 -9
- 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,12 +5,148 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
return
|
|
8
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
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 isValidHttpUrl = (value) => {
|
|
19
|
+
if (value == null || value.trim().length === 0)
|
|
20
|
+
return false;
|
|
21
|
+
try {
|
|
22
|
+
const url = new URL(value);
|
|
23
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
15
28
|
};
|
|
29
|
+
const normalizeAnthropicBaseURLForSdk = (value) => {
|
|
30
|
+
const base = (value && value.trim().length > 0 ? value : 'https://api.anthropic.com')
|
|
31
|
+
.trim()
|
|
32
|
+
.replace(/\/+$/, '');
|
|
33
|
+
return base.endsWith('/v1') ? base.slice(0, -3) : base;
|
|
34
|
+
};
|
|
35
|
+
const anthropicPatchSchema = {
|
|
36
|
+
type: 'object',
|
|
37
|
+
additionalProperties: false,
|
|
38
|
+
properties: {
|
|
39
|
+
edits: {
|
|
40
|
+
type: 'array',
|
|
41
|
+
items: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
properties: {
|
|
45
|
+
id: { type: 'number' },
|
|
46
|
+
text: { type: 'string' },
|
|
47
|
+
},
|
|
48
|
+
required: ['id', 'text'],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ['edits'],
|
|
53
|
+
};
|
|
54
|
+
export async function patchDoc(options) {
|
|
55
|
+
const baseURL = isValidHttpUrl(process.env.ANTHROPIC_BASE_URL)
|
|
56
|
+
? normalizeAnthropicBaseURLForSdk(process.env.ANTHROPIC_BASE_URL)
|
|
57
|
+
: 'https://api.anthropic.com';
|
|
58
|
+
const client = new Anthropic({ apiKey: options.apiKey, baseURL });
|
|
59
|
+
const toolName = 'patch_lexical_text_nodes_v1';
|
|
60
|
+
const result = await client.messages.create({
|
|
61
|
+
model: options.model,
|
|
62
|
+
max_tokens: 4000,
|
|
63
|
+
system: buildPatchSystemPrompt(),
|
|
64
|
+
messages: [
|
|
65
|
+
{
|
|
66
|
+
role: 'user',
|
|
67
|
+
content: buildPatchUserPrompt(options.prompt, options.textNodes),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
tools: [
|
|
71
|
+
{
|
|
72
|
+
name: toolName,
|
|
73
|
+
description: 'Patch Lexical text nodes by returning edits as JSON.',
|
|
74
|
+
input_schema: anthropicPatchSchema,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
tool_choice: { type: 'tool', name: toolName },
|
|
78
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
79
|
+
const toolUse = (result.content ?? []).find((c) => c?.type === 'tool_use' && c?.name === toolName);
|
|
80
|
+
const parsed = toolUse?.input;
|
|
81
|
+
if (parsed && typeof parsed === 'object') {
|
|
82
|
+
return parsed;
|
|
83
|
+
}
|
|
84
|
+
const text = (result.content ?? [])
|
|
85
|
+
.filter((c) => c?.type === 'text')
|
|
86
|
+
.map((c) => c?.text)
|
|
87
|
+
.filter((t) => typeof t === 'string' && t.length > 0)
|
|
88
|
+
.join('\n');
|
|
89
|
+
throw new Error(text.length > 0
|
|
90
|
+
? `Anthropic did not return a tool payload. Text: ${text}`
|
|
91
|
+
: 'Anthropic did not return a tool payload.');
|
|
92
|
+
}
|
|
93
|
+
export function patchDocStreaming(options) {
|
|
94
|
+
const baseURL = isValidHttpUrl(process.env.ANTHROPIC_BASE_URL)
|
|
95
|
+
? normalizeAnthropicBaseURLForSdk(process.env.ANTHROPIC_BASE_URL)
|
|
96
|
+
: 'https://api.anthropic.com';
|
|
97
|
+
const client = new Anthropic({ apiKey: options.apiKey, baseURL });
|
|
98
|
+
const toolName = 'patch_lexical_text_nodes_v1';
|
|
99
|
+
const stream = client.messages.stream({
|
|
100
|
+
model: options.model,
|
|
101
|
+
max_tokens: 4000,
|
|
102
|
+
system: buildPatchSystemPrompt(),
|
|
103
|
+
messages: [
|
|
104
|
+
{
|
|
105
|
+
role: 'user',
|
|
106
|
+
content: buildPatchUserPrompt(options.prompt, options.textNodes),
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
tools: [
|
|
110
|
+
{
|
|
111
|
+
name: toolName,
|
|
112
|
+
description: 'Patch Lexical text nodes by returning edits as JSON.',
|
|
113
|
+
input_schema: anthropicPatchSchema,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
tool_choice: { type: 'tool', name: toolName },
|
|
117
|
+
stream: true,
|
|
118
|
+
}, options.signal ? { signal: options.signal } : undefined);
|
|
119
|
+
const text = (async function* () {
|
|
120
|
+
for await (const event of stream) {
|
|
121
|
+
if (event.type === 'content_block_delta') {
|
|
122
|
+
const deltaText = event?.delta?.text;
|
|
123
|
+
const deltaJson = event?.delta?.partial_json ??
|
|
124
|
+
event?.delta?.input_json_delta?.partial_json;
|
|
125
|
+
if (typeof deltaText === 'string' && deltaText.length > 0) {
|
|
126
|
+
yield deltaText;
|
|
127
|
+
}
|
|
128
|
+
else if (typeof deltaJson === 'string' && deltaJson.length > 0) {
|
|
129
|
+
yield deltaJson;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
})();
|
|
134
|
+
const final = (async () => {
|
|
135
|
+
const result = await stream.finalMessage();
|
|
136
|
+
const toolUse = (result.content ?? []).find((c) => c?.type === 'tool_use' && c?.name === toolName);
|
|
137
|
+
const parsed = toolUse?.input;
|
|
138
|
+
if (parsed && typeof parsed === 'object') {
|
|
139
|
+
return parsed;
|
|
140
|
+
}
|
|
141
|
+
const text = (result.content ?? [])
|
|
142
|
+
.filter((c) => c?.type === 'text')
|
|
143
|
+
.map((c) => c?.text)
|
|
144
|
+
.filter((t) => typeof t === 'string' && t.length > 0)
|
|
145
|
+
.join('\n');
|
|
146
|
+
throw new Error(text.length > 0
|
|
147
|
+
? `Anthropic did not return a tool payload. Text: ${text}`
|
|
148
|
+
: 'Anthropic did not return a tool payload.');
|
|
149
|
+
})();
|
|
150
|
+
return { text, final };
|
|
151
|
+
}
|
|
16
152
|
//# sourceMappingURL=patch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../src/models/anthropic/patch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../src/models/anthropic/patch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,SAAS,MAAM,mBAAmB,CAAA;AAEzC,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,cAAc,GAAG,CAAC,KAAyB,EAAmB,EAAE;IACpE,IAAI,KAAK,IAAI,IAAI,IAAI,K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I,KAAK,UAAU,IAAI,CAAC,EAAE,IAAI,KAAK,QAAQ,CACpD,CAAA;QAER,MAAM,MAAM,GAAG,OAAO,EAAE,KAA6C,CAAA;QACrE,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YACzC,OAAO,MAAM,CAAA;QACf,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;aAChC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM,CAAC;aACtC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;aACxB,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;aACzD,IAAI,CAAC,IAAI,CAAC,CAAA;QAEb,MAAM,IAAI,KAAK,CACb,IAAI,CAAC,MAAM,GAAG,CAAC;YACb,CAAC,CAAC,kDAAkD,IAAI,EAAE;YAC1D,CAAC,CAAC,0CAA0C,CAC/C,CAAA;IACH,CAAC,CAAC,EAAE,CAAA;IAEJ,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AACxB,CAAC"}
|
|
@@ -7,22 +7,18 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
9
9
|
import { getAiServerConfig as getServerConfig } from '../../config/ai-config';
|
|
10
|
-
import { patchDoc
|
|
11
|
-
import { patchDocStreaming as patchDocStreamingVercel, patchDoc as patchDocVercel, } from './patch-vercel';
|
|
10
|
+
import { patchDoc, patchDocStreaming } from './patch';
|
|
12
11
|
const MODEL = 'claude-sonnet-4-5-20250929';
|
|
13
12
|
describe('anthropic patch', () => {
|
|
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 Anthropic using structured outputs.
|
|
19
|
-
*/
|
|
20
|
-
it.skip('makes a real Anthropic request (manual run) from native provider', async () => {
|
|
16
|
+
it.skip('makes a real Anthropic request (manual run)', async () => {
|
|
21
17
|
const config = getServerConfig();
|
|
22
18
|
if (!config.ai.anthropic.apiKey) {
|
|
23
19
|
throw new Error('ANTHROPIC_API_KEY is required for real Anthropic tests.');
|
|
24
20
|
}
|
|
25
|
-
const result = await
|
|
21
|
+
const result = await patchDoc({
|
|
26
22
|
apiKey: config.ai.anthropic.apiKey,
|
|
27
23
|
model: MODEL,
|
|
28
24
|
prompt: 'Translate into French.',
|
|
@@ -32,15 +28,12 @@ describe('anthropic patch', () => {
|
|
|
32
28
|
expect(result).toBeTruthy();
|
|
33
29
|
expect(typeof result).toBe('object');
|
|
34
30
|
}, 30000);
|
|
35
|
-
|
|
36
|
-
* Generates a document from Anthropic using structured outputs via streaming.
|
|
37
|
-
*/
|
|
38
|
-
it.skip('streams a real Anthropic response (manual run) from native provider', async () => {
|
|
31
|
+
it.skip('streams a real Anthropic response (manual run)', async () => {
|
|
39
32
|
const config = getServerConfig();
|
|
40
33
|
if (!config.ai.anthropic.apiKey) {
|
|
41
34
|
throw new Error('ANTHROPIC_API_KEY is required for real Anthropic tests.');
|
|
42
35
|
}
|
|
43
|
-
const streamResult =
|
|
36
|
+
const streamResult = patchDocStreaming({
|
|
44
37
|
apiKey: config.ai.anthropic.apiKey,
|
|
45
38
|
model: MODEL,
|
|
46
39
|
prompt: 'Translate into French.',
|
|
@@ -49,53 +42,10 @@ describe('anthropic patch', () => {
|
|
|
49
42
|
let streamedText = '';
|
|
50
43
|
for await (const chunk of streamResult.text) {
|
|
51
44
|
streamedText += chunk;
|
|
52
|
-
console.log('STREAM CHUNK (Anthropic
|
|
45
|
+
console.log('STREAM CHUNK (Anthropic):', chunk);
|
|
53
46
|
}
|
|
54
47
|
const final = await streamResult.final;
|
|
55
|
-
console.log('FINAL RESULT (Anthropic
|
|
56
|
-
expect(streamedText.length).toBeGreaterThanOrEqual(0);
|
|
57
|
-
expect(final).toBeTruthy();
|
|
58
|
-
expect(typeof final).toBe('object');
|
|
59
|
-
}, 30000);
|
|
60
|
-
/***
|
|
61
|
-
* Generates a document from Anthropic using structured outputs.
|
|
62
|
-
*/
|
|
63
|
-
it.skip('makes a real Anthropic request (manual run) from vercel provider', async () => {
|
|
64
|
-
const config = getServerConfig();
|
|
65
|
-
if (!config.ai.anthropic.apiKey) {
|
|
66
|
-
throw new Error('ANTHROPIC_API_KEY is required for real Anthropic tests.');
|
|
67
|
-
}
|
|
68
|
-
const result = await patchDocVercel({
|
|
69
|
-
apiKey: config.ai.anthropic.apiKey,
|
|
70
|
-
model: MODEL,
|
|
71
|
-
prompt: 'Translate into French.',
|
|
72
|
-
textNodes: [{ id: 0, text: 'The sun is shining' }],
|
|
73
|
-
});
|
|
74
|
-
console.log(result);
|
|
75
|
-
expect(result).toBeTruthy();
|
|
76
|
-
expect(typeof result).toBe('object');
|
|
77
|
-
}, 30000);
|
|
78
|
-
/***
|
|
79
|
-
* Generates a document from Anthropic using structured outputs via streaming.
|
|
80
|
-
*/
|
|
81
|
-
it.skip('streams a real Anthropic response (manual run) from vercel provider', async () => {
|
|
82
|
-
const config = getServerConfig();
|
|
83
|
-
if (!config.ai.anthropic.apiKey) {
|
|
84
|
-
throw new Error('ANTHROPIC_API_KEY is required for real Anthropic tests.');
|
|
85
|
-
}
|
|
86
|
-
const streamResult = patchDocStreamingVercel({
|
|
87
|
-
apiKey: config.ai.anthropic.apiKey,
|
|
88
|
-
model: MODEL,
|
|
89
|
-
prompt: 'Translate into French.',
|
|
90
|
-
textNodes: [{ id: 0, text: 'The sun is shining' }],
|
|
91
|
-
});
|
|
92
|
-
let streamedText = '';
|
|
93
|
-
for await (const chunk of streamResult.text) {
|
|
94
|
-
streamedText += chunk;
|
|
95
|
-
console.log('STREAM CHUNK (Anthropic Vercel):', chunk);
|
|
96
|
-
}
|
|
97
|
-
const final = await streamResult.final;
|
|
98
|
-
console.log('FINAL RESULT (Anthropic Vercel):', final);
|
|
48
|
+
console.log('FINAL RESULT (Anthropic):', final);
|
|
99
49
|
expect(streamedText.length).toBeGreaterThanOrEqual(0);
|
|
100
50
|
expect(final).toBeTruthy();
|
|
101
51
|
expect(typeof final).toBe('object');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.test.node.js","sourceRoot":"","sources":["../../../src/models/anthropic/patch.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAEzD,OAAO,EAAE,iBAAiB,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,
|
|
1
|
+
{"version":3,"file":"patch.test.node.js","sourceRoot":"","sources":["../../../src/models/anthropic/patch.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAEzD,OAAO,EAAE,iBAAiB,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAErD,MAAM,KAAK,GAAG,4BAA4B,CAAA;AAE1C,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,UAAU,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC,CAAA;IAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,MAAM,CAAA;IAExD,IAAI,OAAO,EAAE,CAAC;QACZ,EAAE,CAAC,IAAI,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;YAChE,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;YAChC,IAAI,CAAC,MAAM,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rB,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;YACjD,CAAC;YAED,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,KAAK,CAAA;YACtC,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;YAC/C,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;YACrD,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAA;YAC1B,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC,EAAE,KAAK,CAAC,CAAA;IACX,CAAC;SAAM,CAAC;QACN,EAAE,CAAC,IAAI,CAAC,4BAA4B,EAAE,GAAG,EAAE;YACzC,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAA;QACxE,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -5,12 +5,55 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
import type { GeneratedDoc } from '../../utils/convert-to-lexical';
|
|
9
|
+
export type GenerateTextStreamingResult = {
|
|
10
|
+
text: AsyncIterable<string>;
|
|
11
|
+
final: Promise<string>;
|
|
12
|
+
};
|
|
13
|
+
export type GenerateHtmlStreamingResult = {
|
|
14
|
+
text: AsyncIterable<string>;
|
|
15
|
+
final: Promise<string>;
|
|
16
|
+
};
|
|
17
|
+
export declare function generateHtml(options: {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
model: string;
|
|
20
|
+
prompt: string;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
}): Promise<string>;
|
|
23
|
+
export declare function generateHtmlStreaming(options: {
|
|
24
|
+
apiKey: string;
|
|
25
|
+
model: string;
|
|
26
|
+
prompt: string;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}): GenerateHtmlStreamingResult;
|
|
29
|
+
export declare function generateText(options: {
|
|
30
|
+
apiKey: string;
|
|
31
|
+
model: string;
|
|
32
|
+
prompt: string;
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
}): Promise<string>;
|
|
36
|
+
export declare function generateTextStreaming(options: {
|
|
37
|
+
apiKey: string;
|
|
38
|
+
model: string;
|
|
39
|
+
prompt: string;
|
|
40
|
+
maxLength?: number;
|
|
41
|
+
signal?: AbortSignal;
|
|
42
|
+
}): GenerateTextStreamingResult;
|
|
43
|
+
export declare function generateDoc(options: {
|
|
44
|
+
apiKey: string;
|
|
45
|
+
model: string;
|
|
46
|
+
prompt: string;
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}): Promise<GeneratedDoc>;
|
|
49
|
+
export type GenerateDocStreamingResult = {
|
|
50
|
+
text: AsyncIterable<string>;
|
|
51
|
+
final: Promise<GeneratedDoc>;
|
|
52
|
+
};
|
|
53
|
+
export declare function generateDocStreaming(options: {
|
|
54
|
+
apiKey: string;
|
|
55
|
+
model: string;
|
|
56
|
+
prompt: string;
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
}): GenerateDocStreamingResult;
|
|
16
59
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/models/google/generate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/models/google/generate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,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d,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GAAG,OAAO,CAAC,YAAY,CAAC,CAyBxB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3B,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CAC7B,CAAA;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GAAG,0BAA0B,CA6D7B"}
|
|
@@ -5,24 +5,240 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
import { GoogleGenAI } from '@google/genai';
|
|
9
|
+
import { buildGenerateHtmlSystemPrompt, buildGenerateHtmlUserPrompt, buildGenerateSystemPrompt, buildGenerateTextSystemPrompt, buildGenerateTextUserPrompt, } from '../../prompts';
|
|
10
|
+
import { normalizeGeneratedDoc } from './normalize-generated-doc';
|
|
11
|
+
import { geminiGenerationSchema2 } from './schema';
|
|
12
|
+
export async function generateHtml(options) {
|
|
13
|
+
const google = new GoogleGenAI({ apiKey: options.apiKey });
|
|
14
|
+
const response = await google.models.generateContent({
|
|
15
|
+
model: options.model,
|
|
16
|
+
config: { systemInstruction: buildGenerateHtmlSystemPrompt() },
|
|
17
|
+
contents: [
|
|
18
|
+
{
|
|
19
|
+
role: 'user',
|
|
20
|
+
parts: [{ text: buildGenerateHtmlUserPrompt(options.prompt) }],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
return response.text?.trim() ?? '';
|
|
25
|
+
}
|
|
26
|
+
export function generateHtmlStreaming(options) {
|
|
27
|
+
const ai = new GoogleGenAI({ apiKey: options.apiKey });
|
|
28
|
+
const streamPromise = ai.models.generateContentStream({
|
|
29
|
+
model: options.model,
|
|
30
|
+
config: {
|
|
31
|
+
systemInstruction: buildGenerateHtmlSystemPrompt(),
|
|
32
|
+
abortSignal: options.signal,
|
|
33
|
+
},
|
|
34
|
+
contents: [
|
|
35
|
+
{
|
|
36
|
+
role: 'user',
|
|
37
|
+
parts: [{ text: buildGenerateHtmlUserPrompt(options.prompt) }],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
let resolveFinal;
|
|
42
|
+
let rejectFinal;
|
|
43
|
+
const final = new Promise((resolve, reject) => {
|
|
44
|
+
resolveFinal = resolve;
|
|
45
|
+
rejectFinal = reject;
|
|
46
|
+
});
|
|
47
|
+
const text = (async function* () {
|
|
48
|
+
let buffered = '';
|
|
49
|
+
try {
|
|
50
|
+
const stream = await streamPromise;
|
|
51
|
+
for await (const chunk of stream) {
|
|
52
|
+
const chunkText = typeof chunk?.text === 'function' ? chunk.text() : chunk?.text;
|
|
53
|
+
if (typeof chunkText === 'string' && chunkText.length > 0) {
|
|
54
|
+
buffered += chunkText;
|
|
55
|
+
yield chunkText;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
resolveFinal(buffered.trim());
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
rejectFinal(error);
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
})();
|
|
65
|
+
return { text, final };
|
|
66
|
+
}
|
|
67
|
+
export async function generateText(options) {
|
|
68
|
+
const ai = new GoogleGenAI({ 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 response = await ai.models.generateContent({
|
|
76
|
+
model: options.model,
|
|
77
|
+
config: {
|
|
78
|
+
systemInstruction: buildGenerateTextSystemPrompt(),
|
|
79
|
+
abortSignal: options.signal,
|
|
80
|
+
},
|
|
81
|
+
contents: [
|
|
82
|
+
{
|
|
83
|
+
role: 'user',
|
|
84
|
+
parts: [{ text: buildGenerateTextUserPrompt(promptWithLength) }],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
const normalized = response.text?.trim() ?? '';
|
|
89
|
+
if (typeof maxLength === 'number' && maxLength > 0) {
|
|
90
|
+
return normalized.length > maxLength ? normalized.slice(0, maxLength).trimEnd() : normalized;
|
|
91
|
+
}
|
|
92
|
+
return normalized;
|
|
93
|
+
}
|
|
94
|
+
export function generateTextStreaming(options) {
|
|
95
|
+
const ai = new GoogleGenAI({ apiKey: options.apiKey });
|
|
96
|
+
const maxLength = typeof options.maxLength === 'number' && Number.isFinite(options.maxLength)
|
|
97
|
+
? Math.floor(options.maxLength)
|
|
98
|
+
: undefined;
|
|
99
|
+
const promptWithLength = typeof maxLength === 'number' && maxLength > 0
|
|
100
|
+
? `${options.prompt}\n\nConstraints:\n- Maximum length: ${maxLength} characters.`
|
|
101
|
+
: options.prompt;
|
|
102
|
+
const streamPromise = ai.models.generateContentStream({
|
|
103
|
+
model: options.model,
|
|
104
|
+
config: {
|
|
105
|
+
systemInstruction: buildGenerateTextSystemPrompt(),
|
|
106
|
+
abortSignal: options.signal,
|
|
107
|
+
},
|
|
108
|
+
contents: [
|
|
109
|
+
{
|
|
110
|
+
role: 'user',
|
|
111
|
+
parts: [{ text: buildGenerateTextUserPrompt(promptWithLength) }],
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
});
|
|
115
|
+
let resolveFinal;
|
|
116
|
+
let rejectFinal;
|
|
117
|
+
const final = new Promise((resolve, reject) => {
|
|
118
|
+
resolveFinal = resolve;
|
|
119
|
+
rejectFinal = reject;
|
|
120
|
+
});
|
|
121
|
+
const text = (async function* () {
|
|
122
|
+
let buffered = '';
|
|
123
|
+
let remaining = typeof maxLength === 'number' && maxLength > 0 ? maxLength : undefined;
|
|
124
|
+
try {
|
|
125
|
+
const stream = await streamPromise;
|
|
126
|
+
for await (const chunk of stream) {
|
|
127
|
+
const chunkText = typeof chunk?.text === 'function' ? chunk.text() : chunk?.text;
|
|
128
|
+
if (typeof chunkText !== 'string' || chunkText.length === 0) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
buffered += chunkText;
|
|
132
|
+
if (typeof remaining === 'number') {
|
|
133
|
+
if (remaining <= 0) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const sliced = chunkText.slice(0, remaining);
|
|
137
|
+
remaining -= sliced.length;
|
|
138
|
+
if (sliced.length > 0) {
|
|
139
|
+
yield sliced;
|
|
140
|
+
}
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
yield chunkText;
|
|
144
|
+
}
|
|
145
|
+
const normalized = buffered.trim();
|
|
146
|
+
if (typeof maxLength === 'number' && maxLength > 0) {
|
|
147
|
+
resolveFinal(normalized.length > maxLength ? normalized.slice(0, maxLength).trimEnd() : normalized);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
resolveFinal(normalized);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
rejectFinal(error);
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
})();
|
|
158
|
+
return { text, final };
|
|
159
|
+
}
|
|
160
|
+
const tryParseJson = (text) => {
|
|
161
|
+
const trimmed = text.trim();
|
|
162
|
+
if (trimmed.length === 0)
|
|
163
|
+
return undefined;
|
|
164
|
+
// Defensive: sometimes models wrap JSON in code fences.
|
|
165
|
+
const fenced = trimmed.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);
|
|
166
|
+
const candidate = fenced?.[1]?.trim() ?? trimmed;
|
|
167
|
+
return JSON.parse(candidate);
|
|
27
168
|
};
|
|
169
|
+
export async function generateDoc(options) {
|
|
170
|
+
const ai = new GoogleGenAI({ apiKey: options.apiKey });
|
|
171
|
+
const response = await ai.models.generateContent({
|
|
172
|
+
model: options.model,
|
|
173
|
+
contents: options.prompt,
|
|
174
|
+
config: {
|
|
175
|
+
systemInstruction: buildGenerateSystemPrompt(),
|
|
176
|
+
responseMimeType: 'application/json',
|
|
177
|
+
responseJsonSchema: geminiGenerationSchema2,
|
|
178
|
+
abortSignal: options.signal,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
const text = response.text?.trim() ?? '';
|
|
182
|
+
if (text.length === 0) {
|
|
183
|
+
throw new Error('Google model returned an empty response.');
|
|
184
|
+
}
|
|
185
|
+
const parsed = tryParseJson(text);
|
|
186
|
+
if (parsed && typeof parsed === 'object') {
|
|
187
|
+
return normalizeGeneratedDoc(parsed);
|
|
188
|
+
}
|
|
189
|
+
throw new Error('Google structured output did not return a JSON object.');
|
|
190
|
+
}
|
|
191
|
+
export function generateDocStreaming(options) {
|
|
192
|
+
const ai = new GoogleGenAI({ apiKey: options.apiKey });
|
|
193
|
+
// const responseJsonSchema = {
|
|
194
|
+
// ...(geminiGenerationSchema as any),
|
|
195
|
+
// $schema: undefined,
|
|
196
|
+
// }
|
|
197
|
+
// const normalizedResponseJsonSchema = normalizeJsonSchemaForGemini(responseJsonSchema)
|
|
198
|
+
const streamPromise = ai.models.generateContentStream({
|
|
199
|
+
model: options.model,
|
|
200
|
+
contents: options.prompt,
|
|
201
|
+
config: {
|
|
202
|
+
systemInstruction: buildGenerateSystemPrompt(),
|
|
203
|
+
responseMimeType: 'application/json',
|
|
204
|
+
// responseJsonSchema: normalizedResponseJsonSchema,
|
|
205
|
+
responseJsonSchema: geminiGenerationSchema2,
|
|
206
|
+
abortSignal: options.signal,
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
let resolveFinal;
|
|
210
|
+
let rejectFinal;
|
|
211
|
+
const final = new Promise((resolve, reject) => {
|
|
212
|
+
resolveFinal = resolve;
|
|
213
|
+
rejectFinal = reject;
|
|
214
|
+
});
|
|
215
|
+
const text = (async function* () {
|
|
216
|
+
let buffered = '';
|
|
217
|
+
try {
|
|
218
|
+
const stream = await streamPromise;
|
|
219
|
+
for await (const chunk of stream) {
|
|
220
|
+
const chunkText = typeof chunk?.text === 'function' ? chunk.text() : chunk?.text;
|
|
221
|
+
if (typeof chunkText === 'string' && chunkText.length > 0) {
|
|
222
|
+
buffered += chunkText;
|
|
223
|
+
yield chunkText;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const trimmed = buffered.trim();
|
|
227
|
+
if (trimmed.length === 0) {
|
|
228
|
+
throw new Error('Google model returned an empty response.');
|
|
229
|
+
}
|
|
230
|
+
const parsed = tryParseJson(trimmed);
|
|
231
|
+
if (parsed && typeof parsed === 'object') {
|
|
232
|
+
resolveFinal(normalizeGeneratedDoc(parsed));
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
throw new Error('Google structured output did not return a JSON object.');
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
rejectFinal(error);
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
})();
|
|
242
|
+
return { text, final };
|
|
243
|
+
}
|
|
28
244
|
//# sourceMappingURL=generate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/models/google/generate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,WAAW,IAAI,iBAAiB,
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/models/google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