@openrouter/ai-sdk-provider 2.6.0 → 2.7.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.d.mts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +31 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -28
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +34 -0
- package/dist/internal/index.d.ts +34 -0
- package/dist/internal/index.js +30 -27
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +30 -27
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -3277,7 +3277,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3277
3277
|
tools,
|
|
3278
3278
|
toolChoice
|
|
3279
3279
|
}) {
|
|
3280
|
-
var _a16;
|
|
3280
|
+
var _a16, _b16;
|
|
3281
3281
|
const baseArgs = __spreadValues(__spreadValues({
|
|
3282
3282
|
// model id:
|
|
3283
3283
|
model: this.modelId,
|
|
@@ -3288,12 +3288,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3288
3288
|
top_logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : void 0 : void 0,
|
|
3289
3289
|
user: this.settings.user,
|
|
3290
3290
|
parallel_tool_calls: this.settings.parallelToolCalls,
|
|
3291
|
-
// standardized settings:
|
|
3292
|
-
max_tokens: maxOutputTokens,
|
|
3293
|
-
temperature,
|
|
3294
|
-
top_p: topP,
|
|
3295
|
-
frequency_penalty: frequencyPenalty,
|
|
3296
|
-
presence_penalty: presencePenalty,
|
|
3291
|
+
// standardized settings (call-level options override model-level settings):
|
|
3292
|
+
max_tokens: maxOutputTokens != null ? maxOutputTokens : this.settings.maxTokens,
|
|
3293
|
+
temperature: temperature != null ? temperature : this.settings.temperature,
|
|
3294
|
+
top_p: topP != null ? topP : this.settings.topP,
|
|
3295
|
+
frequency_penalty: frequencyPenalty != null ? frequencyPenalty : this.settings.frequencyPenalty,
|
|
3296
|
+
presence_penalty: presencePenalty != null ? presencePenalty : this.settings.presencePenalty,
|
|
3297
3297
|
seed,
|
|
3298
3298
|
stop: stopSequences,
|
|
3299
3299
|
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? responseFormat.schema != null ? {
|
|
@@ -3306,7 +3306,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3306
3306
|
description: responseFormat.description
|
|
3307
3307
|
})
|
|
3308
3308
|
} : { type: "json_object" } : void 0,
|
|
3309
|
-
top_k: topK,
|
|
3309
|
+
top_k: topK != null ? topK : this.settings.topK,
|
|
3310
3310
|
// messages:
|
|
3311
3311
|
messages: convertToOpenRouterChatMessages(prompt),
|
|
3312
3312
|
// OpenRouter specific settings:
|
|
@@ -3327,14 +3327,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3327
3327
|
const mappedTools = [];
|
|
3328
3328
|
for (const tool of tools) {
|
|
3329
3329
|
if (tool.type === "function") {
|
|
3330
|
-
|
|
3330
|
+
const openrouterOptions = (_b16 = tool.providerOptions) == null ? void 0 : _b16.openrouter;
|
|
3331
|
+
const eagerInputStreaming = openrouterOptions == null ? void 0 : openrouterOptions.eager_input_streaming;
|
|
3332
|
+
mappedTools.push(__spreadValues({
|
|
3331
3333
|
type: "function",
|
|
3332
3334
|
function: {
|
|
3333
3335
|
name: tool.name,
|
|
3334
3336
|
description: tool.description,
|
|
3335
3337
|
parameters: tool.inputSchema
|
|
3336
3338
|
}
|
|
3337
|
-
}
|
|
3339
|
+
}, eagerInputStreaming != null && {
|
|
3340
|
+
eager_input_streaming: eagerInputStreaming
|
|
3341
|
+
}));
|
|
3338
3342
|
} else if (tool.type === "provider") {
|
|
3339
3343
|
mappedTools.push(mapProviderTool(tool));
|
|
3340
3344
|
}
|
|
@@ -3672,18 +3676,16 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3672
3676
|
return;
|
|
3673
3677
|
}
|
|
3674
3678
|
const delta = choice.delta;
|
|
3675
|
-
const emitReasoningChunk = (chunkText
|
|
3679
|
+
const emitReasoningChunk = (chunkText) => {
|
|
3676
3680
|
if (!reasoningStarted) {
|
|
3677
3681
|
reasoningId = generateId();
|
|
3678
3682
|
controller.enqueue({
|
|
3679
|
-
providerMetadata,
|
|
3680
3683
|
type: "reasoning-start",
|
|
3681
3684
|
id: reasoningId
|
|
3682
3685
|
});
|
|
3683
3686
|
reasoningStarted = true;
|
|
3684
3687
|
}
|
|
3685
3688
|
controller.enqueue({
|
|
3686
|
-
providerMetadata,
|
|
3687
3689
|
type: "reasoning-delta",
|
|
3688
3690
|
delta: chunkText,
|
|
3689
3691
|
id: reasoningId || generateId()
|
|
@@ -3705,15 +3707,10 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3705
3707
|
}
|
|
3706
3708
|
}
|
|
3707
3709
|
if (!textStarted) {
|
|
3708
|
-
const reasoningMetadata = {
|
|
3709
|
-
openrouter: {
|
|
3710
|
-
reasoning_details: accumulatedReasoningDetails.map((d) => __spreadValues({}, d))
|
|
3711
|
-
}
|
|
3712
|
-
};
|
|
3713
3710
|
for (const detail of delta.reasoning_details) {
|
|
3714
3711
|
switch (detail.type) {
|
|
3715
3712
|
case "reasoning.text" /* Text */: {
|
|
3716
|
-
emitReasoningChunk(detail.text || ""
|
|
3713
|
+
emitReasoningChunk(detail.text || "");
|
|
3717
3714
|
break;
|
|
3718
3715
|
}
|
|
3719
3716
|
case "reasoning.encrypted" /* Encrypted */: {
|
|
@@ -3721,7 +3718,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3721
3718
|
}
|
|
3722
3719
|
case "reasoning.summary" /* Summary */: {
|
|
3723
3720
|
if (detail.summary) {
|
|
3724
|
-
emitReasoningChunk(detail.summary
|
|
3721
|
+
emitReasoningChunk(detail.summary);
|
|
3725
3722
|
}
|
|
3726
3723
|
break;
|
|
3727
3724
|
}
|
|
@@ -4010,6 +4007,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
4010
4007
|
if (accumulatedFileAnnotations.length > 0) {
|
|
4011
4008
|
openrouterMetadata.annotations = accumulatedFileAnnotations;
|
|
4012
4009
|
}
|
|
4010
|
+
if (usage.inputTokens.total === void 0 && openrouterUsage.promptTokens !== void 0) {
|
|
4011
|
+
usage.inputTokens.total = openrouterUsage.promptTokens;
|
|
4012
|
+
}
|
|
4013
|
+
if (usage.outputTokens.total === void 0 && openrouterUsage.completionTokens !== void 0) {
|
|
4014
|
+
usage.outputTokens.total = openrouterUsage.completionTokens;
|
|
4015
|
+
}
|
|
4013
4016
|
usage.raw = rawUsage;
|
|
4014
4017
|
controller.enqueue({
|
|
4015
4018
|
type: "finish",
|
|
@@ -4245,16 +4248,16 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
4245
4248
|
logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : void 0 : void 0,
|
|
4246
4249
|
suffix: this.settings.suffix,
|
|
4247
4250
|
user: this.settings.user,
|
|
4248
|
-
// standardized settings:
|
|
4249
|
-
max_tokens: maxOutputTokens,
|
|
4250
|
-
temperature,
|
|
4251
|
-
top_p: topP,
|
|
4252
|
-
frequency_penalty: frequencyPenalty,
|
|
4253
|
-
presence_penalty: presencePenalty,
|
|
4251
|
+
// standardized settings (call-level options override model-level settings):
|
|
4252
|
+
max_tokens: maxOutputTokens != null ? maxOutputTokens : this.settings.maxTokens,
|
|
4253
|
+
temperature: temperature != null ? temperature : this.settings.temperature,
|
|
4254
|
+
top_p: topP != null ? topP : this.settings.topP,
|
|
4255
|
+
frequency_penalty: frequencyPenalty != null ? frequencyPenalty : this.settings.frequencyPenalty,
|
|
4256
|
+
presence_penalty: presencePenalty != null ? presencePenalty : this.settings.presencePenalty,
|
|
4254
4257
|
seed,
|
|
4255
4258
|
stop: stopSequences,
|
|
4256
4259
|
response_format: responseFormat,
|
|
4257
|
-
top_k: topK,
|
|
4260
|
+
top_k: topK != null ? topK : this.settings.topK,
|
|
4258
4261
|
// prompt:
|
|
4259
4262
|
prompt: completionPrompt,
|
|
4260
4263
|
// OpenRouter specific settings:
|