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