call-ai 0.10.2 → 0.11.0-dev-preview3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -58
- package/api-core.d.ts +13 -0
- package/{dist/api-core.js → api-core.js} +51 -126
- package/api-core.js.map +1 -0
- package/api.d.ts +4 -0
- package/api.js +364 -0
- package/api.js.map +1 -0
- package/api.ts.off +595 -0
- package/{dist/error-handling.d.ts → error-handling.d.ts} +4 -2
- package/{dist/error-handling.js → error-handling.js} +34 -70
- package/error-handling.js.map +1 -0
- package/image.d.ts +2 -0
- package/{dist/image.js → image.js} +10 -33
- package/image.js.map +1 -0
- package/index.d.ts +6 -0
- package/index.js +7 -0
- package/index.js.map +1 -0
- package/index.ts.bak +16 -0
- package/key-management.d.ts +29 -0
- package/key-management.js +189 -0
- package/key-management.js.map +1 -0
- package/{dist/non-streaming.d.ts → non-streaming.d.ts} +5 -8
- package/{dist/non-streaming.js → non-streaming.js} +28 -87
- package/non-streaming.js.map +1 -0
- package/package.json +15 -31
- package/response-metadata.d.ts +6 -0
- package/response-metadata.js +22 -0
- package/response-metadata.js.map +1 -0
- package/strategies/index.d.ts +2 -0
- package/strategies/index.js +3 -0
- package/strategies/index.js.map +1 -0
- package/strategies/model-strategies.d.ts +6 -0
- package/{dist/strategies → strategies}/model-strategies.js +26 -72
- package/strategies/model-strategies.js.map +1 -0
- package/strategies/strategy-selector.d.ts +2 -0
- package/strategies/strategy-selector.js +66 -0
- package/strategies/strategy-selector.js.map +1 -0
- package/streaming.d.ts +4 -0
- package/{dist/streaming.js → streaming.js} +66 -184
- package/streaming.js.map +1 -0
- package/streaming.ts.off +571 -0
- package/tsconfig.json +18 -0
- package/types.d.ts +226 -0
- package/types.js +33 -0
- package/types.js.map +1 -0
- package/utils.d.ts +32 -0
- package/utils.js +129 -0
- package/utils.js.map +1 -0
- package/version.d.ts +1 -0
- package/version.js +2 -0
- package/version.js.map +1 -0
- package/dist/api-core.d.ts +0 -40
- package/dist/api.d.ts +0 -15
- package/dist/api.js +0 -498
- package/dist/image.d.ts +0 -12
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -32
- package/dist/key-management.d.ts +0 -43
- package/dist/key-management.js +0 -312
- package/dist/response-metadata.d.ts +0 -18
- package/dist/response-metadata.js +0 -44
- package/dist/strategies/index.d.ts +0 -5
- package/dist/strategies/index.js +0 -21
- package/dist/strategies/model-strategies.d.ts +0 -24
- package/dist/strategies/strategy-selector.d.ts +0 -8
- package/dist/strategies/strategy-selector.js +0 -79
- package/dist/streaming.d.ts +0 -7
- package/dist/types.d.ts +0 -226
- package/dist/types.js +0 -5
- package/dist/utils.d.ts +0 -8
- package/dist/utils.js +0 -52
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { claudeStrategy, defaultStrategy, geminiStrategy, openAIStrategy, systemMessageStrategy } from "./model-strategies.js";
|
|
2
|
+
export function chooseSchemaStrategy(model, schema) {
|
|
3
|
+
const resolvedModel = model || (schema ? "openai/gpt-4o" : "openrouter/auto");
|
|
4
|
+
if (!schema) {
|
|
5
|
+
return {
|
|
6
|
+
strategy: "none",
|
|
7
|
+
model: resolvedModel,
|
|
8
|
+
prepareRequest: defaultStrategy.prepareRequest,
|
|
9
|
+
processResponse: defaultStrategy.processResponse,
|
|
10
|
+
shouldForceStream: false,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (/claude/i.test(resolvedModel)) {
|
|
14
|
+
return {
|
|
15
|
+
strategy: "tool_mode",
|
|
16
|
+
model: resolvedModel,
|
|
17
|
+
prepareRequest: claudeStrategy.prepareRequest,
|
|
18
|
+
processResponse: claudeStrategy.processResponse,
|
|
19
|
+
shouldForceStream: !!claudeStrategy.shouldForceStream,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (/gemini/i.test(resolvedModel)) {
|
|
23
|
+
return {
|
|
24
|
+
strategy: "json_schema",
|
|
25
|
+
model: resolvedModel,
|
|
26
|
+
prepareRequest: geminiStrategy.prepareRequest,
|
|
27
|
+
processResponse: geminiStrategy.processResponse,
|
|
28
|
+
shouldForceStream: !!geminiStrategy.shouldForceStream,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (/gpt-4-turbo/i.test(resolvedModel)) {
|
|
32
|
+
return {
|
|
33
|
+
strategy: "system_message",
|
|
34
|
+
model: resolvedModel,
|
|
35
|
+
prepareRequest: systemMessageStrategy.prepareRequest,
|
|
36
|
+
processResponse: systemMessageStrategy.processResponse,
|
|
37
|
+
shouldForceStream: !!systemMessageStrategy.shouldForceStream,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (/openai|gpt/i.test(resolvedModel)) {
|
|
41
|
+
return {
|
|
42
|
+
strategy: "json_schema",
|
|
43
|
+
model: resolvedModel,
|
|
44
|
+
prepareRequest: openAIStrategy.prepareRequest,
|
|
45
|
+
processResponse: openAIStrategy.processResponse,
|
|
46
|
+
shouldForceStream: !!openAIStrategy.shouldForceStream,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (/llama-3|deepseek/i.test(resolvedModel)) {
|
|
50
|
+
return {
|
|
51
|
+
strategy: "system_message",
|
|
52
|
+
model: resolvedModel,
|
|
53
|
+
prepareRequest: systemMessageStrategy.prepareRequest,
|
|
54
|
+
processResponse: systemMessageStrategy.processResponse,
|
|
55
|
+
shouldForceStream: !!systemMessageStrategy.shouldForceStream,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
strategy: "system_message",
|
|
60
|
+
model: resolvedModel,
|
|
61
|
+
prepareRequest: systemMessageStrategy.prepareRequest,
|
|
62
|
+
processResponse: systemMessageStrategy.processResponse,
|
|
63
|
+
shouldForceStream: !!systemMessageStrategy.shouldForceStream,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=strategy-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy-selector.js","sourceRo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AqB,CAAC,cAAc;YACpD,eAAe,EAAE,qBAAqB,CAAC,eAAe;YACtD,iBAAiB,EAAE,CAAC,CAAC,qBAAqB,CAAC,iBAAiB;SAC7D,CAAC;IACJ,CAAC;IAGD,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,QAAQ,EAAE,aAAa;YACvB,KAAK,EAAE,aAAa;YACpB,cAAc,EAAE,cAAc,CAAC,cAAc;YAC7C,eAAe,EAAE,cAAc,CAAC,eAAe;YAC/C,iBAAiB,EAAE,CAAC,CAAC,cAAc,CAAC,iBAAiB;SACtD,CAAC;IACJ,CAAC;IAGD,IAAI,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QAC5C,OAAO;YACL,QAAQ,EAAE,gBAAgB;YAC1B,KAAK,EAAE,aAAa;YACpB,cAAc,EAAE,qBAAqB,CAAC,cAAc;YACpD,eAAe,EAAE,qBAAqB,CAAC,eAAe;YACtD,iBAAiB,EAAE,CAAC,CAAC,qBAAqB,CAAC,iBAAiB;SAC7D,CAAC;IACJ,CAAC;IAGD,OAAO;QACL,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE,aAAa;QACpB,cAAc,EAAE,qBAAqB,CAAC,cAAc;QACpD,eAAe,EAAE,qBAAqB,CAAC,eAAe;QACtD,iBAAiB,EAAE,CAAC,CAAC,qBAAqB,CAAC,iBAAiB;KAC7D,CAAC;AAAA,CACH"}
|
package/streaming.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CallAIOptions, Message, SchemaStrategy } from "./types.js";
|
|
2
|
+
declare function createStreamingGenerator(response: Response, options: CallAIOptions, schemaStrategy: SchemaStrategy, model: string): AsyncGenerator<string, string, unknown>;
|
|
3
|
+
declare function callAIStreaming(prompt: string | Message[], options?: CallAIOptions, isRetry?: boolean): AsyncGenerator<string, string, unknown>;
|
|
4
|
+
export { createStreamingGenerator, callAIStreaming };
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.createStreamingGenerator = createStreamingGenerator;
|
|
7
|
-
exports.callAIStreaming = callAIStreaming;
|
|
8
|
-
const key_management_1 = require("./key-management");
|
|
9
|
-
const response_metadata_1 = require("./response-metadata");
|
|
10
|
-
const error_handling_1 = require("./error-handling");
|
|
11
|
-
const non_streaming_1 = require("./non-streaming");
|
|
12
|
-
// Generator factory function for streaming API calls
|
|
13
|
-
// This is called after the fetch is made and response is validated
|
|
14
|
-
//
|
|
15
|
-
// Note: Even though we checked response.ok before creating this generator,
|
|
16
|
-
// we need to be prepared for errors that may occur during streaming. Some APIs
|
|
17
|
-
// return a 200 OK initially but then deliver error information in the stream.
|
|
1
|
+
import { CallAIError } from "./types.js";
|
|
2
|
+
import { globalDebug } from "./key-management.js";
|
|
3
|
+
import { responseMetadata, boxString } from "./response-metadata.js";
|
|
4
|
+
import { checkForInvalidModelError } from "./error-handling.js";
|
|
5
|
+
import { PACKAGE_VERSION, FALLBACK_MODEL } from "./non-streaming.js";
|
|
18
6
|
async function* createStreamingGenerator(response, options, schemaStrategy, model) {
|
|
19
|
-
// Create a metadata object for this streaming response
|
|
20
7
|
const meta = {
|
|
21
8
|
model,
|
|
22
9
|
endpoint: options.endpoint || "https://openrouter.ai/api/v1",
|
|
@@ -26,140 +13,106 @@ async function* createStreamingGenerator(response, options, schemaStrategy, mode
|
|
|
26
13
|
duration: 0,
|
|
27
14
|
},
|
|
28
15
|
};
|
|
29
|
-
// Tool calls assembly (for Claude/Anthropic)
|
|
30
16
|
let toolCallsAssembled = "";
|
|
31
17
|
let completeText = "";
|
|
32
18
|
let chunkCount = 0;
|
|
33
|
-
if (options.debug ||
|
|
34
|
-
console.log(`[callAi:${
|
|
19
|
+
if (options.debug || globalDebug) {
|
|
20
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Starting streaming generator with model: ${model}`);
|
|
35
21
|
}
|
|
36
22
|
try {
|
|
37
|
-
// Handle streaming response
|
|
38
23
|
const reader = response.body?.getReader();
|
|
39
24
|
if (!reader) {
|
|
40
25
|
throw new Error("Response body is undefined - API endpoint may not support streaming");
|
|
41
26
|
}
|
|
42
27
|
const textDecoder = new TextDecoder();
|
|
43
|
-
let buffer = "";
|
|
28
|
+
let buffer = "";
|
|
44
29
|
while (true) {
|
|
45
30
|
const { done, value } = await reader.read();
|
|
46
31
|
if (done) {
|
|
47
|
-
if (options.debug ||
|
|
48
|
-
console.log(`[callAi-streaming:complete v${
|
|
32
|
+
if (options.debug || globalDebug) {
|
|
33
|
+
console.log(`[callAi-streaming:complete v${PACKAGE_VERSION}] Stream finished after ${chunkCount} chunks`);
|
|
49
34
|
}
|
|
50
35
|
break;
|
|
51
36
|
}
|
|
52
|
-
// Convert bytes to text
|
|
53
37
|
const chunk = textDecoder.decode(value, { stream: true });
|
|
54
38
|
buffer += chunk;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
buffer = messages.pop() || ""; // Keep the last incomplete chunk in the buffer
|
|
39
|
+
const messages = buffer.split(/\n\n/);
|
|
40
|
+
buffer = messages.pop() || "";
|
|
58
41
|
for (const message of messages) {
|
|
59
42
|
if (!message.trim() || !message.startsWith("data: ")) {
|
|
60
|
-
continue;
|
|
43
|
+
continue;
|
|
61
44
|
}
|
|
62
|
-
|
|
63
|
-
let jsonStr = message.slice(6); // Remove 'data: ' prefix
|
|
45
|
+
const jsonStr = message.slice(6);
|
|
64
46
|
if (jsonStr === "[DONE]") {
|
|
65
|
-
if (options.debug ||
|
|
66
|
-
console.log(`[callAi:${
|
|
47
|
+
if (options.debug || globalDebug) {
|
|
48
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Received [DONE] signal`);
|
|
67
49
|
}
|
|
68
50
|
continue;
|
|
69
51
|
}
|
|
70
52
|
chunkCount++;
|
|
71
|
-
// Try to parse the JSON
|
|
72
53
|
try {
|
|
73
54
|
const json = JSON.parse(jsonStr);
|
|
74
|
-
// Check for error responses in the stream
|
|
75
55
|
if (json.error ||
|
|
76
56
|
json.type === "error" ||
|
|
77
|
-
(json.choices &&
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const errorMessage = json.error?.message ||
|
|
82
|
-
json.error ||
|
|
83
|
-
json.choices?.[0]?.message?.content ||
|
|
84
|
-
"Unknown streaming error";
|
|
85
|
-
if (options.debug || key_management_1.globalDebug) {
|
|
86
|
-
console.error(`[callAi:${non_streaming_1.PACKAGE_VERSION}] Detected error in streaming response:`, json);
|
|
57
|
+
(json.choices && json.choices.length > 0 && json.choices[0].finish_reason === "error")) {
|
|
58
|
+
const errorMessage = json.error?.message || json.error || json.choices?.[0]?.message?.content || "Unknown streaming error";
|
|
59
|
+
if (options.debug || globalDebug) {
|
|
60
|
+
console.error(`[callAi:${PACKAGE_VERSION}] Detected error in streaming response:`, json);
|
|
87
61
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
console.error(`[callAi:${
|
|
62
|
+
const detailedError = new CallAIError({
|
|
63
|
+
message: `API streaming error: ${errorMessage}`,
|
|
64
|
+
status: json.error?.status || 400,
|
|
65
|
+
statusText: json.error?.type || "Bad Request",
|
|
66
|
+
details: JSON.stringify(json.error || json),
|
|
67
|
+
contentType: "application/json",
|
|
68
|
+
});
|
|
69
|
+
console.error(`[callAi:${PACKAGE_VERSION}] Throwing stream error:`, detailedError);
|
|
96
70
|
throw detailedError;
|
|
97
71
|
}
|
|
98
|
-
// Handle tool use response - Claude with schema cases
|
|
99
72
|
const isClaudeWithSchema = /claude/i.test(model) && schemaStrategy.strategy === "tool_mode";
|
|
100
73
|
if (isClaudeWithSchema) {
|
|
101
|
-
// Claude streaming tool calls - need to assemble arguments
|
|
102
74
|
if (json.choices && json.choices.length > 0) {
|
|
103
75
|
const choice = json.choices[0];
|
|
104
|
-
// Handle finish reason tool_calls - this is where we know the tool call is complete
|
|
105
76
|
if (choice.finish_reason === "tool_calls") {
|
|
106
77
|
if (options.debug) {
|
|
107
|
-
console.log(`[callAi:${
|
|
78
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Received tool_calls finish reason. Assembled JSON:`, toolCallsAssembled);
|
|
108
79
|
}
|
|
109
|
-
// Full JSON collected, construct a proper object with it
|
|
110
80
|
try {
|
|
111
|
-
// Try to fix any malformed JSON that might have resulted from chunking
|
|
112
|
-
// This happens when property names get split across chunks
|
|
113
81
|
if (toolCallsAssembled) {
|
|
114
82
|
try {
|
|
115
|
-
// First try parsing as-is
|
|
116
83
|
JSON.parse(toolCallsAssembled);
|
|
117
84
|
}
|
|
118
85
|
catch (parseError) {
|
|
119
86
|
if (options.debug) {
|
|
120
|
-
console.log(`[callAi:${
|
|
87
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Attempting to fix malformed JSON in tool call:`, toolCallsAssembled);
|
|
121
88
|
}
|
|
122
|
-
// Apply comprehensive fixes for Claude's JSON property splitting
|
|
123
89
|
let fixedJson = toolCallsAssembled;
|
|
124
|
-
// 1. Remove trailing commas
|
|
125
90
|
fixedJson = fixedJson.replace(/,\s*([\}\]])/, "$1");
|
|
126
|
-
// 2. Ensure proper JSON structure
|
|
127
|
-
// Add closing braces if missing
|
|
128
91
|
const openBraces = (fixedJson.match(/\{/g) || []).length;
|
|
129
92
|
const closeBraces = (fixedJson.match(/\}/g) || []).length;
|
|
130
93
|
if (openBraces > closeBraces) {
|
|
131
94
|
fixedJson += "}".repeat(openBraces - closeBraces);
|
|
132
95
|
}
|
|
133
|
-
// Add opening brace if missing
|
|
134
96
|
if (!fixedJson.trim().startsWith("{")) {
|
|
135
97
|
fixedJson = "{" + fixedJson.trim();
|
|
136
98
|
}
|
|
137
|
-
// Ensure it ends with a closing brace
|
|
138
99
|
if (!fixedJson.trim().endsWith("}")) {
|
|
139
100
|
fixedJson += "}";
|
|
140
101
|
}
|
|
141
|
-
// 3. Fix various property name/value split issues
|
|
142
|
-
// Fix dangling property names without values
|
|
143
102
|
fixedJson = fixedJson.replace(/"(\w+)"\s*:\s*$/g, '"$1":null');
|
|
144
|
-
// Fix missing property values
|
|
145
103
|
fixedJson = fixedJson.replace(/"(\w+)"\s*:\s*,/g, '"$1":null,');
|
|
146
|
-
// Fix incomplete property names (when split across chunks)
|
|
147
104
|
fixedJson = fixedJson.replace(/"(\w+)"\s*:\s*"(\w+)$/g, '"$1$2"');
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
.length;
|
|
151
|
-
const closeBrackets = (fixedJson.match(/\]/g) || [])
|
|
152
|
-
.length;
|
|
105
|
+
const openBrackets = (fixedJson.match(/\[/g) || []).length;
|
|
106
|
+
const closeBrackets = (fixedJson.match(/\]/g) || []).length;
|
|
153
107
|
if (openBrackets > closeBrackets) {
|
|
154
108
|
fixedJson += "]".repeat(openBrackets - closeBrackets);
|
|
155
109
|
}
|
|
156
110
|
if (options.debug) {
|
|
157
|
-
console.log(`[callAi:${
|
|
111
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Applied comprehensive JSON fixes:`, `\nBefore: ${toolCallsAssembled}`, `\nAfter: ${fixedJson}`);
|
|
158
112
|
}
|
|
159
113
|
toolCallsAssembled = fixedJson;
|
|
160
114
|
}
|
|
161
115
|
}
|
|
162
|
-
// Return the assembled tool call
|
|
163
116
|
completeText = toolCallsAssembled;
|
|
164
117
|
yield completeText;
|
|
165
118
|
continue;
|
|
@@ -168,31 +121,23 @@ async function* createStreamingGenerator(response, options, schemaStrategy, mode
|
|
|
168
121
|
console.error("[callAIStreaming] Error handling assembled tool call:", e);
|
|
169
122
|
}
|
|
170
123
|
}
|
|
171
|
-
// Assemble tool_calls arguments from delta
|
|
172
|
-
// Simply accumulate the raw strings without trying to parse them
|
|
173
124
|
if (choice && choice.delta && choice.delta.tool_calls) {
|
|
174
125
|
const toolCall = choice.delta.tool_calls[0];
|
|
175
|
-
if (toolCall &&
|
|
176
|
-
toolCall.function &&
|
|
177
|
-
toolCall.function.arguments !== undefined) {
|
|
126
|
+
if (toolCall && toolCall.function && toolCall.function.arguments !== undefined) {
|
|
178
127
|
toolCallsAssembled += toolCall.function.arguments;
|
|
179
128
|
if (options.debug) {
|
|
180
|
-
console.log(`[callAi:${
|
|
129
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Accumulated tool call chunk:`, toolCall.function.arguments);
|
|
181
130
|
}
|
|
182
131
|
}
|
|
183
132
|
}
|
|
184
133
|
}
|
|
185
134
|
}
|
|
186
|
-
|
|
187
|
-
if (isClaudeWithSchema &&
|
|
188
|
-
(json.stop_reason === "tool_use" || json.type === "tool_use")) {
|
|
189
|
-
// First try direct tool use object format
|
|
135
|
+
if (isClaudeWithSchema && (json.stop_reason === "tool_use" || json.type === "tool_use")) {
|
|
190
136
|
if (json.type === "tool_use") {
|
|
191
137
|
completeText = schemaStrategy.processResponse(json);
|
|
192
138
|
yield completeText;
|
|
193
139
|
continue;
|
|
194
140
|
}
|
|
195
|
-
// Extract the tool use content
|
|
196
141
|
if (json.content && Array.isArray(json.content)) {
|
|
197
142
|
const toolUseBlock = json.content.find((block) => block.type === "tool_use");
|
|
198
143
|
if (toolUseBlock) {
|
|
@@ -201,7 +146,6 @@ async function* createStreamingGenerator(response, options, schemaStrategy, mode
|
|
|
201
146
|
continue;
|
|
202
147
|
}
|
|
203
148
|
}
|
|
204
|
-
// Find tool_use in assistant's content blocks
|
|
205
149
|
if (json.choices && Array.isArray(json.choices)) {
|
|
206
150
|
const choice = json.choices[0];
|
|
207
151
|
if (choice.message && Array.isArray(choice.message.content)) {
|
|
@@ -212,7 +156,6 @@ async function* createStreamingGenerator(response, options, schemaStrategy, mode
|
|
|
212
156
|
continue;
|
|
213
157
|
}
|
|
214
158
|
}
|
|
215
|
-
// Handle case where the tool use is in the delta
|
|
216
159
|
if (choice.delta && Array.isArray(choice.delta.content)) {
|
|
217
160
|
const toolUseBlock = choice.delta.content.find((block) => block.type === "tool_use");
|
|
218
161
|
if (toolUseBlock) {
|
|
@@ -223,10 +166,8 @@ async function* createStreamingGenerator(response, options, schemaStrategy, mode
|
|
|
223
166
|
}
|
|
224
167
|
}
|
|
225
168
|
}
|
|
226
|
-
// Extract content from the delta
|
|
227
169
|
if (json.choices?.[0]?.delta?.content !== undefined) {
|
|
228
170
|
const content = json.choices[0].delta.content || "";
|
|
229
|
-
// Treat all models the same - yield as content arrives
|
|
230
171
|
completeText += content;
|
|
231
172
|
yield schemaStrategy.processResponse(completeText);
|
|
232
173
|
}
|
|
@@ -237,32 +178,24 @@ async function* createStreamingGenerator(response, options, schemaStrategy, mode
|
|
|
237
178
|
yield schemaStrategy.processResponse(completeText);
|
|
238
179
|
}
|
|
239
180
|
// Handle content blocks for Claude/Anthropic response format
|
|
240
|
-
else if (json.choices?.[0]?.message?.content &&
|
|
241
|
-
Array.isArray(json.choices[0].message.content)) {
|
|
181
|
+
else if (json.choices?.[0]?.message?.content && Array.isArray(json.choices[0].message.content)) {
|
|
242
182
|
const contentBlocks = json.choices[0].message.content;
|
|
243
|
-
// Find text or tool_use blocks
|
|
244
183
|
for (const block of contentBlocks) {
|
|
245
184
|
if (block.type === "text") {
|
|
246
185
|
completeText += block.text || "";
|
|
247
186
|
}
|
|
248
187
|
else if (isClaudeWithSchema && block.type === "tool_use") {
|
|
249
188
|
completeText = schemaStrategy.processResponse(block);
|
|
250
|
-
break;
|
|
189
|
+
break;
|
|
251
190
|
}
|
|
252
191
|
}
|
|
253
192
|
yield schemaStrategy.processResponse(completeText);
|
|
254
193
|
}
|
|
255
|
-
|
|
256
|
-
if (json.type === "content_block_delta" &&
|
|
257
|
-
json.delta &&
|
|
258
|
-
json.delta.type === "text_delta" &&
|
|
259
|
-
json.delta.text) {
|
|
194
|
+
if (json.type === "content_block_delta" && json.delta && json.delta.type === "text_delta" && json.delta.text) {
|
|
260
195
|
if (options.debug) {
|
|
261
|
-
console.log(`[callAi:${
|
|
196
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Received text delta:`, json.delta.text);
|
|
262
197
|
}
|
|
263
198
|
completeText += json.delta.text;
|
|
264
|
-
// In some models like Claude, don't yield partial results as they can be malformed JSON
|
|
265
|
-
// Only yield what we've seen so far if it's not a Claude model with schema
|
|
266
199
|
if (!isClaudeWithSchema) {
|
|
267
200
|
yield schemaStrategy.processResponse(completeText);
|
|
268
201
|
}
|
|
@@ -275,115 +208,77 @@ async function* createStreamingGenerator(response, options, schemaStrategy, mode
|
|
|
275
208
|
}
|
|
276
209
|
}
|
|
277
210
|
}
|
|
278
|
-
// We no longer need special error handling here as errors are thrown immediately
|
|
279
|
-
// No extra error handling needed here - errors are thrown immediately
|
|
280
|
-
// If we have assembled tool calls but haven't yielded them yet
|
|
281
211
|
if (toolCallsAssembled && (!completeText || completeText.length === 0)) {
|
|
282
|
-
// Try to fix any remaining JSON issues before returning
|
|
283
212
|
let result = toolCallsAssembled;
|
|
284
213
|
try {
|
|
285
|
-
// Try to parse as-is first
|
|
286
214
|
JSON.parse(result);
|
|
287
215
|
}
|
|
288
216
|
catch (e) {
|
|
289
217
|
if (options.debug) {
|
|
290
|
-
console.log(`[callAi:${
|
|
218
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Final JSON validation failed:`, e, `\nAttempting to fix JSON:`, result);
|
|
291
219
|
}
|
|
292
|
-
// Apply more robust fixes for Claude's streaming JSON issues
|
|
293
|
-
// 1. Remove trailing commas (common in malformed JSON)
|
|
294
220
|
result = result.replace(/,\s*([\}\]])/, "$1");
|
|
295
|
-
// 2. Ensure we have proper JSON structure
|
|
296
|
-
// Add closing braces if missing
|
|
297
221
|
const openBraces = (result.match(/\{/g) || []).length;
|
|
298
222
|
const closeBraces = (result.match(/\}/g) || []).length;
|
|
299
223
|
if (openBraces > closeBraces) {
|
|
300
224
|
result += "}".repeat(openBraces - closeBraces);
|
|
301
225
|
}
|
|
302
|
-
// Add opening brace if missing
|
|
303
226
|
if (!result.trim().startsWith("{")) {
|
|
304
227
|
result = "{" + result.trim();
|
|
305
228
|
}
|
|
306
|
-
// Ensure it ends with a closing brace
|
|
307
229
|
if (!result.trim().endsWith("}")) {
|
|
308
230
|
result += "}";
|
|
309
231
|
}
|
|
310
|
-
// Fix dangling property names without values
|
|
311
232
|
result = result.replace(/"(\w+)"\s*:\s*$/g, '"$1":null');
|
|
312
|
-
// Fix missing property values
|
|
313
233
|
result = result.replace(/"(\w+)"\s*:\s*,/g, '"$1":null,');
|
|
314
|
-
// Balance brackets
|
|
315
234
|
const openBrackets = (result.match(/\[/g) || []).length;
|
|
316
235
|
const closeBrackets = (result.match(/\]/g) || []).length;
|
|
317
236
|
if (openBrackets > closeBrackets) {
|
|
318
237
|
result += "]".repeat(openBrackets - closeBrackets);
|
|
319
238
|
}
|
|
320
239
|
if (options.debug) {
|
|
321
|
-
console.log(`[callAi:${
|
|
240
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Applied final JSON fixes:`, result);
|
|
322
241
|
}
|
|
323
242
|
}
|
|
324
|
-
// Return the assembled tool call
|
|
325
243
|
completeText = result;
|
|
326
|
-
// Try one more time to validate
|
|
327
244
|
try {
|
|
328
245
|
JSON.parse(completeText);
|
|
329
246
|
}
|
|
330
247
|
catch (finalParseError) {
|
|
331
248
|
if (options.debug) {
|
|
332
|
-
console.error(`[callAi:${
|
|
249
|
+
console.error(`[callAi:${PACKAGE_VERSION}] Final JSON validation still failed:`, finalParseError);
|
|
333
250
|
}
|
|
334
251
|
}
|
|
335
252
|
yield completeText;
|
|
336
253
|
}
|
|
337
|
-
// Record streaming completion in metadata
|
|
338
254
|
const endTime = Date.now();
|
|
339
255
|
meta.timing.endTime = endTime;
|
|
340
256
|
meta.timing.duration = endTime - meta.timing.startTime;
|
|
341
|
-
// Add the rawResponse field to match non-streaming behavior
|
|
342
|
-
// For streaming, we use the final complete text as the raw response
|
|
343
257
|
meta.rawResponse = completeText;
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
response_metadata_1.responseMetadata.set(boxed, meta);
|
|
347
|
-
// Return the complete text as the final value
|
|
258
|
+
const boxed = boxString(completeText);
|
|
259
|
+
responseMetadata.set(boxed, meta);
|
|
348
260
|
return completeText;
|
|
349
261
|
}
|
|
350
262
|
catch (error) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
console.error(`[callAi:${non_streaming_1.PACKAGE_VERSION}] Streaming error:`, error);
|
|
263
|
+
if (options.debug || globalDebug) {
|
|
264
|
+
console.error(`[callAi:${PACKAGE_VERSION}] Streaming error:`, error);
|
|
354
265
|
}
|
|
355
|
-
// This error will be caught in the caller's try/catch block
|
|
356
266
|
throw error;
|
|
357
267
|
}
|
|
358
268
|
}
|
|
359
|
-
// Simplified generator for accessing streaming results
|
|
360
|
-
// Returns an async generator that yields blocks of text
|
|
361
|
-
// This is a higher-level function that prepares the request
|
|
362
|
-
// and handles model fallback
|
|
363
269
|
async function* callAIStreaming(prompt, options = {}, isRetry = false) {
|
|
364
|
-
|
|
365
|
-
const messages = Array.isArray(prompt)
|
|
366
|
-
? prompt
|
|
367
|
-
: [{ role: "user", content: prompt }];
|
|
368
|
-
// API key should be provided by options (validation happens in callAi)
|
|
270
|
+
const messages = Array.isArray(prompt) ? prompt : [{ role: "user", content: prompt }];
|
|
369
271
|
const apiKey = options.apiKey;
|
|
370
272
|
const model = options.model || "openai/gpt-3.5-turbo";
|
|
371
|
-
// Default endpoint compatible with OpenAI API
|
|
372
273
|
const endpoint = options.endpoint || "https://openrouter.ai/api/v1";
|
|
373
|
-
// Build the endpoint URL
|
|
374
274
|
const url = `${endpoint}/chat/completions`;
|
|
375
|
-
// Choose a schema strategy based on model
|
|
376
275
|
const schemaStrategy = options.schemaStrategy;
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
? "json"
|
|
380
|
-
: undefined;
|
|
381
|
-
const debug = options.debug === undefined ? key_management_1.globalDebug : options.debug;
|
|
276
|
+
const responseFormat = options.responseFormat || /gpt-4/.test(model) || /gpt-3.5/.test(model) ? "json" : undefined;
|
|
277
|
+
const debug = options.debug === undefined ? globalDebug : options.debug;
|
|
382
278
|
if (debug) {
|
|
383
|
-
console.log(`[callAi:${
|
|
384
|
-
console.log(`[callAi:${
|
|
279
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Making streaming request to: ${url}`);
|
|
280
|
+
console.log(`[callAi:${PACKAGE_VERSION}] With model: ${model}`);
|
|
385
281
|
}
|
|
386
|
-
// Build request body
|
|
387
282
|
const requestBody = {
|
|
388
283
|
model,
|
|
389
284
|
messages,
|
|
@@ -392,26 +287,21 @@ async function* callAIStreaming(prompt, options = {}, isRetry = false) {
|
|
|
392
287
|
top_p: options.topP !== undefined ? options.topP : 1,
|
|
393
288
|
stream: true,
|
|
394
289
|
};
|
|
395
|
-
// Add response_format if specified or for JSON handling
|
|
396
290
|
if (responseFormat === "json") {
|
|
397
291
|
requestBody.response_format = { type: "json_object" };
|
|
398
292
|
}
|
|
399
|
-
// Add schema-specific parameters (if schema is provided)
|
|
400
293
|
if (options.schema) {
|
|
401
|
-
Object.assign(requestBody, schemaStrategy
|
|
294
|
+
Object.assign(requestBody, schemaStrategy?.prepareRequest(options.schema, messages));
|
|
402
295
|
}
|
|
403
|
-
// Add HTTP referer and other options to help with abuse prevention
|
|
404
296
|
const headers = {
|
|
405
297
|
Authorization: `Bearer ${apiKey}`,
|
|
406
298
|
"HTTP-Referer": options.referer || "https://vibes.diy",
|
|
407
299
|
"X-Title": options.title || "Vibes",
|
|
408
300
|
"Content-Type": "application/json",
|
|
409
301
|
};
|
|
410
|
-
// Add any additional headers
|
|
411
302
|
if (options.headers) {
|
|
412
303
|
Object.assign(headers, options.headers);
|
|
413
304
|
}
|
|
414
|
-
// Copy any other options not explicitly handled above
|
|
415
305
|
Object.keys(options).forEach((key) => {
|
|
416
306
|
if (![
|
|
417
307
|
"apiKey",
|
|
@@ -433,51 +323,43 @@ async function* callAIStreaming(prompt, options = {}, isRetry = false) {
|
|
|
433
323
|
}
|
|
434
324
|
});
|
|
435
325
|
if (debug) {
|
|
436
|
-
console.log(`[callAi:${
|
|
437
|
-
console.log(`[callAi:${
|
|
326
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Request headers:`, headers);
|
|
327
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Request body:`, requestBody);
|
|
438
328
|
}
|
|
439
329
|
let response;
|
|
440
330
|
try {
|
|
441
|
-
// Make the API request
|
|
442
331
|
response = await fetch(url, {
|
|
443
332
|
method: "POST",
|
|
444
333
|
headers,
|
|
445
334
|
body: JSON.stringify(requestBody),
|
|
446
335
|
});
|
|
447
|
-
// Handle HTTP errors
|
|
448
336
|
if (!response.ok) {
|
|
449
|
-
|
|
450
|
-
const { isInvalidModel, errorData } = await (0, error_handling_1.checkForInvalidModelError)(response, model, debug);
|
|
337
|
+
const { isInvalidModel, errorData } = await checkForInvalidModelError(response, model, debug);
|
|
451
338
|
if (isInvalidModel && !isRetry && !options.skipRetry) {
|
|
452
339
|
if (debug) {
|
|
453
|
-
console.log(`[callAi:${
|
|
340
|
+
console.log(`[callAi:${PACKAGE_VERSION}] Invalid model "${model}", falling back to "${FALLBACK_MODEL}"`);
|
|
454
341
|
}
|
|
455
|
-
// Retry with the fallback model using yield* to delegate to the other generator
|
|
456
342
|
yield* callAIStreaming(prompt, {
|
|
457
343
|
...options,
|
|
458
|
-
model:
|
|
344
|
+
model: FALLBACK_MODEL,
|
|
459
345
|
}, true);
|
|
460
|
-
// Generator delegation handles returning the final value
|
|
461
346
|
return "";
|
|
462
347
|
}
|
|
463
|
-
|
|
464
|
-
const errorText = errorData
|
|
465
|
-
? JSON.stringify(errorData)
|
|
466
|
-
: `HTTP error! Status: ${response.status}`;
|
|
348
|
+
const errorText = errorData ? JSON.stringify(errorData) : `HTTP error! Status: ${response.status}`;
|
|
467
349
|
throw new Error(errorText);
|
|
468
350
|
}
|
|
469
|
-
|
|
351
|
+
if (!schemaStrategy) {
|
|
352
|
+
throw new Error("Schema strategy is required for streaming");
|
|
353
|
+
}
|
|
470
354
|
yield* createStreamingGenerator(response, options, schemaStrategy, model);
|
|
471
|
-
|
|
472
|
-
return ""; // This is never reached due to yield*
|
|
355
|
+
return "";
|
|
473
356
|
}
|
|
474
357
|
catch (fetchError) {
|
|
475
|
-
// Network errors must be directly re-thrown without modification
|
|
476
|
-
// This is exactly how the original implementation handles it
|
|
477
358
|
if (debug) {
|
|
478
|
-
console.error(`[callAi:${
|
|
359
|
+
console.error(`[callAi:${PACKAGE_VERSION}] Network error during fetch:`, fetchError);
|
|
479
360
|
}
|
|
480
|
-
// Critical: throw the exact same error object without any wrapping
|
|
481
361
|
throw fetchError;
|
|
482
362
|
}
|
|
483
363
|
}
|
|
364
|
+
export { createStreamingGenerator, callAIStreaming };
|
|
365
|
+
//# sourceMappingURL=streaming.js.map
|
package/streaming.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../jsr/streaming.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAgF,MAAM,YAAY,CAAC;AACvH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAQrE,KAAK,SAAS,CAAC,CAAC,wBAAwB,CACtC,QAAkB,EAClB,OAAsB,EACtB,cAA8B,EAC9B,KAAa,EAC4B;IAEzC,MAAM,IAAI,GAAiB;QACzB,KAAK;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,8BAA8B;QAC5D,MAAM,EAAE;YACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,CAAC;SACZ;KACF,CAAC;IAGF,IAAI,kBAAkB,GAAG,EAAE,CAAC;IAC5B,IAAI,YAAY,GAA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