@zenning/openai 2.2.0 → 2.3.0
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 +80 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -16
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +33 -1
- package/dist/internal/index.d.ts +33 -1
- package/dist/internal/index.js +85 -17
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +82 -16
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2720,6 +2720,11 @@ var localShellCallItem = z19.object({
|
|
|
2720
2720
|
env: z19.record(z19.string(), z19.string()).optional()
|
|
2721
2721
|
})
|
|
2722
2722
|
});
|
|
2723
|
+
var sourceExecutionFileCodeInterpreterItem = z19.object({
|
|
2724
|
+
containerId: z19.string(),
|
|
2725
|
+
fileId: z19.string(),
|
|
2726
|
+
filename: z19.string()
|
|
2727
|
+
});
|
|
2723
2728
|
var imageGenerationCallItem = z19.object({
|
|
2724
2729
|
type: z19.literal("image_generation_call"),
|
|
2725
2730
|
id: z19.string(),
|
|
@@ -2945,7 +2950,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2945
2950
|
};
|
|
2946
2951
|
}
|
|
2947
2952
|
async doGenerate(options) {
|
|
2948
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2953
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
2949
2954
|
const {
|
|
2950
2955
|
args: body,
|
|
2951
2956
|
warnings,
|
|
@@ -2955,6 +2960,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2955
2960
|
path: "/responses",
|
|
2956
2961
|
modelId: this.modelId
|
|
2957
2962
|
});
|
|
2963
|
+
const providerKey = this.config.provider.replace(".responses", "");
|
|
2958
2964
|
const {
|
|
2959
2965
|
responseHeaders,
|
|
2960
2966
|
value: response,
|
|
@@ -3003,7 +3009,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3003
3009
|
quote: z19.string().nullish()
|
|
3004
3010
|
}),
|
|
3005
3011
|
z19.object({
|
|
3006
|
-
type: z19.literal("container_file_citation")
|
|
3012
|
+
type: z19.literal("container_file_citation"),
|
|
3013
|
+
container_id: z19.string(),
|
|
3014
|
+
end_index: z19.number(),
|
|
3015
|
+
file_id: z19.string(),
|
|
3016
|
+
filename: z19.string(),
|
|
3017
|
+
start_index: z19.number()
|
|
3007
3018
|
})
|
|
3008
3019
|
])
|
|
3009
3020
|
)
|
|
@@ -3125,7 +3136,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3125
3136
|
text: contentPart.text,
|
|
3126
3137
|
providerMetadata: {
|
|
3127
3138
|
openai: {
|
|
3128
|
-
itemId: part.id
|
|
3139
|
+
itemId: part.id,
|
|
3140
|
+
annotations: contentPart.annotations
|
|
3129
3141
|
}
|
|
3130
3142
|
}
|
|
3131
3143
|
});
|
|
@@ -3150,6 +3162,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3150
3162
|
startIndex: (_m = annotation.start_index) != null ? _m : void 0,
|
|
3151
3163
|
endIndex: (_n = annotation.end_index) != null ? _n : void 0
|
|
3152
3164
|
});
|
|
3165
|
+
} else if (annotation.type === "container_file_citation") {
|
|
3166
|
+
content.push({
|
|
3167
|
+
type: "source",
|
|
3168
|
+
sourceType: "executionFile",
|
|
3169
|
+
id: (_q = (_p = (_o = this.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : generateId2(),
|
|
3170
|
+
providerMetadata: {
|
|
3171
|
+
[providerKey]: {
|
|
3172
|
+
containerId: annotation.container_id,
|
|
3173
|
+
fileId: annotation.file_id,
|
|
3174
|
+
filename: annotation.filename
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
});
|
|
3153
3178
|
}
|
|
3154
3179
|
}
|
|
3155
3180
|
}
|
|
@@ -3221,13 +3246,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3221
3246
|
toolName: "file_search",
|
|
3222
3247
|
result: {
|
|
3223
3248
|
queries: part.queries,
|
|
3224
|
-
results: (
|
|
3249
|
+
results: (_s = (_r = part.results) == null ? void 0 : _r.map((result) => ({
|
|
3225
3250
|
attributes: result.attributes,
|
|
3226
3251
|
fileId: result.file_id,
|
|
3227
3252
|
filename: result.filename,
|
|
3228
3253
|
score: result.score,
|
|
3229
3254
|
text: result.text
|
|
3230
|
-
}))) != null ?
|
|
3255
|
+
}))) != null ? _s : null
|
|
3231
3256
|
},
|
|
3232
3257
|
providerExecuted: true
|
|
3233
3258
|
});
|
|
@@ -3269,15 +3294,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3269
3294
|
return {
|
|
3270
3295
|
content,
|
|
3271
3296
|
finishReason: mapOpenAIResponseFinishReason({
|
|
3272
|
-
finishReason: (
|
|
3297
|
+
finishReason: (_t = response.incomplete_details) == null ? void 0 : _t.reason,
|
|
3273
3298
|
hasFunctionCall
|
|
3274
3299
|
}),
|
|
3275
3300
|
usage: {
|
|
3276
3301
|
inputTokens: response.usage.input_tokens,
|
|
3277
3302
|
outputTokens: response.usage.output_tokens,
|
|
3278
3303
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
3279
|
-
reasoningTokens: (
|
|
3280
|
-
cachedInputTokens: (
|
|
3304
|
+
reasoningTokens: (_v = (_u = response.usage.output_tokens_details) == null ? void 0 : _u.reasoning_tokens) != null ? _v : void 0,
|
|
3305
|
+
cachedInputTokens: (_x = (_w = response.usage.input_tokens_details) == null ? void 0 : _w.cached_tokens) != null ? _x : void 0
|
|
3281
3306
|
},
|
|
3282
3307
|
request: { body },
|
|
3283
3308
|
response: {
|
|
@@ -3324,6 +3349,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3324
3349
|
const logprobs = [];
|
|
3325
3350
|
let responseId = null;
|
|
3326
3351
|
const ongoingToolCalls = {};
|
|
3352
|
+
const ongoingAnnotations = [];
|
|
3327
3353
|
let hasFunctionCall = false;
|
|
3328
3354
|
const activeReasoning = {};
|
|
3329
3355
|
let serviceTier;
|
|
@@ -3334,7 +3360,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3334
3360
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3335
3361
|
},
|
|
3336
3362
|
transform(chunk, controller) {
|
|
3337
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
3363
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
3338
3364
|
if (options.includeRawChunks) {
|
|
3339
3365
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3340
3366
|
}
|
|
@@ -3410,6 +3436,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3410
3436
|
providerExecuted: true
|
|
3411
3437
|
});
|
|
3412
3438
|
} else if (value.item.type === "message") {
|
|
3439
|
+
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
3413
3440
|
controller.enqueue({
|
|
3414
3441
|
type: "text-start",
|
|
3415
3442
|
id: value.item.id,
|
|
@@ -3435,7 +3462,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3435
3462
|
}
|
|
3436
3463
|
});
|
|
3437
3464
|
}
|
|
3438
|
-
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
3465
|
+
} else if (isResponseOutputItemDoneChunk(value) && value.item.type !== "message") {
|
|
3439
3466
|
if (value.item.type === "function_call") {
|
|
3440
3467
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3441
3468
|
hasFunctionCall = true;
|
|
@@ -3556,11 +3583,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3556
3583
|
openai: { itemId: value.item.id }
|
|
3557
3584
|
}
|
|
3558
3585
|
});
|
|
3559
|
-
} else if (value.item.type === "message") {
|
|
3560
|
-
controller.enqueue({
|
|
3561
|
-
type: "text-end",
|
|
3562
|
-
id: value.item.id
|
|
3563
|
-
});
|
|
3564
3586
|
} else if (isResponseOutputItemDoneReasoningChunk(value)) {
|
|
3565
3587
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
3566
3588
|
for (const summaryIndex of activeReasoningPart.summaryParts) {
|
|
@@ -3689,6 +3711,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3689
3711
|
serviceTier = value.response.service_tier;
|
|
3690
3712
|
}
|
|
3691
3713
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
3714
|
+
ongoingAnnotations.push(value.annotation);
|
|
3692
3715
|
if (value.annotation.type === "url_citation") {
|
|
3693
3716
|
controller.enqueue({
|
|
3694
3717
|
type: "source",
|
|
@@ -3709,7 +3732,31 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3709
3732
|
startIndex: (_x = value.annotation.start_index) != null ? _x : void 0,
|
|
3710
3733
|
endIndex: (_y = value.annotation.end_index) != null ? _y : void 0
|
|
3711
3734
|
});
|
|
3735
|
+
} else if (value.annotation.type === "container_file_citation") {
|
|
3736
|
+
controller.enqueue({
|
|
3737
|
+
type: "source",
|
|
3738
|
+
sourceType: "executionFile",
|
|
3739
|
+
id: (_B = (_A = (_z = self.config).generateId) == null ? void 0 : _A.call(_z)) != null ? _B : generateId2(),
|
|
3740
|
+
providerMetadata: {
|
|
3741
|
+
openai: {
|
|
3742
|
+
containerId: value.annotation.container_id,
|
|
3743
|
+
fileId: value.annotation.file_id,
|
|
3744
|
+
filename: value.annotation.filename
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
});
|
|
3712
3748
|
}
|
|
3749
|
+
} else if (isResponseOutputItemDoneChunk(value) && value.item.type === "message") {
|
|
3750
|
+
controller.enqueue({
|
|
3751
|
+
type: "text-end",
|
|
3752
|
+
id: value.item.id,
|
|
3753
|
+
providerMetadata: {
|
|
3754
|
+
openai: {
|
|
3755
|
+
itemId: value.item.id,
|
|
3756
|
+
annotations: ongoingAnnotations
|
|
3757
|
+
}
|
|
3758
|
+
}
|
|
3759
|
+
});
|
|
3713
3760
|
} else if (isErrorChunk(value)) {
|
|
3714
3761
|
controller.enqueue({ type: "error", error: value });
|
|
3715
3762
|
}
|
|
@@ -3906,6 +3953,14 @@ var responseAnnotationAddedSchema = z19.object({
|
|
|
3906
3953
|
start_index: z19.number().nullish(),
|
|
3907
3954
|
end_index: z19.number().nullish(),
|
|
3908
3955
|
quote: z19.string().nullish()
|
|
3956
|
+
}),
|
|
3957
|
+
z19.object({
|
|
3958
|
+
type: z19.literal("container_file_citation"),
|
|
3959
|
+
container_id: z19.string(),
|
|
3960
|
+
end_index: z19.number(),
|
|
3961
|
+
file_id: z19.string(),
|
|
3962
|
+
filename: z19.string(),
|
|
3963
|
+
start_index: z19.number()
|
|
3909
3964
|
})
|
|
3910
3965
|
])
|
|
3911
3966
|
});
|
|
@@ -4057,6 +4112,15 @@ var openaiResponsesProviderOptionsSchema = z19.object({
|
|
|
4057
4112
|
textVerbosity: z19.enum(["low", "medium", "high"]).nullish(),
|
|
4058
4113
|
user: z19.string().nullish()
|
|
4059
4114
|
});
|
|
4115
|
+
var openaiResponsesTextUIPartProviderMetadataSchema = z19.object({
|
|
4116
|
+
openai: z19.object({
|
|
4117
|
+
itemId: z19.string(),
|
|
4118
|
+
annotations: z19.array(responseAnnotationAddedSchema.shape.annotation)
|
|
4119
|
+
})
|
|
4120
|
+
});
|
|
4121
|
+
var openaiSourceExecutionFileProviderMetadataSchema = z19.object({
|
|
4122
|
+
openai: sourceExecutionFileCodeInterpreterItem
|
|
4123
|
+
});
|
|
4060
4124
|
export {
|
|
4061
4125
|
OpenAIChatLanguageModel,
|
|
4062
4126
|
OpenAICompletionLanguageModel,
|
|
@@ -4081,6 +4145,8 @@ export {
|
|
|
4081
4145
|
openAITranscriptionProviderOptions,
|
|
4082
4146
|
openaiChatLanguageModelOptions,
|
|
4083
4147
|
openaiCompletionProviderOptions,
|
|
4084
|
-
openaiEmbeddingProviderOptions
|
|
4148
|
+
openaiEmbeddingProviderOptions,
|
|
4149
|
+
openaiResponsesTextUIPartProviderMetadataSchema,
|
|
4150
|
+
openaiSourceExecutionFileProviderMetadataSchema
|
|
4085
4151
|
};
|
|
4086
4152
|
//# sourceMappingURL=index.mjs.map
|