ai 6.0.0-beta.136 → 6.0.0-beta.137

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.mjs CHANGED
@@ -813,7 +813,7 @@ import {
813
813
  } from "@ai-sdk/provider-utils";
814
814
 
815
815
  // src/version.ts
816
- var VERSION = true ? "6.0.0-beta.136" : "0.0.0-test";
816
+ var VERSION = true ? "6.0.0-beta.137" : "0.0.0-test";
817
817
 
818
818
  // src/util/download/download.ts
819
819
  var download = async ({ url }) => {
@@ -948,6 +948,11 @@ function convertDataContentToUint8Array(content) {
948
948
  throw new InvalidDataContentError({ content });
949
949
  }
950
950
 
951
+ // src/util/as-array.ts
952
+ function asArray(value) {
953
+ return value === void 0 ? [] : Array.isArray(value) ? value : [value];
954
+ }
955
+
951
956
  // src/prompt/convert-to-language-model-prompt.ts
952
957
  async function convertToLanguageModelPrompt({
953
958
  prompt,
@@ -960,13 +965,11 @@ async function convertToLanguageModelPrompt({
960
965
  supportedUrls
961
966
  );
962
967
  const messages = [
963
- ...prompt.system != null ? typeof prompt.system === "string" ? [{ role: "system", content: prompt.system }] : [
964
- {
965
- role: "system",
966
- content: prompt.system.content,
967
- providerOptions: prompt.system.providerOptions
968
- }
969
- ] : [],
968
+ ...prompt.system != null ? typeof prompt.system === "string" ? [{ role: "system", content: prompt.system }] : asArray(prompt.system).map((message) => ({
969
+ role: "system",
970
+ content: message.content,
971
+ providerOptions: message.providerOptions
972
+ })) : [],
970
973
  ...prompt.messages.map(
971
974
  (message) => convertToLanguageModelMessage({ message, downloadedAssets })
972
975
  )
@@ -1622,10 +1625,12 @@ async function standardizePrompt(prompt) {
1622
1625
  message: "prompt and messages cannot be defined at the same time"
1623
1626
  });
1624
1627
  }
1625
- if (prompt.system != null && typeof prompt.system !== "string" && "role" in prompt.system && prompt.system.role !== "system") {
1628
+ if (prompt.system != null && typeof prompt.system !== "string" && !asArray(prompt.system).every(
1629
+ (message) => typeof message === "object" && message !== null && "role" in message && message.role === "system"
1630
+ )) {
1626
1631
  throw new InvalidPromptError2({
1627
1632
  prompt,
1628
- message: "system must be a string"
1633
+ message: "system must be a string, SystemModelMessage, or array of SystemModelMessage"
1629
1634
  });
1630
1635
  }
1631
1636
  let messages;
@@ -1931,11 +1936,6 @@ function addImageModelUsage(usage1, usage2) {
1931
1936
  };
1932
1937
  }
1933
1938
 
1934
- // src/util/as-array.ts
1935
- function asArray(value) {
1936
- return value === void 0 ? [] : Array.isArray(value) ? value : [value];
1937
- }
1938
-
1939
1939
  // src/util/retry-with-exponential-backoff.ts
1940
1940
  import { APICallError as APICallError2 } from "@ai-sdk/provider";
1941
1941
  import { delay, getErrorMessage as getErrorMessage4, isAbortError } from "@ai-sdk/provider-utils";