@openrouter/ai-sdk-provider 1.0.0-beta.5 → 1.0.0-beta.7
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/README.md +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +30 -21
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +30 -21
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -139,7 +139,7 @@ type OpenRouterChatSettings = {
|
|
|
139
139
|
/**
|
|
140
140
|
Return the log probabilities of the tokens. Including logprobs will increase
|
|
141
141
|
the response size and can slow down response times. However, it can
|
|
142
|
-
be useful to better
|
|
142
|
+
be useful to understand better how the model is behaving.
|
|
143
143
|
|
|
144
144
|
Setting to true will return the log probabilities of the tokens that
|
|
145
145
|
were generated.
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -139,7 +139,7 @@ type OpenRouterChatSettings = {
|
|
|
139
139
|
/**
|
|
140
140
|
Return the log probabilities of the tokens. Including logprobs will increase
|
|
141
141
|
the response size and can slow down response times. However, it can
|
|
142
|
-
be useful to better
|
|
142
|
+
be useful to understand better how the model is behaving.
|
|
143
143
|
|
|
144
144
|
Setting to true will return the log probabilities of the tokens that
|
|
145
145
|
were generated.
|
package/dist/internal/index.js
CHANGED
|
@@ -1309,6 +1309,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1309
1309
|
tools,
|
|
1310
1310
|
toolChoice
|
|
1311
1311
|
}) {
|
|
1312
|
+
var _a15;
|
|
1312
1313
|
const baseArgs = __spreadValues(__spreadValues({
|
|
1313
1314
|
// model id:
|
|
1314
1315
|
model: this.modelId,
|
|
@@ -1336,9 +1337,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1336
1337
|
reasoning: this.settings.reasoning,
|
|
1337
1338
|
usage: this.settings.usage
|
|
1338
1339
|
}, this.config.extraBody), this.settings.extraBody);
|
|
1339
|
-
if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
|
|
1340
|
+
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
|
|
1340
1341
|
return __spreadProps(__spreadValues({}, baseArgs), {
|
|
1341
|
-
response_format: {
|
|
1342
|
+
response_format: {
|
|
1343
|
+
type: "json_schema",
|
|
1344
|
+
json_schema: __spreadValues({
|
|
1345
|
+
schema: responseFormat.schema,
|
|
1346
|
+
strict: true,
|
|
1347
|
+
name: (_a15 = responseFormat.name) != null ? _a15 : "response"
|
|
1348
|
+
}, responseFormat.description && {
|
|
1349
|
+
description: responseFormat.description
|
|
1350
|
+
})
|
|
1351
|
+
}
|
|
1342
1352
|
});
|
|
1343
1353
|
}
|
|
1344
1354
|
if (tools && tools.length > 0) {
|
|
@@ -1584,21 +1594,6 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1584
1594
|
return;
|
|
1585
1595
|
}
|
|
1586
1596
|
const delta = choice.delta;
|
|
1587
|
-
if (delta.content != null) {
|
|
1588
|
-
if (!textStarted) {
|
|
1589
|
-
textId = openrouterResponseId || generateId();
|
|
1590
|
-
controller.enqueue({
|
|
1591
|
-
type: "text-start",
|
|
1592
|
-
id: textId
|
|
1593
|
-
});
|
|
1594
|
-
textStarted = true;
|
|
1595
|
-
}
|
|
1596
|
-
controller.enqueue({
|
|
1597
|
-
type: "text-delta",
|
|
1598
|
-
delta: delta.content,
|
|
1599
|
-
id: textId || generateId()
|
|
1600
|
-
});
|
|
1601
|
-
}
|
|
1602
1597
|
const emitReasoningChunk = (chunkText) => {
|
|
1603
1598
|
if (!reasoningStarted) {
|
|
1604
1599
|
reasoningId = openrouterResponseId || generateId();
|
|
@@ -1614,9 +1609,6 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1614
1609
|
id: reasoningId || generateId()
|
|
1615
1610
|
});
|
|
1616
1611
|
};
|
|
1617
|
-
if (delta.reasoning != null) {
|
|
1618
|
-
emitReasoningChunk(delta.reasoning);
|
|
1619
|
-
}
|
|
1620
1612
|
if (delta.reasoning_details && delta.reasoning_details.length > 0) {
|
|
1621
1613
|
for (const detail of delta.reasoning_details) {
|
|
1622
1614
|
switch (detail.type) {
|
|
@@ -1644,6 +1636,23 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1644
1636
|
}
|
|
1645
1637
|
}
|
|
1646
1638
|
}
|
|
1639
|
+
} else if (delta.reasoning != null) {
|
|
1640
|
+
emitReasoningChunk(delta.reasoning);
|
|
1641
|
+
}
|
|
1642
|
+
if (delta.content != null) {
|
|
1643
|
+
if (!textStarted) {
|
|
1644
|
+
textId = openrouterResponseId || generateId();
|
|
1645
|
+
controller.enqueue({
|
|
1646
|
+
type: "text-start",
|
|
1647
|
+
id: textId
|
|
1648
|
+
});
|
|
1649
|
+
textStarted = true;
|
|
1650
|
+
}
|
|
1651
|
+
controller.enqueue({
|
|
1652
|
+
type: "text-delta",
|
|
1653
|
+
delta: delta.content,
|
|
1654
|
+
id: textId || generateId()
|
|
1655
|
+
});
|
|
1647
1656
|
}
|
|
1648
1657
|
if (delta.tool_calls != null) {
|
|
1649
1658
|
for (const toolCallDelta of delta.tool_calls) {
|
|
@@ -1743,7 +1752,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1743
1752
|
var _a16;
|
|
1744
1753
|
if (finishReason === "tool-calls") {
|
|
1745
1754
|
for (const toolCall of toolCalls) {
|
|
1746
|
-
if (!toolCall.sent) {
|
|
1755
|
+
if (toolCall && !toolCall.sent) {
|
|
1747
1756
|
controller.enqueue({
|
|
1748
1757
|
type: "tool-call",
|
|
1749
1758
|
toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),
|