ai 7.0.0-beta.88 → 7.0.0-beta.89
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 +11 -0
- package/dist/index.js +137 -60
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1600 -3
- package/dist/internal/index.js +600 -4
- package/dist/internal/index.js.map +1 -1
- package/docs/02-foundations/03-prompts.mdx +1 -1
- package/docs/03-agents/07-workflow-agent.mdx +471 -0
- package/docs/03-agents/index.mdx +6 -0
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +1 -1
- package/docs/04-ai-sdk-ui/21-transport.mdx +38 -0
- package/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +11 -1
- package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +750 -0
- package/docs/07-reference/04-ai-sdk-workflow/02-workflow-chat-transport.mdx +342 -0
- package/docs/07-reference/04-ai-sdk-workflow/index.mdx +26 -0
- package/docs/07-reference/index.mdx +6 -0
- package/docs/08-migration-guides/23-migration-guide-7-0.mdx +15 -10
- package/package.json +4 -4
- package/src/model/resolve-model.ts +58 -79
- package/src/prompt/content-part.ts +2 -0
- package/src/prompt/convert-to-language-model-prompt.ts +98 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.0-beta.89
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
|
|
8
|
+
- Updated dependencies [b3976a2]
|
|
9
|
+
- Updated dependencies [ff5eba1]
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
11
|
+
- @ai-sdk/gateway@4.0.0-beta.50
|
|
12
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
13
|
+
|
|
3
14
|
## 7.0.0-beta.88
|
|
4
15
|
|
|
5
16
|
### Major Changes
|
package/dist/index.js
CHANGED
|
@@ -882,76 +882,76 @@ function asProviderV4(provider) {
|
|
|
882
882
|
|
|
883
883
|
// src/model/resolve-model.ts
|
|
884
884
|
function resolveLanguageModel(model) {
|
|
885
|
-
if (typeof model
|
|
886
|
-
|
|
887
|
-
const unsupportedModel = model;
|
|
888
|
-
throw new UnsupportedModelVersionError({
|
|
889
|
-
version: unsupportedModel.specificationVersion,
|
|
890
|
-
provider: unsupportedModel.provider,
|
|
891
|
-
modelId: unsupportedModel.modelId
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
return asLanguageModelV4(model);
|
|
885
|
+
if (typeof model === "string") {
|
|
886
|
+
return getGlobalProvider().languageModel(model);
|
|
895
887
|
}
|
|
896
|
-
|
|
888
|
+
if (!["v4", "v3", "v2"].includes(model.specificationVersion)) {
|
|
889
|
+
const unsupportedModel = model;
|
|
890
|
+
throw new UnsupportedModelVersionError({
|
|
891
|
+
version: unsupportedModel.specificationVersion,
|
|
892
|
+
provider: unsupportedModel.provider,
|
|
893
|
+
modelId: unsupportedModel.modelId
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
return asLanguageModelV4(model);
|
|
897
897
|
}
|
|
898
898
|
function resolveEmbeddingModel(model) {
|
|
899
|
-
if (typeof model
|
|
900
|
-
|
|
901
|
-
const unsupportedModel = model;
|
|
902
|
-
throw new UnsupportedModelVersionError({
|
|
903
|
-
version: unsupportedModel.specificationVersion,
|
|
904
|
-
provider: unsupportedModel.provider,
|
|
905
|
-
modelId: unsupportedModel.modelId
|
|
906
|
-
});
|
|
907
|
-
}
|
|
908
|
-
return asEmbeddingModelV4(model);
|
|
899
|
+
if (typeof model === "string") {
|
|
900
|
+
return getGlobalProvider().embeddingModel(model);
|
|
909
901
|
}
|
|
910
|
-
|
|
902
|
+
if (!["v4", "v3", "v2"].includes(model.specificationVersion)) {
|
|
903
|
+
const unsupportedModel = model;
|
|
904
|
+
throw new UnsupportedModelVersionError({
|
|
905
|
+
version: unsupportedModel.specificationVersion,
|
|
906
|
+
provider: unsupportedModel.provider,
|
|
907
|
+
modelId: unsupportedModel.modelId
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
return asEmbeddingModelV4(model);
|
|
911
911
|
}
|
|
912
912
|
function resolveTranscriptionModel(model) {
|
|
913
913
|
var _a21, _b;
|
|
914
|
-
if (typeof model
|
|
915
|
-
|
|
916
|
-
const unsupportedModel = model;
|
|
917
|
-
throw new UnsupportedModelVersionError({
|
|
918
|
-
version: unsupportedModel.specificationVersion,
|
|
919
|
-
provider: unsupportedModel.provider,
|
|
920
|
-
modelId: unsupportedModel.modelId
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
return asTranscriptionModelV4(model);
|
|
914
|
+
if (typeof model === "string") {
|
|
915
|
+
return (_b = (_a21 = getGlobalProvider()).transcriptionModel) == null ? void 0 : _b.call(_a21, model);
|
|
924
916
|
}
|
|
925
|
-
|
|
917
|
+
if (!["v4", "v3", "v2"].includes(model.specificationVersion)) {
|
|
918
|
+
const unsupportedModel = model;
|
|
919
|
+
throw new UnsupportedModelVersionError({
|
|
920
|
+
version: unsupportedModel.specificationVersion,
|
|
921
|
+
provider: unsupportedModel.provider,
|
|
922
|
+
modelId: unsupportedModel.modelId
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
return asTranscriptionModelV4(model);
|
|
926
926
|
}
|
|
927
927
|
function resolveSpeechModel(model) {
|
|
928
928
|
var _a21, _b;
|
|
929
|
-
if (typeof model
|
|
930
|
-
|
|
931
|
-
const unsupportedModel = model;
|
|
932
|
-
throw new UnsupportedModelVersionError({
|
|
933
|
-
version: unsupportedModel.specificationVersion,
|
|
934
|
-
provider: unsupportedModel.provider,
|
|
935
|
-
modelId: unsupportedModel.modelId
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
return asSpeechModelV4(model);
|
|
929
|
+
if (typeof model === "string") {
|
|
930
|
+
return (_b = (_a21 = getGlobalProvider()).speechModel) == null ? void 0 : _b.call(_a21, model);
|
|
939
931
|
}
|
|
940
|
-
|
|
932
|
+
if (!["v4", "v3", "v2"].includes(model.specificationVersion)) {
|
|
933
|
+
const unsupportedModel = model;
|
|
934
|
+
throw new UnsupportedModelVersionError({
|
|
935
|
+
version: unsupportedModel.specificationVersion,
|
|
936
|
+
provider: unsupportedModel.provider,
|
|
937
|
+
modelId: unsupportedModel.modelId
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
return asSpeechModelV4(model);
|
|
941
941
|
}
|
|
942
942
|
function resolveImageModel(model) {
|
|
943
|
-
if (typeof model
|
|
944
|
-
|
|
945
|
-
const unsupportedModel = model;
|
|
946
|
-
throw new UnsupportedModelVersionError({
|
|
947
|
-
version: unsupportedModel.specificationVersion,
|
|
948
|
-
provider: unsupportedModel.provider,
|
|
949
|
-
modelId: unsupportedModel.modelId
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
return asImageModelV4(model);
|
|
943
|
+
if (typeof model === "string") {
|
|
944
|
+
return getGlobalProvider().imageModel(model);
|
|
953
945
|
}
|
|
954
|
-
|
|
946
|
+
if (!["v4", "v3", "v2"].includes(model.specificationVersion)) {
|
|
947
|
+
const unsupportedModel = model;
|
|
948
|
+
throw new UnsupportedModelVersionError({
|
|
949
|
+
version: unsupportedModel.specificationVersion,
|
|
950
|
+
provider: unsupportedModel.provider,
|
|
951
|
+
modelId: unsupportedModel.modelId
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
return asImageModelV4(model);
|
|
955
955
|
}
|
|
956
956
|
function resolveVideoModel(model) {
|
|
957
957
|
var _a21;
|
|
@@ -965,7 +965,7 @@ function resolveVideoModel(model) {
|
|
|
965
965
|
}
|
|
966
966
|
return videoModel(model);
|
|
967
967
|
}
|
|
968
|
-
if (
|
|
968
|
+
if (!["v4", "v3"].includes(model.specificationVersion)) {
|
|
969
969
|
const unsupportedModel = model;
|
|
970
970
|
throw new UnsupportedModelVersionError({
|
|
971
971
|
version: unsupportedModel.specificationVersion,
|
|
@@ -1285,7 +1285,7 @@ import {
|
|
|
1285
1285
|
} from "@ai-sdk/provider-utils";
|
|
1286
1286
|
|
|
1287
1287
|
// src/version.ts
|
|
1288
|
-
var VERSION = true ? "7.0.0-beta.
|
|
1288
|
+
var VERSION = true ? "7.0.0-beta.89" : "0.0.0-test";
|
|
1289
1289
|
|
|
1290
1290
|
// src/util/download/download.ts
|
|
1291
1291
|
var download = async ({
|
|
@@ -1822,8 +1822,25 @@ function mapToolResultOutput({
|
|
|
1822
1822
|
return {
|
|
1823
1823
|
type: "content",
|
|
1824
1824
|
value: output.value.map((item) => {
|
|
1825
|
+
var _a21;
|
|
1825
1826
|
switch (item.type) {
|
|
1826
|
-
case "
|
|
1827
|
+
case "image-data": {
|
|
1828
|
+
return {
|
|
1829
|
+
type: "file-data",
|
|
1830
|
+
data: item.data,
|
|
1831
|
+
mediaType: item.mediaType,
|
|
1832
|
+
providerOptions: item.providerOptions
|
|
1833
|
+
};
|
|
1834
|
+
}
|
|
1835
|
+
case "image-url": {
|
|
1836
|
+
return {
|
|
1837
|
+
type: "file-url",
|
|
1838
|
+
url: item.url,
|
|
1839
|
+
mediaType: getMediaTypeFromUrl(item.url, "image/*"),
|
|
1840
|
+
providerOptions: item.providerOptions
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
case "image-file-id": {
|
|
1827
1844
|
return {
|
|
1828
1845
|
type: "file-reference",
|
|
1829
1846
|
providerReference: convertFileIdToProviderReference({
|
|
@@ -1833,9 +1850,16 @@ function mapToolResultOutput({
|
|
|
1833
1850
|
providerOptions: item.providerOptions
|
|
1834
1851
|
};
|
|
1835
1852
|
}
|
|
1836
|
-
case "image-file-
|
|
1853
|
+
case "image-file-reference": {
|
|
1837
1854
|
return {
|
|
1838
|
-
type: "
|
|
1855
|
+
type: "file-reference",
|
|
1856
|
+
providerReference: item.providerReference,
|
|
1857
|
+
providerOptions: item.providerOptions
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1860
|
+
case "file-id": {
|
|
1861
|
+
return {
|
|
1862
|
+
type: "file-reference",
|
|
1839
1863
|
providerReference: convertFileIdToProviderReference({
|
|
1840
1864
|
fileId: item.fileId,
|
|
1841
1865
|
provider
|
|
@@ -1843,6 +1867,26 @@ function mapToolResultOutput({
|
|
|
1843
1867
|
providerOptions: item.providerOptions
|
|
1844
1868
|
};
|
|
1845
1869
|
}
|
|
1870
|
+
case "file-url": {
|
|
1871
|
+
const mediaType = (_a21 = item.mediaType) != null ? _a21 : getMediaTypeFromUrl(item.url);
|
|
1872
|
+
if (!item.mediaType) {
|
|
1873
|
+
if (mediaType === "application/octet-stream") {
|
|
1874
|
+
console.warn(
|
|
1875
|
+
`AI SDK: 'file-url' tool result content part is missing 'mediaType'. Unable to infer media type from URL. Defaulting to 'application/octet-stream'. Provide 'mediaType' on the 'file-url' part for correct provider behavior.`
|
|
1876
|
+
);
|
|
1877
|
+
} else {
|
|
1878
|
+
console.warn(
|
|
1879
|
+
`AI SDK: 'file-url' tool result content part is missing 'mediaType'. Inferred '${mediaType}' from URL. Provide 'mediaType' on the 'file-url' part for correct provider behavior.`
|
|
1880
|
+
);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
return {
|
|
1884
|
+
type: "file-url",
|
|
1885
|
+
url: item.url,
|
|
1886
|
+
mediaType,
|
|
1887
|
+
providerOptions: item.providerOptions
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1846
1890
|
default:
|
|
1847
1891
|
return item;
|
|
1848
1892
|
}
|
|
@@ -1863,6 +1907,37 @@ function convertFileIdToProviderReference({
|
|
|
1863
1907
|
}
|
|
1864
1908
|
return { [provider]: fileId };
|
|
1865
1909
|
}
|
|
1910
|
+
var URL_EXTENSION_TO_MEDIA_TYPE = {
|
|
1911
|
+
jpg: "image/jpeg",
|
|
1912
|
+
jpeg: "image/jpeg",
|
|
1913
|
+
png: "image/png",
|
|
1914
|
+
gif: "image/gif",
|
|
1915
|
+
webp: "image/webp",
|
|
1916
|
+
svg: "image/svg+xml",
|
|
1917
|
+
avif: "image/avif",
|
|
1918
|
+
heic: "image/heic",
|
|
1919
|
+
bmp: "image/bmp",
|
|
1920
|
+
tiff: "image/tiff",
|
|
1921
|
+
tif: "image/tiff",
|
|
1922
|
+
pdf: "application/pdf",
|
|
1923
|
+
mp4: "video/mp4",
|
|
1924
|
+
webm: "video/webm",
|
|
1925
|
+
mp3: "audio/mpeg",
|
|
1926
|
+
wav: "audio/wav",
|
|
1927
|
+
ogg: "audio/ogg"
|
|
1928
|
+
};
|
|
1929
|
+
function getMediaTypeFromUrl(url, fallbackMediaType = "application/octet-stream") {
|
|
1930
|
+
var _a21;
|
|
1931
|
+
try {
|
|
1932
|
+
const pathname = new URL(url).pathname;
|
|
1933
|
+
const ext = (_a21 = pathname.split(".").pop()) == null ? void 0 : _a21.toLowerCase();
|
|
1934
|
+
if (ext && ext in URL_EXTENSION_TO_MEDIA_TYPE) {
|
|
1935
|
+
return URL_EXTENSION_TO_MEDIA_TYPE[ext];
|
|
1936
|
+
}
|
|
1937
|
+
} catch (e) {
|
|
1938
|
+
}
|
|
1939
|
+
return fallbackMediaType;
|
|
1940
|
+
}
|
|
1866
1941
|
|
|
1867
1942
|
// src/prompt/create-tool-model-output.ts
|
|
1868
1943
|
import { getErrorMessage as getErrorMessage3 } from "@ai-sdk/provider";
|
|
@@ -2170,6 +2245,8 @@ var outputSchema = z4.discriminatedUnion(
|
|
|
2170
2245
|
z4.object({
|
|
2171
2246
|
type: z4.literal("file-url"),
|
|
2172
2247
|
url: z4.string(),
|
|
2248
|
+
// Temporarily optional. TODO: make required in v8, after migration period.
|
|
2249
|
+
mediaType: z4.string().optional(),
|
|
2173
2250
|
providerOptions: providerMetadataSchema.optional()
|
|
2174
2251
|
}),
|
|
2175
2252
|
z4.object({
|