ai 6.0.0-beta.135 → 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.135" : "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";
@@ -9905,10 +9905,10 @@ function defaultFormatExample(example) {
9905
9905
  return JSON.stringify(example.input);
9906
9906
  }
9907
9907
  function addToolInputExamplesMiddleware({
9908
- examplesPrefix,
9909
- formatExample = defaultFormatExample,
9910
- removeInputExamples = true
9911
- }) {
9908
+ prefix = "Input Examples:",
9909
+ format = defaultFormatExample,
9910
+ remove = true
9911
+ } = {}) {
9912
9912
  return {
9913
9913
  specificationVersion: "v3",
9914
9914
  transformParams: async ({ params }) => {
@@ -9921,8 +9921,8 @@ function addToolInputExamplesMiddleware({
9921
9921
  if (tool2.type !== "function" || !((_a16 = tool2.inputExamples) == null ? void 0 : _a16.length)) {
9922
9922
  return tool2;
9923
9923
  }
9924
- const formattedExamples = tool2.inputExamples.map((example, index) => formatExample(example, index)).join("\n");
9925
- const examplesSection = `${examplesPrefix}
9924
+ const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join("\n");
9925
+ const examplesSection = `${prefix}
9926
9926
  ${formattedExamples}`;
9927
9927
  const toolDescription = tool2.description ? `${tool2.description}
9928
9928
 
@@ -9930,7 +9930,7 @@ ${examplesSection}` : examplesSection;
9930
9930
  return {
9931
9931
  ...tool2,
9932
9932
  description: toolDescription,
9933
- inputExamples: removeInputExamples ? void 0 : tool2.inputExamples
9933
+ inputExamples: remove ? void 0 : tool2.inputExamples
9934
9934
  };
9935
9935
  });
9936
9936
  return {