@zenning/openai 1.4.6 → 1.4.8
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/index.js +164 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -24
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.js +164 -24
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +164 -24
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2781,7 +2781,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2781
2781
|
stream: response.pipeThrough(
|
|
2782
2782
|
new TransformStream({
|
|
2783
2783
|
transform(chunk, controller) {
|
|
2784
|
-
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2784
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2785
2785
|
try {
|
|
2786
2786
|
console.log("\u{1F4E6} Processing chunk:", JSON.stringify(chunk, null, 2));
|
|
2787
2787
|
if (!chunk.success) {
|
|
@@ -2909,58 +2909,79 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2909
2909
|
args: ""
|
|
2910
2910
|
});
|
|
2911
2911
|
} else if (value.item.type === "file_search_call") {
|
|
2912
|
+
console.log("\u{1F4C1} File search call completed:", JSON.stringify({
|
|
2913
|
+
id: value.item.id,
|
|
2914
|
+
status: value.item.status,
|
|
2915
|
+
queries: value.item.queries,
|
|
2916
|
+
resultsCount: ((_a15 = value.item.results) == null ? void 0 : _a15.length) || 0
|
|
2917
|
+
}, null, 2));
|
|
2912
2918
|
ongoingToolCalls[value.output_index] = void 0;
|
|
2913
2919
|
hasToolCalls = true;
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2920
|
+
try {
|
|
2921
|
+
controller.enqueue({
|
|
2922
|
+
type: "tool-call",
|
|
2923
|
+
toolCallType: "function",
|
|
2924
|
+
toolCallId: value.item.id,
|
|
2925
|
+
toolName: "file_search",
|
|
2926
|
+
args: JSON.stringify({
|
|
2927
|
+
queries: value.item.queries,
|
|
2928
|
+
results: value.item.results
|
|
2929
|
+
})
|
|
2930
|
+
});
|
|
2931
|
+
console.log("\u2705 File search tool call enqueued successfully");
|
|
2932
|
+
} catch (error) {
|
|
2933
|
+
console.error("\u274C Error enqueuing file search tool call:", error);
|
|
2934
|
+
}
|
|
2924
2935
|
}
|
|
2925
2936
|
} else if (isResponseFinishedChunk(value)) {
|
|
2926
2937
|
console.log("\u{1F3C1} Response finished:", JSON.stringify(value, null, 2));
|
|
2927
2938
|
finishReason = mapOpenAIResponseFinishReason({
|
|
2928
|
-
finishReason: (
|
|
2939
|
+
finishReason: (_b = value.response.incomplete_details) == null ? void 0 : _b.reason,
|
|
2929
2940
|
hasToolCalls
|
|
2930
2941
|
});
|
|
2931
2942
|
promptTokens = value.response.usage.input_tokens;
|
|
2932
2943
|
completionTokens = value.response.usage.output_tokens;
|
|
2933
|
-
cachedPromptTokens = (
|
|
2934
|
-
reasoningTokens = (
|
|
2944
|
+
cachedPromptTokens = (_d = (_c = value.response.usage.input_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : cachedPromptTokens;
|
|
2945
|
+
reasoningTokens = (_f = (_e = value.response.usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : reasoningTokens;
|
|
2935
2946
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
2936
2947
|
console.log("\u{1F50D} Processing annotation chunk:", JSON.stringify({
|
|
2937
2948
|
type: value.type,
|
|
2938
2949
|
annotation: value.annotation
|
|
2939
2950
|
}, null, 2));
|
|
2940
2951
|
try {
|
|
2952
|
+
console.log("\u{1F50D} Annotation processing - step 1: Validating annotation structure");
|
|
2953
|
+
if (!value.annotation || typeof value.annotation !== "object") {
|
|
2954
|
+
throw new Error("Invalid annotation structure");
|
|
2955
|
+
}
|
|
2956
|
+
console.log("\u{1F50D} Annotation processing - step 2: Checking annotation type");
|
|
2941
2957
|
if (value.annotation.type === "url_citation") {
|
|
2958
|
+
console.log("\u{1F310} Processing URL citation");
|
|
2942
2959
|
const urlSource = {
|
|
2943
2960
|
sourceType: "url",
|
|
2944
|
-
id: (
|
|
2945
|
-
url: value.annotation.url,
|
|
2946
|
-
title: value.annotation.title
|
|
2961
|
+
id: (_i = (_h = (_g = self.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
|
|
2962
|
+
url: String(value.annotation.url || ""),
|
|
2963
|
+
title: String(value.annotation.title || "Web Source")
|
|
2947
2964
|
};
|
|
2948
|
-
console.log("\u2705
|
|
2965
|
+
console.log("\u2705 Created URL source:", JSON.stringify(urlSource, null, 2));
|
|
2966
|
+
console.log("\u{1F50D} Annotation processing - step 3: Enqueuing URL source");
|
|
2949
2967
|
controller.enqueue({
|
|
2950
2968
|
type: "source",
|
|
2951
2969
|
source: urlSource
|
|
2952
2970
|
});
|
|
2953
2971
|
console.log("\u2705 URL source enqueued successfully");
|
|
2954
2972
|
} else if (value.annotation.type === "file_citation") {
|
|
2973
|
+
console.log("\u{1F4C4} Processing FILE citation - this is where the error likely occurs");
|
|
2974
|
+
console.log("\u{1F4C4} File citation raw data:", JSON.stringify(value.annotation, null, 2));
|
|
2955
2975
|
const documentSource = {
|
|
2956
2976
|
sourceType: "document",
|
|
2957
|
-
id: (
|
|
2977
|
+
id: (_l = (_k = (_j = self.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
|
|
2958
2978
|
mediaType: "text/plain",
|
|
2959
|
-
title: value.annotation.quote || value.annotation.filename || "Document",
|
|
2960
|
-
filename: value.annotation.filename,
|
|
2961
|
-
quote: value.annotation.quote
|
|
2979
|
+
title: String(value.annotation.quote || value.annotation.filename || "Document"),
|
|
2980
|
+
filename: value.annotation.filename ? String(value.annotation.filename) : void 0,
|
|
2981
|
+
quote: value.annotation.quote ? String(value.annotation.quote) : void 0
|
|
2962
2982
|
};
|
|
2963
|
-
console.log("\u{1F4C4}
|
|
2983
|
+
console.log("\u{1F4C4} Created document source:", JSON.stringify(documentSource, null, 2));
|
|
2984
|
+
console.log("\u{1F50D} Annotation processing - step 3: Enqueuing document source");
|
|
2964
2985
|
controller.enqueue({
|
|
2965
2986
|
type: "source",
|
|
2966
2987
|
source: documentSource
|
|
@@ -2970,12 +2991,33 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2970
2991
|
console.log("\u26A0\uFE0F Unknown annotation type:", value.annotation.type);
|
|
2971
2992
|
}
|
|
2972
2993
|
} catch (error) {
|
|
2973
|
-
console.error("\u274C
|
|
2994
|
+
console.error("\u274C CRITICAL ERROR in annotation processing:", {
|
|
2995
|
+
step: "annotation processing",
|
|
2974
2996
|
annotation: value.annotation,
|
|
2975
2997
|
error: error instanceof Error ? error.message : String(error),
|
|
2976
2998
|
stack: error instanceof Error ? error.stack : void 0
|
|
2977
2999
|
});
|
|
3000
|
+
console.log("\u{1F6E1}\uFE0F Continuing stream without this annotation to prevent total failure");
|
|
2978
3001
|
}
|
|
3002
|
+
} else if (isResponseInProgressChunk(value)) {
|
|
3003
|
+
console.log("\u23F3 Response in progress (ignored):", value.type);
|
|
3004
|
+
} else if (isResponseContentPartAddedChunk(value)) {
|
|
3005
|
+
console.log("\u{1F4DD} Content part added (ignored):", value.type);
|
|
3006
|
+
} else if (isResponseOutputTextDoneChunk(value)) {
|
|
3007
|
+
console.log("\u2705 Output text done (ignored):", value.type);
|
|
3008
|
+
} else if (isResponseContentPartDoneChunk(value)) {
|
|
3009
|
+
console.log("\u2705 Content part done (ignored):", value.type);
|
|
3010
|
+
} else if (isResponseFileSearchCallInProgressChunk(value)) {
|
|
3011
|
+
console.log("\u{1F50D} File search in progress (ignored):", value.type);
|
|
3012
|
+
} else if (isResponseFileSearchCallSearchingChunk(value)) {
|
|
3013
|
+
console.log("\u{1F50D} File search searching (ignored):", value.type);
|
|
3014
|
+
} else if (isResponseFileSearchCallCompletedChunk(value)) {
|
|
3015
|
+
console.log("\u2705 File search completed (ignored):", value.type);
|
|
3016
|
+
} else if (isResponseFileSearchCallQueryAddedChunk(value)) {
|
|
3017
|
+
console.log("\u{1F50D} File search query added (ignored):", value.type, "Query:", value.query);
|
|
3018
|
+
} else if (isResponseFileSearchCallResultAddedChunk(value)) {
|
|
3019
|
+
console.log("\u{1F4C4} File search result added (ignored):", value.type);
|
|
3020
|
+
console.log("\u{1F4C4} File search result details:", JSON.stringify(value.result, null, 2));
|
|
2979
3021
|
} else {
|
|
2980
3022
|
console.log("\u2753 Unhandled chunk type:", value.type, JSON.stringify(value, null, 2));
|
|
2981
3023
|
}
|
|
@@ -3180,6 +3222,68 @@ var responseReasoningSummaryTextDeltaSchema = z11.object({
|
|
|
3180
3222
|
summary_index: z11.number(),
|
|
3181
3223
|
delta: z11.string()
|
|
3182
3224
|
});
|
|
3225
|
+
var responseInProgressChunkSchema = z11.object({
|
|
3226
|
+
type: z11.literal("response.in_progress"),
|
|
3227
|
+
sequence_number: z11.number(),
|
|
3228
|
+
response: z11.any()
|
|
3229
|
+
});
|
|
3230
|
+
var responseContentPartAddedChunkSchema = z11.object({
|
|
3231
|
+
type: z11.literal("response.content_part.added"),
|
|
3232
|
+
sequence_number: z11.number(),
|
|
3233
|
+
item_id: z11.string(),
|
|
3234
|
+
output_index: z11.number(),
|
|
3235
|
+
content_index: z11.number(),
|
|
3236
|
+
part: z11.any()
|
|
3237
|
+
});
|
|
3238
|
+
var responseOutputTextDoneChunkSchema = z11.object({
|
|
3239
|
+
type: z11.literal("response.output_text.done"),
|
|
3240
|
+
sequence_number: z11.number(),
|
|
3241
|
+
item_id: z11.string(),
|
|
3242
|
+
output_index: z11.number(),
|
|
3243
|
+
content_index: z11.number(),
|
|
3244
|
+
text: z11.string(),
|
|
3245
|
+
logprobs: z11.array(z11.any()).optional()
|
|
3246
|
+
});
|
|
3247
|
+
var responseContentPartDoneChunkSchema = z11.object({
|
|
3248
|
+
type: z11.literal("response.content_part.done"),
|
|
3249
|
+
sequence_number: z11.number(),
|
|
3250
|
+
item_id: z11.string(),
|
|
3251
|
+
output_index: z11.number(),
|
|
3252
|
+
content_index: z11.number(),
|
|
3253
|
+
part: z11.any()
|
|
3254
|
+
});
|
|
3255
|
+
var responseFileSearchCallInProgressChunkSchema = z11.object({
|
|
3256
|
+
type: z11.literal("response.file_search_call.in_progress"),
|
|
3257
|
+
sequence_number: z11.number(),
|
|
3258
|
+
output_index: z11.number(),
|
|
3259
|
+
item_id: z11.string()
|
|
3260
|
+
});
|
|
3261
|
+
var responseFileSearchCallSearchingChunkSchema = z11.object({
|
|
3262
|
+
type: z11.literal("response.file_search_call.searching"),
|
|
3263
|
+
sequence_number: z11.number(),
|
|
3264
|
+
output_index: z11.number(),
|
|
3265
|
+
item_id: z11.string()
|
|
3266
|
+
});
|
|
3267
|
+
var responseFileSearchCallCompletedChunkSchema = z11.object({
|
|
3268
|
+
type: z11.literal("response.file_search_call.completed"),
|
|
3269
|
+
sequence_number: z11.number(),
|
|
3270
|
+
output_index: z11.number(),
|
|
3271
|
+
item_id: z11.string()
|
|
3272
|
+
});
|
|
3273
|
+
var responseFileSearchCallQueryAddedChunkSchema = z11.object({
|
|
3274
|
+
type: z11.literal("response.file_search_call.query.added"),
|
|
3275
|
+
sequence_number: z11.number(),
|
|
3276
|
+
output_index: z11.number(),
|
|
3277
|
+
item_id: z11.string(),
|
|
3278
|
+
query: z11.string()
|
|
3279
|
+
});
|
|
3280
|
+
var responseFileSearchCallResultAddedChunkSchema = z11.object({
|
|
3281
|
+
type: z11.literal("response.file_search_call.result.added"),
|
|
3282
|
+
sequence_number: z11.number(),
|
|
3283
|
+
output_index: z11.number(),
|
|
3284
|
+
item_id: z11.string(),
|
|
3285
|
+
result: z11.any()
|
|
3286
|
+
});
|
|
3183
3287
|
var openaiResponsesChunkSchema = z11.union([
|
|
3184
3288
|
textDeltaChunkSchema,
|
|
3185
3289
|
responseFinishedChunkSchema,
|
|
@@ -3189,6 +3293,15 @@ var openaiResponsesChunkSchema = z11.union([
|
|
|
3189
3293
|
responseOutputItemAddedSchema,
|
|
3190
3294
|
responseAnnotationAddedSchema,
|
|
3191
3295
|
responseReasoningSummaryTextDeltaSchema,
|
|
3296
|
+
responseInProgressChunkSchema,
|
|
3297
|
+
responseContentPartAddedChunkSchema,
|
|
3298
|
+
responseOutputTextDoneChunkSchema,
|
|
3299
|
+
responseContentPartDoneChunkSchema,
|
|
3300
|
+
responseFileSearchCallInProgressChunkSchema,
|
|
3301
|
+
responseFileSearchCallSearchingChunkSchema,
|
|
3302
|
+
responseFileSearchCallCompletedChunkSchema,
|
|
3303
|
+
responseFileSearchCallQueryAddedChunkSchema,
|
|
3304
|
+
responseFileSearchCallResultAddedChunkSchema,
|
|
3192
3305
|
z11.object({ type: z11.string() }).passthrough()
|
|
3193
3306
|
// fallback for unknown chunks
|
|
3194
3307
|
]);
|
|
@@ -3216,6 +3329,33 @@ function isResponseAnnotationAddedChunk(chunk) {
|
|
|
3216
3329
|
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
3217
3330
|
return chunk.type === "response.reasoning_summary_text.delta";
|
|
3218
3331
|
}
|
|
3332
|
+
function isResponseInProgressChunk(chunk) {
|
|
3333
|
+
return chunk.type === "response.in_progress";
|
|
3334
|
+
}
|
|
3335
|
+
function isResponseContentPartAddedChunk(chunk) {
|
|
3336
|
+
return chunk.type === "response.content_part.added";
|
|
3337
|
+
}
|
|
3338
|
+
function isResponseOutputTextDoneChunk(chunk) {
|
|
3339
|
+
return chunk.type === "response.output_text.done";
|
|
3340
|
+
}
|
|
3341
|
+
function isResponseContentPartDoneChunk(chunk) {
|
|
3342
|
+
return chunk.type === "response.content_part.done";
|
|
3343
|
+
}
|
|
3344
|
+
function isResponseFileSearchCallInProgressChunk(chunk) {
|
|
3345
|
+
return chunk.type === "response.file_search_call.in_progress";
|
|
3346
|
+
}
|
|
3347
|
+
function isResponseFileSearchCallSearchingChunk(chunk) {
|
|
3348
|
+
return chunk.type === "response.file_search_call.searching";
|
|
3349
|
+
}
|
|
3350
|
+
function isResponseFileSearchCallCompletedChunk(chunk) {
|
|
3351
|
+
return chunk.type === "response.file_search_call.completed";
|
|
3352
|
+
}
|
|
3353
|
+
function isResponseFileSearchCallQueryAddedChunk(chunk) {
|
|
3354
|
+
return chunk.type === "response.file_search_call.query.added";
|
|
3355
|
+
}
|
|
3356
|
+
function isResponseFileSearchCallResultAddedChunk(chunk) {
|
|
3357
|
+
return chunk.type === "response.file_search_call.result.added";
|
|
3358
|
+
}
|
|
3219
3359
|
function getResponsesModelConfig(modelId) {
|
|
3220
3360
|
if (modelId.startsWith("o")) {
|
|
3221
3361
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|