ai 4.1.13 → 4.1.15
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/CHANGELOG.md +19 -0
- package/dist/index.d.mts +28 -9
- package/dist/index.d.ts +28 -9
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/rsc/dist/rsc-server.mjs +7 -4
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/dist/index.mjs
CHANGED
@@ -1525,7 +1525,9 @@ function convertToCoreMessages(messages, options) {
|
|
1525
1525
|
var _a15;
|
1526
1526
|
const tools = (_a15 = options == null ? void 0 : options.tools) != null ? _a15 : {};
|
1527
1527
|
const coreMessages = [];
|
1528
|
-
for (
|
1528
|
+
for (let i = 0; i < messages.length; i++) {
|
1529
|
+
const message = messages[i];
|
1530
|
+
const isLastMessage = i === messages.length - 1;
|
1529
1531
|
const { role, content, toolInvocations, experimental_attachments } = message;
|
1530
1532
|
switch (role) {
|
1531
1533
|
case "system": {
|
@@ -1554,11 +1556,11 @@ function convertToCoreMessages(messages, options) {
|
|
1554
1556
|
var _a16;
|
1555
1557
|
return Math.max(max, (_a16 = toolInvocation.step) != null ? _a16 : 0);
|
1556
1558
|
}, 0);
|
1557
|
-
for (let
|
1559
|
+
for (let i2 = 0; i2 <= maxStep; i2++) {
|
1558
1560
|
const stepInvocations = toolInvocations.filter(
|
1559
1561
|
(toolInvocation) => {
|
1560
1562
|
var _a16;
|
1561
|
-
return ((_a16 = toolInvocation.step) != null ? _a16 : 0) ===
|
1563
|
+
return ((_a16 = toolInvocation.step) != null ? _a16 : 0) === i2;
|
1562
1564
|
}
|
1563
1565
|
);
|
1564
1566
|
if (stepInvocations.length === 0) {
|
@@ -1567,6 +1569,7 @@ function convertToCoreMessages(messages, options) {
|
|
1567
1569
|
coreMessages.push({
|
1568
1570
|
role: "assistant",
|
1569
1571
|
content: [
|
1572
|
+
...isLastMessage && content && i2 === 0 ? [{ type: "text", text: content }] : [],
|
1570
1573
|
...stepInvocations.map(
|
1571
1574
|
({ toolCallId, toolName, args }) => ({
|
1572
1575
|
type: "tool-call",
|
@@ -1603,7 +1606,7 @@ function convertToCoreMessages(messages, options) {
|
|
1603
1606
|
})
|
1604
1607
|
});
|
1605
1608
|
}
|
1606
|
-
if (content) {
|
1609
|
+
if (content && !isLastMessage) {
|
1607
1610
|
coreMessages.push({ role: "assistant", content });
|
1608
1611
|
}
|
1609
1612
|
break;
|
@@ -5821,9 +5824,10 @@ function appendResponseMessages({
|
|
5821
5824
|
|
5822
5825
|
// core/registry/custom-provider.ts
|
5823
5826
|
import { NoSuchModelError as NoSuchModelError2 } from "@ai-sdk/provider";
|
5824
|
-
function
|
5827
|
+
function customProvider({
|
5825
5828
|
languageModels,
|
5826
5829
|
textEmbeddingModels,
|
5830
|
+
imageModels,
|
5827
5831
|
fallbackProvider
|
5828
5832
|
}) {
|
5829
5833
|
return {
|
@@ -5844,9 +5848,19 @@ function experimental_customProvider({
|
|
5844
5848
|
return fallbackProvider.textEmbeddingModel(modelId);
|
5845
5849
|
}
|
5846
5850
|
throw new NoSuchModelError2({ modelId, modelType: "textEmbeddingModel" });
|
5851
|
+
},
|
5852
|
+
imageModel(modelId) {
|
5853
|
+
if (imageModels != null && modelId in imageModels) {
|
5854
|
+
return imageModels[modelId];
|
5855
|
+
}
|
5856
|
+
if (fallbackProvider == null ? void 0 : fallbackProvider.imageModel) {
|
5857
|
+
return fallbackProvider.imageModel(modelId);
|
5858
|
+
}
|
5859
|
+
throw new NoSuchModelError2({ modelId, modelType: "imageModel" });
|
5847
5860
|
}
|
5848
5861
|
};
|
5849
5862
|
}
|
5863
|
+
var experimental_customProvider = customProvider;
|
5850
5864
|
|
5851
5865
|
// core/registry/no-such-provider-error.ts
|
5852
5866
|
import { AISDKError as AISDKError15, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
|
@@ -5886,7 +5900,10 @@ var DefaultProviderRegistry = class {
|
|
5886
5900
|
constructor() {
|
5887
5901
|
this.providers = {};
|
5888
5902
|
}
|
5889
|
-
registerProvider({
|
5903
|
+
registerProvider({
|
5904
|
+
id,
|
5905
|
+
provider
|
5906
|
+
}) {
|
5890
5907
|
this.providers[id] = provider;
|
5891
5908
|
}
|
5892
5909
|
getProvider(id) {
|
@@ -5934,6 +5951,16 @@ var DefaultProviderRegistry = class {
|
|
5934
5951
|
}
|
5935
5952
|
return model;
|
5936
5953
|
}
|
5954
|
+
imageModel(id) {
|
5955
|
+
var _a15;
|
5956
|
+
const [providerId, modelId] = this.splitId(id, "imageModel");
|
5957
|
+
const provider = this.getProvider(providerId);
|
5958
|
+
const model = (_a15 = provider.imageModel) == null ? void 0 : _a15.call(provider, modelId);
|
5959
|
+
if (model == null) {
|
5960
|
+
throw new NoSuchModelError4({ modelId: id, modelType: "imageModel" });
|
5961
|
+
}
|
5962
|
+
return model;
|
5963
|
+
}
|
5937
5964
|
/**
|
5938
5965
|
* @deprecated Use `textEmbeddingModel` instead.
|
5939
5966
|
*/
|
@@ -6381,6 +6408,7 @@ export {
|
|
6381
6408
|
createDataStream,
|
6382
6409
|
createDataStreamResponse,
|
6383
6410
|
createIdGenerator5 as createIdGenerator,
|
6411
|
+
customProvider,
|
6384
6412
|
embed,
|
6385
6413
|
embedMany,
|
6386
6414
|
experimental_createProviderRegistry,
|