ai 6.0.0-beta.148 → 6.0.0-beta.150

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.0-beta.150
4
+
5
+ ### Patch Changes
6
+
7
+ - db62f7d: Added schema name and description for generateText and output
8
+
9
+ ## 6.0.0-beta.149
10
+
11
+ ### Patch Changes
12
+
13
+ - 4e2b04d: fix(gateway): throw error with user-friendly message in non-production environments if `AI_GATEWAY_API_KEY` is not configured
14
+
3
15
  ## 6.0.0-beta.148
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -603,41 +603,91 @@ declare const text: () => Output<string, string>;
603
603
  * When the model generates a text response, it will return an object that matches the schema.
604
604
  *
605
605
  * @param schema - The schema of the object to generate.
606
+ * @param name - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
607
+ * @param description - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
606
608
  *
607
609
  * @returns An output specification for generating objects with the specified schema.
608
610
  */
609
- declare const object: <OBJECT>({ schema: inputSchema, }: {
611
+ declare const object: <OBJECT>({ schema: inputSchema, name, description, }: {
610
612
  schema: FlexibleSchema<OBJECT>;
613
+ /**
614
+ * Optional name of the output that should be generated.
615
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema name.
616
+ */
617
+ name?: string;
618
+ /**
619
+ * Optional description of the output that should be generated.
620
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema description.
621
+ */
622
+ description?: string;
611
623
  }) => Output<OBJECT, DeepPartial<OBJECT>>;
612
624
  /**
613
625
  * Output specification for array generation.
614
626
  * When the model generates a text response, it will return an array of elements.
615
627
  *
616
628
  * @param element - The schema of the array elements to generate.
629
+ * @param name - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
630
+ * @param description - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
617
631
  *
618
632
  * @returns An output specification for generating an array of elements.
619
633
  */
620
- declare const array: <ELEMENT>({ element: inputElementSchema, }: {
634
+ declare const array: <ELEMENT>({ element: inputElementSchema, name, description, }: {
621
635
  element: FlexibleSchema<ELEMENT>;
636
+ /**
637
+ * Optional name of the output that should be generated.
638
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema name.
639
+ */
640
+ name?: string;
641
+ /**
642
+ * Optional description of the output that should be generated.
643
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema description.
644
+ */
645
+ description?: string;
622
646
  }) => Output<Array<ELEMENT>, Array<ELEMENT>>;
623
647
  /**
624
648
  * Output specification for choice generation.
625
649
  * When the model generates a text response, it will return a one of the choice options.
626
650
  *
627
651
  * @param options - The available choices.
652
+ * @param name - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
653
+ * @param description - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
628
654
  *
629
655
  * @returns An output specification for generating a choice.
630
656
  */
631
- declare const choice: <CHOICE extends string>({ options: choiceOptions, }: {
657
+ declare const choice: <CHOICE extends string>({ options: choiceOptions, name, description, }: {
632
658
  options: Array<CHOICE>;
659
+ /**
660
+ * Optional name of the output that should be generated.
661
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema name.
662
+ */
663
+ name?: string;
664
+ /**
665
+ * Optional description of the output that should be generated.
666
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema description.
667
+ */
668
+ description?: string;
633
669
  }) => Output<CHOICE, CHOICE>;
634
670
  /**
635
671
  * Output specification for unstructured JSON generation.
636
672
  * When the model generates a text response, it will return a JSON object.
637
673
  *
674
+ * @param name - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
675
+ * @param description - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
676
+ *
638
677
  * @returns An output specification for generating JSON.
639
678
  */
640
- declare const json: () => Output<JSONValue$1, JSONValue$1>;
679
+ declare const json: ({ name, description, }?: {
680
+ /**
681
+ * Optional name of the output that should be generated.
682
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema name.
683
+ */
684
+ name?: string;
685
+ /**
686
+ * Optional description of the output that should be generated.
687
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema description.
688
+ */
689
+ description?: string;
690
+ }) => Output<JSONValue$1, JSONValue$1>;
641
691
 
642
692
  type output_Output<OUTPUT = any, PARTIAL = any> = Output<OUTPUT, PARTIAL>;
643
693
  declare const output_array: typeof array;
package/dist/index.d.ts CHANGED
@@ -603,41 +603,91 @@ declare const text: () => Output<string, string>;
603
603
  * When the model generates a text response, it will return an object that matches the schema.
604
604
  *
605
605
  * @param schema - The schema of the object to generate.
606
+ * @param name - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
607
+ * @param description - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
606
608
  *
607
609
  * @returns An output specification for generating objects with the specified schema.
608
610
  */
609
- declare const object: <OBJECT>({ schema: inputSchema, }: {
611
+ declare const object: <OBJECT>({ schema: inputSchema, name, description, }: {
610
612
  schema: FlexibleSchema<OBJECT>;
613
+ /**
614
+ * Optional name of the output that should be generated.
615
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema name.
616
+ */
617
+ name?: string;
618
+ /**
619
+ * Optional description of the output that should be generated.
620
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema description.
621
+ */
622
+ description?: string;
611
623
  }) => Output<OBJECT, DeepPartial<OBJECT>>;
612
624
  /**
613
625
  * Output specification for array generation.
614
626
  * When the model generates a text response, it will return an array of elements.
615
627
  *
616
628
  * @param element - The schema of the array elements to generate.
629
+ * @param name - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
630
+ * @param description - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
617
631
  *
618
632
  * @returns An output specification for generating an array of elements.
619
633
  */
620
- declare const array: <ELEMENT>({ element: inputElementSchema, }: {
634
+ declare const array: <ELEMENT>({ element: inputElementSchema, name, description, }: {
621
635
  element: FlexibleSchema<ELEMENT>;
636
+ /**
637
+ * Optional name of the output that should be generated.
638
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema name.
639
+ */
640
+ name?: string;
641
+ /**
642
+ * Optional description of the output that should be generated.
643
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema description.
644
+ */
645
+ description?: string;
622
646
  }) => Output<Array<ELEMENT>, Array<ELEMENT>>;
623
647
  /**
624
648
  * Output specification for choice generation.
625
649
  * When the model generates a text response, it will return a one of the choice options.
626
650
  *
627
651
  * @param options - The available choices.
652
+ * @param name - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
653
+ * @param description - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
628
654
  *
629
655
  * @returns An output specification for generating a choice.
630
656
  */
631
- declare const choice: <CHOICE extends string>({ options: choiceOptions, }: {
657
+ declare const choice: <CHOICE extends string>({ options: choiceOptions, name, description, }: {
632
658
  options: Array<CHOICE>;
659
+ /**
660
+ * Optional name of the output that should be generated.
661
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema name.
662
+ */
663
+ name?: string;
664
+ /**
665
+ * Optional description of the output that should be generated.
666
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema description.
667
+ */
668
+ description?: string;
633
669
  }) => Output<CHOICE, CHOICE>;
634
670
  /**
635
671
  * Output specification for unstructured JSON generation.
636
672
  * When the model generates a text response, it will return a JSON object.
637
673
  *
674
+ * @param name - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
675
+ * @param description - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
676
+ *
638
677
  * @returns An output specification for generating JSON.
639
678
  */
640
- declare const json: () => Output<JSONValue$1, JSONValue$1>;
679
+ declare const json: ({ name, description, }?: {
680
+ /**
681
+ * Optional name of the output that should be generated.
682
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema name.
683
+ */
684
+ name?: string;
685
+ /**
686
+ * Optional description of the output that should be generated.
687
+ * Used by some providers for additional LLM guidance, e.g. via tool or schema description.
688
+ */
689
+ description?: string;
690
+ }) => Output<JSONValue$1, JSONValue$1>;
641
691
 
642
692
  type output_Output<OUTPUT = any, PARTIAL = any> = Output<OUTPUT, PARTIAL>;
643
693
  declare const output_array: typeof array;
package/dist/index.js CHANGED
@@ -962,7 +962,7 @@ function detectMediaType({
962
962
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
963
963
 
964
964
  // src/version.ts
965
- var VERSION = true ? "6.0.0-beta.148" : "0.0.0-test";
965
+ var VERSION = true ? "6.0.0-beta.150" : "0.0.0-test";
966
966
 
967
967
  // src/util/download/download.ts
968
968
  var download = async ({ url }) => {
@@ -1817,14 +1817,28 @@ async function standardizePrompt(prompt) {
1817
1817
  var import_gateway2 = require("@ai-sdk/gateway");
1818
1818
  var import_provider20 = require("@ai-sdk/provider");
1819
1819
  function wrapGatewayError(error) {
1820
- if (import_gateway2.GatewayAuthenticationError.isInstance(error) || import_gateway2.GatewayModelNotFoundError.isInstance(error)) {
1820
+ if (!import_gateway2.GatewayAuthenticationError.isInstance(error))
1821
+ return error;
1822
+ const isProductionEnv = (process == null ? void 0 : process.env.NODE_ENV) === "production";
1823
+ const moreInfoURL = "https://v6.ai-sdk.dev/unauthenticated-ai-gateway";
1824
+ if (isProductionEnv) {
1821
1825
  return new import_provider20.AISDKError({
1822
1826
  name: "GatewayError",
1823
- message: "Unauthenticated. Configure AI_GATEWAY_API_KEY or configure and use a provider module. Learn more: https://vercel.link/unauthenticated-ai-gateway-v6",
1824
- cause: error
1827
+ message: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`
1825
1828
  });
1826
1829
  }
1827
- return error;
1830
+ return Object.assign(
1831
+ new Error(`\x1B[1m\x1B[31mUnauthenticated request to AI Gateway.\x1B[0m
1832
+
1833
+ To authenticate, set the \x1B[33mAI_GATEWAY_API_KEY\x1B[0m environment variable with your API key.
1834
+
1835
+ Alternatively, you can use a provider module instead of the AI Gateway.
1836
+
1837
+ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
1838
+
1839
+ `),
1840
+ { name: "GatewayAuthenticationError" }
1841
+ );
1828
1842
  }
1829
1843
 
1830
1844
  // src/telemetry/assemble-operation-name.ts
@@ -2855,13 +2869,17 @@ var text = () => ({
2855
2869
  }
2856
2870
  });
2857
2871
  var object = ({
2858
- schema: inputSchema
2872
+ schema: inputSchema,
2873
+ name: name15,
2874
+ description
2859
2875
  }) => {
2860
2876
  const schema = (0, import_provider_utils11.asSchema)(inputSchema);
2861
2877
  return {
2862
2878
  responseFormat: (0, import_provider_utils11.resolve)(schema.jsonSchema).then((jsonSchema2) => ({
2863
2879
  type: "json",
2864
- schema: jsonSchema2
2880
+ schema: jsonSchema2,
2881
+ ...name15 != null && { name: name15 },
2882
+ ...description != null && { description }
2865
2883
  })),
2866
2884
  async parseCompleteOutput({ text: text2 }, context) {
2867
2885
  const parseResult = await (0, import_provider_utils11.safeParseJSON)({ text: text2 });
@@ -2910,7 +2928,9 @@ var object = ({
2910
2928
  };
2911
2929
  };
2912
2930
  var array = ({
2913
- element: inputElementSchema
2931
+ element: inputElementSchema,
2932
+ name: name15,
2933
+ description
2914
2934
  }) => {
2915
2935
  const elementSchema = (0, import_provider_utils11.asSchema)(inputElementSchema);
2916
2936
  return {
@@ -2927,7 +2947,9 @@ var array = ({
2927
2947
  },
2928
2948
  required: ["elements"],
2929
2949
  additionalProperties: false
2930
- }
2950
+ },
2951
+ ...name15 != null && { name: name15 },
2952
+ ...description != null && { description }
2931
2953
  };
2932
2954
  }),
2933
2955
  async parseCompleteOutput({ text: text2 }, context) {
@@ -3005,7 +3027,9 @@ var array = ({
3005
3027
  };
3006
3028
  };
3007
3029
  var choice = ({
3008
- options: choiceOptions
3030
+ options: choiceOptions,
3031
+ name: name15,
3032
+ description
3009
3033
  }) => {
3010
3034
  return {
3011
3035
  // JSON schema that describes an enumeration:
@@ -3019,7 +3043,9 @@ var choice = ({
3019
3043
  },
3020
3044
  required: ["result"],
3021
3045
  additionalProperties: false
3022
- }
3046
+ },
3047
+ ...name15 != null && { name: name15 },
3048
+ ...description != null && { description }
3023
3049
  }),
3024
3050
  async parseCompleteOutput({ text: text2 }, context) {
3025
3051
  const parseResult = await (0, import_provider_utils11.safeParseJSON)({ text: text2 });
@@ -3075,10 +3101,15 @@ var choice = ({
3075
3101
  }
3076
3102
  };
3077
3103
  };
3078
- var json = () => {
3104
+ var json = ({
3105
+ name: name15,
3106
+ description
3107
+ } = {}) => {
3079
3108
  return {
3080
3109
  responseFormat: Promise.resolve({
3081
- type: "json"
3110
+ type: "json",
3111
+ ...name15 != null && { name: name15 },
3112
+ ...description != null && { description }
3082
3113
  }),
3083
3114
  async parseCompleteOutput({ text: text2 }, context) {
3084
3115
  const parseResult = await (0, import_provider_utils11.safeParseJSON)({ text: text2 });