@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/internal/dist/index.mjs
CHANGED
|
@@ -2847,7 +2847,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2847
2847
|
stream: response.pipeThrough(
|
|
2848
2848
|
new TransformStream({
|
|
2849
2849
|
transform(chunk, controller) {
|
|
2850
|
-
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2850
|
+
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2851
2851
|
try {
|
|
2852
2852
|
console.log("\u{1F4E6} Processing chunk:", JSON.stringify(chunk, null, 2));
|
|
2853
2853
|
if (!chunk.success) {
|
|
@@ -2975,58 +2975,79 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2975
2975
|
args: ""
|
|
2976
2976
|
});
|
|
2977
2977
|
} else if (value.item.type === "file_search_call") {
|
|
2978
|
+
console.log("\u{1F4C1} File search call completed:", JSON.stringify({
|
|
2979
|
+
id: value.item.id,
|
|
2980
|
+
status: value.item.status,
|
|
2981
|
+
queries: value.item.queries,
|
|
2982
|
+
resultsCount: ((_a15 = value.item.results) == null ? void 0 : _a15.length) || 0
|
|
2983
|
+
}, null, 2));
|
|
2978
2984
|
ongoingToolCalls[value.output_index] = void 0;
|
|
2979
2985
|
hasToolCalls = true;
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2986
|
+
try {
|
|
2987
|
+
controller.enqueue({
|
|
2988
|
+
type: "tool-call",
|
|
2989
|
+
toolCallType: "function",
|
|
2990
|
+
toolCallId: value.item.id,
|
|
2991
|
+
toolName: "file_search",
|
|
2992
|
+
args: JSON.stringify({
|
|
2993
|
+
queries: value.item.queries,
|
|
2994
|
+
results: value.item.results
|
|
2995
|
+
})
|
|
2996
|
+
});
|
|
2997
|
+
console.log("\u2705 File search tool call enqueued successfully");
|
|
2998
|
+
} catch (error) {
|
|
2999
|
+
console.error("\u274C Error enqueuing file search tool call:", error);
|
|
3000
|
+
}
|
|
2990
3001
|
}
|
|
2991
3002
|
} else if (isResponseFinishedChunk(value)) {
|
|
2992
3003
|
console.log("\u{1F3C1} Response finished:", JSON.stringify(value, null, 2));
|
|
2993
3004
|
finishReason = mapOpenAIResponseFinishReason({
|
|
2994
|
-
finishReason: (
|
|
3005
|
+
finishReason: (_b = value.response.incomplete_details) == null ? void 0 : _b.reason,
|
|
2995
3006
|
hasToolCalls
|
|
2996
3007
|
});
|
|
2997
3008
|
promptTokens = value.response.usage.input_tokens;
|
|
2998
3009
|
completionTokens = value.response.usage.output_tokens;
|
|
2999
|
-
cachedPromptTokens = (
|
|
3000
|
-
reasoningTokens = (
|
|
3010
|
+
cachedPromptTokens = (_d = (_c = value.response.usage.input_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : cachedPromptTokens;
|
|
3011
|
+
reasoningTokens = (_f = (_e = value.response.usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : reasoningTokens;
|
|
3001
3012
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
3002
3013
|
console.log("\u{1F50D} Processing annotation chunk:", JSON.stringify({
|
|
3003
3014
|
type: value.type,
|
|
3004
3015
|
annotation: value.annotation
|
|
3005
3016
|
}, null, 2));
|
|
3006
3017
|
try {
|
|
3018
|
+
console.log("\u{1F50D} Annotation processing - step 1: Validating annotation structure");
|
|
3019
|
+
if (!value.annotation || typeof value.annotation !== "object") {
|
|
3020
|
+
throw new Error("Invalid annotation structure");
|
|
3021
|
+
}
|
|
3022
|
+
console.log("\u{1F50D} Annotation processing - step 2: Checking annotation type");
|
|
3007
3023
|
if (value.annotation.type === "url_citation") {
|
|
3024
|
+
console.log("\u{1F310} Processing URL citation");
|
|
3008
3025
|
const urlSource = {
|
|
3009
3026
|
sourceType: "url",
|
|
3010
|
-
id: (
|
|
3011
|
-
url: value.annotation.url,
|
|
3012
|
-
title: value.annotation.title
|
|
3027
|
+
id: (_i = (_h = (_g = self.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
|
|
3028
|
+
url: String(value.annotation.url || ""),
|
|
3029
|
+
title: String(value.annotation.title || "Web Source")
|
|
3013
3030
|
};
|
|
3014
|
-
console.log("\u2705
|
|
3031
|
+
console.log("\u2705 Created URL source:", JSON.stringify(urlSource, null, 2));
|
|
3032
|
+
console.log("\u{1F50D} Annotation processing - step 3: Enqueuing URL source");
|
|
3015
3033
|
controller.enqueue({
|
|
3016
3034
|
type: "source",
|
|
3017
3035
|
source: urlSource
|
|
3018
3036
|
});
|
|
3019
3037
|
console.log("\u2705 URL source enqueued successfully");
|
|
3020
3038
|
} else if (value.annotation.type === "file_citation") {
|
|
3039
|
+
console.log("\u{1F4C4} Processing FILE citation - this is where the error likely occurs");
|
|
3040
|
+
console.log("\u{1F4C4} File citation raw data:", JSON.stringify(value.annotation, null, 2));
|
|
3021
3041
|
const documentSource = {
|
|
3022
3042
|
sourceType: "document",
|
|
3023
|
-
id: (
|
|
3043
|
+
id: (_l = (_k = (_j = self.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
|
|
3024
3044
|
mediaType: "text/plain",
|
|
3025
|
-
title: value.annotation.quote || value.annotation.filename || "Document",
|
|
3026
|
-
filename: value.annotation.filename,
|
|
3027
|
-
quote: value.annotation.quote
|
|
3045
|
+
title: String(value.annotation.quote || value.annotation.filename || "Document"),
|
|
3046
|
+
filename: value.annotation.filename ? String(value.annotation.filename) : void 0,
|
|
3047
|
+
quote: value.annotation.quote ? String(value.annotation.quote) : void 0
|
|
3028
3048
|
};
|
|
3029
|
-
console.log("\u{1F4C4}
|
|
3049
|
+
console.log("\u{1F4C4} Created document source:", JSON.stringify(documentSource, null, 2));
|
|
3050
|
+
console.log("\u{1F50D} Annotation processing - step 3: Enqueuing document source");
|
|
3030
3051
|
controller.enqueue({
|
|
3031
3052
|
type: "source",
|
|
3032
3053
|
source: documentSource
|
|
@@ -3036,12 +3057,33 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3036
3057
|
console.log("\u26A0\uFE0F Unknown annotation type:", value.annotation.type);
|
|
3037
3058
|
}
|
|
3038
3059
|
} catch (error) {
|
|
3039
|
-
console.error("\u274C
|
|
3060
|
+
console.error("\u274C CRITICAL ERROR in annotation processing:", {
|
|
3061
|
+
step: "annotation processing",
|
|
3040
3062
|
annotation: value.annotation,
|
|
3041
3063
|
error: error instanceof Error ? error.message : String(error),
|
|
3042
3064
|
stack: error instanceof Error ? error.stack : void 0
|
|
3043
3065
|
});
|
|
3066
|
+
console.log("\u{1F6E1}\uFE0F Continuing stream without this annotation to prevent total failure");
|
|
3044
3067
|
}
|
|
3068
|
+
} else if (isResponseInProgressChunk(value)) {
|
|
3069
|
+
console.log("\u23F3 Response in progress (ignored):", value.type);
|
|
3070
|
+
} else if (isResponseContentPartAddedChunk(value)) {
|
|
3071
|
+
console.log("\u{1F4DD} Content part added (ignored):", value.type);
|
|
3072
|
+
} else if (isResponseOutputTextDoneChunk(value)) {
|
|
3073
|
+
console.log("\u2705 Output text done (ignored):", value.type);
|
|
3074
|
+
} else if (isResponseContentPartDoneChunk(value)) {
|
|
3075
|
+
console.log("\u2705 Content part done (ignored):", value.type);
|
|
3076
|
+
} else if (isResponseFileSearchCallInProgressChunk(value)) {
|
|
3077
|
+
console.log("\u{1F50D} File search in progress (ignored):", value.type);
|
|
3078
|
+
} else if (isResponseFileSearchCallSearchingChunk(value)) {
|
|
3079
|
+
console.log("\u{1F50D} File search searching (ignored):", value.type);
|
|
3080
|
+
} else if (isResponseFileSearchCallCompletedChunk(value)) {
|
|
3081
|
+
console.log("\u2705 File search completed (ignored):", value.type);
|
|
3082
|
+
} else if (isResponseFileSearchCallQueryAddedChunk(value)) {
|
|
3083
|
+
console.log("\u{1F50D} File search query added (ignored):", value.type, "Query:", value.query);
|
|
3084
|
+
} else if (isResponseFileSearchCallResultAddedChunk(value)) {
|
|
3085
|
+
console.log("\u{1F4C4} File search result added (ignored):", value.type);
|
|
3086
|
+
console.log("\u{1F4C4} File search result details:", JSON.stringify(value.result, null, 2));
|
|
3045
3087
|
} else {
|
|
3046
3088
|
console.log("\u2753 Unhandled chunk type:", value.type, JSON.stringify(value, null, 2));
|
|
3047
3089
|
}
|
|
@@ -3246,6 +3288,68 @@ var responseReasoningSummaryTextDeltaSchema = z12.object({
|
|
|
3246
3288
|
summary_index: z12.number(),
|
|
3247
3289
|
delta: z12.string()
|
|
3248
3290
|
});
|
|
3291
|
+
var responseInProgressChunkSchema = z12.object({
|
|
3292
|
+
type: z12.literal("response.in_progress"),
|
|
3293
|
+
sequence_number: z12.number(),
|
|
3294
|
+
response: z12.any()
|
|
3295
|
+
});
|
|
3296
|
+
var responseContentPartAddedChunkSchema = z12.object({
|
|
3297
|
+
type: z12.literal("response.content_part.added"),
|
|
3298
|
+
sequence_number: z12.number(),
|
|
3299
|
+
item_id: z12.string(),
|
|
3300
|
+
output_index: z12.number(),
|
|
3301
|
+
content_index: z12.number(),
|
|
3302
|
+
part: z12.any()
|
|
3303
|
+
});
|
|
3304
|
+
var responseOutputTextDoneChunkSchema = z12.object({
|
|
3305
|
+
type: z12.literal("response.output_text.done"),
|
|
3306
|
+
sequence_number: z12.number(),
|
|
3307
|
+
item_id: z12.string(),
|
|
3308
|
+
output_index: z12.number(),
|
|
3309
|
+
content_index: z12.number(),
|
|
3310
|
+
text: z12.string(),
|
|
3311
|
+
logprobs: z12.array(z12.any()).optional()
|
|
3312
|
+
});
|
|
3313
|
+
var responseContentPartDoneChunkSchema = z12.object({
|
|
3314
|
+
type: z12.literal("response.content_part.done"),
|
|
3315
|
+
sequence_number: z12.number(),
|
|
3316
|
+
item_id: z12.string(),
|
|
3317
|
+
output_index: z12.number(),
|
|
3318
|
+
content_index: z12.number(),
|
|
3319
|
+
part: z12.any()
|
|
3320
|
+
});
|
|
3321
|
+
var responseFileSearchCallInProgressChunkSchema = z12.object({
|
|
3322
|
+
type: z12.literal("response.file_search_call.in_progress"),
|
|
3323
|
+
sequence_number: z12.number(),
|
|
3324
|
+
output_index: z12.number(),
|
|
3325
|
+
item_id: z12.string()
|
|
3326
|
+
});
|
|
3327
|
+
var responseFileSearchCallSearchingChunkSchema = z12.object({
|
|
3328
|
+
type: z12.literal("response.file_search_call.searching"),
|
|
3329
|
+
sequence_number: z12.number(),
|
|
3330
|
+
output_index: z12.number(),
|
|
3331
|
+
item_id: z12.string()
|
|
3332
|
+
});
|
|
3333
|
+
var responseFileSearchCallCompletedChunkSchema = z12.object({
|
|
3334
|
+
type: z12.literal("response.file_search_call.completed"),
|
|
3335
|
+
sequence_number: z12.number(),
|
|
3336
|
+
output_index: z12.number(),
|
|
3337
|
+
item_id: z12.string()
|
|
3338
|
+
});
|
|
3339
|
+
var responseFileSearchCallQueryAddedChunkSchema = z12.object({
|
|
3340
|
+
type: z12.literal("response.file_search_call.query.added"),
|
|
3341
|
+
sequence_number: z12.number(),
|
|
3342
|
+
output_index: z12.number(),
|
|
3343
|
+
item_id: z12.string(),
|
|
3344
|
+
query: z12.string()
|
|
3345
|
+
});
|
|
3346
|
+
var responseFileSearchCallResultAddedChunkSchema = z12.object({
|
|
3347
|
+
type: z12.literal("response.file_search_call.result.added"),
|
|
3348
|
+
sequence_number: z12.number(),
|
|
3349
|
+
output_index: z12.number(),
|
|
3350
|
+
item_id: z12.string(),
|
|
3351
|
+
result: z12.any()
|
|
3352
|
+
});
|
|
3249
3353
|
var openaiResponsesChunkSchema = z12.union([
|
|
3250
3354
|
textDeltaChunkSchema,
|
|
3251
3355
|
responseFinishedChunkSchema,
|
|
@@ -3255,6 +3359,15 @@ var openaiResponsesChunkSchema = z12.union([
|
|
|
3255
3359
|
responseOutputItemAddedSchema,
|
|
3256
3360
|
responseAnnotationAddedSchema,
|
|
3257
3361
|
responseReasoningSummaryTextDeltaSchema,
|
|
3362
|
+
responseInProgressChunkSchema,
|
|
3363
|
+
responseContentPartAddedChunkSchema,
|
|
3364
|
+
responseOutputTextDoneChunkSchema,
|
|
3365
|
+
responseContentPartDoneChunkSchema,
|
|
3366
|
+
responseFileSearchCallInProgressChunkSchema,
|
|
3367
|
+
responseFileSearchCallSearchingChunkSchema,
|
|
3368
|
+
responseFileSearchCallCompletedChunkSchema,
|
|
3369
|
+
responseFileSearchCallQueryAddedChunkSchema,
|
|
3370
|
+
responseFileSearchCallResultAddedChunkSchema,
|
|
3258
3371
|
z12.object({ type: z12.string() }).passthrough()
|
|
3259
3372
|
// fallback for unknown chunks
|
|
3260
3373
|
]);
|
|
@@ -3282,6 +3395,33 @@ function isResponseAnnotationAddedChunk(chunk) {
|
|
|
3282
3395
|
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
3283
3396
|
return chunk.type === "response.reasoning_summary_text.delta";
|
|
3284
3397
|
}
|
|
3398
|
+
function isResponseInProgressChunk(chunk) {
|
|
3399
|
+
return chunk.type === "response.in_progress";
|
|
3400
|
+
}
|
|
3401
|
+
function isResponseContentPartAddedChunk(chunk) {
|
|
3402
|
+
return chunk.type === "response.content_part.added";
|
|
3403
|
+
}
|
|
3404
|
+
function isResponseOutputTextDoneChunk(chunk) {
|
|
3405
|
+
return chunk.type === "response.output_text.done";
|
|
3406
|
+
}
|
|
3407
|
+
function isResponseContentPartDoneChunk(chunk) {
|
|
3408
|
+
return chunk.type === "response.content_part.done";
|
|
3409
|
+
}
|
|
3410
|
+
function isResponseFileSearchCallInProgressChunk(chunk) {
|
|
3411
|
+
return chunk.type === "response.file_search_call.in_progress";
|
|
3412
|
+
}
|
|
3413
|
+
function isResponseFileSearchCallSearchingChunk(chunk) {
|
|
3414
|
+
return chunk.type === "response.file_search_call.searching";
|
|
3415
|
+
}
|
|
3416
|
+
function isResponseFileSearchCallCompletedChunk(chunk) {
|
|
3417
|
+
return chunk.type === "response.file_search_call.completed";
|
|
3418
|
+
}
|
|
3419
|
+
function isResponseFileSearchCallQueryAddedChunk(chunk) {
|
|
3420
|
+
return chunk.type === "response.file_search_call.query.added";
|
|
3421
|
+
}
|
|
3422
|
+
function isResponseFileSearchCallResultAddedChunk(chunk) {
|
|
3423
|
+
return chunk.type === "response.file_search_call.result.added";
|
|
3424
|
+
}
|
|
3285
3425
|
function getResponsesModelConfig(modelId) {
|
|
3286
3426
|
if (modelId.startsWith("o")) {
|
|
3287
3427
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|