ai 5.0.0-canary.10 → 5.0.0-canary.12

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.
@@ -617,10 +617,11 @@ type CallSettings = {
617
617
  1 (very random).
618
618
 
619
619
  It is recommended to set either `temperature` or `topP`, but not both.
620
+ Use `null` to use the provider's default temperature.
620
621
 
621
622
  @default 0
622
623
  */
623
- temperature?: number;
624
+ temperature?: number | null;
624
625
  /**
625
626
  Nucleus sampling. This is a number between 0 and 1.
626
627
 
@@ -705,7 +706,9 @@ declare function prepareRetries({ maxRetries, }: {
705
706
  /**
706
707
  * Validates call settings and sets default values.
707
708
  */
708
- declare function prepareCallSettings({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, stopSequences, seed, }: Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>): Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>;
709
+ declare function prepareCallSettings({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, stopSequences, seed, }: Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>): Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries' | 'temperature'> & {
710
+ temperature?: number;
711
+ };
709
712
 
710
713
  declare function download({ url }: {
711
714
  url: URL;
@@ -714,10 +717,9 @@ declare function download({ url }: {
714
717
  mediaType: string | undefined;
715
718
  }>;
716
719
 
717
- declare function convertToLanguageModelPrompt({ prompt, modelSupportsImageUrls, modelSupportsUrl, downloadImplementation, }: {
720
+ declare function convertToLanguageModelPrompt({ prompt, supportedUrls, downloadImplementation, }: {
718
721
  prompt: StandardizedPrompt;
719
- modelSupportsImageUrls: boolean | undefined;
720
- modelSupportsUrl: undefined | ((url: URL) => boolean);
722
+ supportedUrls: Record<string, RegExp[]>;
721
723
  downloadImplementation?: typeof download;
722
724
  }): Promise<LanguageModelV2Prompt>;
723
725
 
@@ -617,10 +617,11 @@ type CallSettings = {
617
617
  1 (very random).
618
618
 
619
619
  It is recommended to set either `temperature` or `topP`, but not both.
620
+ Use `null` to use the provider's default temperature.
620
621
 
621
622
  @default 0
622
623
  */
623
- temperature?: number;
624
+ temperature?: number | null;
624
625
  /**
625
626
  Nucleus sampling. This is a number between 0 and 1.
626
627
 
@@ -705,7 +706,9 @@ declare function prepareRetries({ maxRetries, }: {
705
706
  /**
706
707
  * Validates call settings and sets default values.
707
708
  */
708
- declare function prepareCallSettings({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, stopSequences, seed, }: Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>): Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>;
709
+ declare function prepareCallSettings({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, stopSequences, seed, }: Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>): Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries' | 'temperature'> & {
710
+ temperature?: number;
711
+ };
709
712
 
710
713
  declare function download({ url }: {
711
714
  url: URL;
@@ -714,10 +717,9 @@ declare function download({ url }: {
714
717
  mediaType: string | undefined;
715
718
  }>;
716
719
 
717
- declare function convertToLanguageModelPrompt({ prompt, modelSupportsImageUrls, modelSupportsUrl, downloadImplementation, }: {
720
+ declare function convertToLanguageModelPrompt({ prompt, supportedUrls, downloadImplementation, }: {
718
721
  prompt: StandardizedPrompt;
719
- modelSupportsImageUrls: boolean | undefined;
720
- modelSupportsUrl: undefined | ((url: URL) => boolean);
722
+ supportedUrls: Record<string, RegExp[]>;
721
723
  downloadImplementation?: typeof download;
722
724
  }): Promise<LanguageModelV2Prompt>;
723
725
 
@@ -1058,8 +1058,7 @@ function prepareCallSettings({
1058
1058
  }
1059
1059
  return {
1060
1060
  maxOutputTokens,
1061
- // TODO v5 remove default 0 for temperature
1062
- temperature: temperature != null ? temperature : 0,
1061
+ temperature: temperature != null ? temperature : temperature === null ? void 0 : 0,
1063
1062
  topP,
1064
1063
  topK,
1065
1064
  presencePenalty,
@@ -1243,17 +1242,16 @@ var InvalidMessageRoleError = class extends import_provider9.AISDKError {
1243
1242
  _a6 = symbol6;
1244
1243
 
1245
1244
  // core/prompt/convert-to-language-model-prompt.ts
1245
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1246
1246
  async function convertToLanguageModelPrompt({
1247
1247
  prompt,
1248
- modelSupportsImageUrls = true,
1249
- modelSupportsUrl = () => false,
1248
+ supportedUrls,
1250
1249
  downloadImplementation = download
1251
1250
  }) {
1252
1251
  const downloadedAssets = await downloadAssets(
1253
1252
  prompt.messages,
1254
1253
  downloadImplementation,
1255
- modelSupportsImageUrls,
1256
- modelSupportsUrl
1254
+ supportedUrls
1257
1255
  );
1258
1256
  return [
1259
1257
  ...prompt.system != null ? [{ role: "system", content: prompt.system }] : [],
@@ -1372,19 +1370,29 @@ function convertToLanguageModelMessage(message, downloadedAssets) {
1372
1370
  }
1373
1371
  }
1374
1372
  }
1375
- async function downloadAssets(messages, downloadImplementation, modelSupportsImageUrls, modelSupportsUrl) {
1373
+ async function downloadAssets(messages, downloadImplementation, supportedUrls) {
1376
1374
  const urls = messages.filter((message) => message.role === "user").map((message) => message.content).filter(
1377
1375
  (content) => Array.isArray(content)
1378
1376
  ).flat().filter(
1379
1377
  (part) => part.type === "image" || part.type === "file"
1380
- ).filter(
1381
- (part) => !(part.type === "image" && modelSupportsImageUrls === true)
1382
- ).map((part) => part.type === "image" ? part.image : part.data).map(
1383
- (part) => (
1384
- // support string urls:
1385
- typeof part === "string" && (part.startsWith("http:") || part.startsWith("https:")) ? new URL(part) : part
1386
- )
1387
- ).filter((image) => image instanceof URL).filter((url) => !modelSupportsUrl(url));
1378
+ ).map((part) => {
1379
+ var _a7, _b;
1380
+ const mediaType = (_b = (_a7 = part.mediaType) != null ? _a7 : part.mimeType) != null ? _b : part.type === "image" ? "image/*" : void 0;
1381
+ let data = part.type === "image" ? part.image : part.data;
1382
+ if (typeof data === "string") {
1383
+ try {
1384
+ data = new URL(data);
1385
+ } catch (ignored) {
1386
+ }
1387
+ }
1388
+ return { mediaType, data };
1389
+ }).filter(
1390
+ (part) => part.data instanceof URL && part.mediaType != null && !(0, import_provider_utils7.isUrlSupported)({
1391
+ url: part.data.toString(),
1392
+ mediaType: part.mediaType,
1393
+ supportedUrls
1394
+ })
1395
+ ).map((part) => part.data);
1388
1396
  const downloadedImages = await Promise.all(
1389
1397
  urls.map(async (url) => ({
1390
1398
  url,