@ai-sdk/provider-utils 5.0.55 → 5.0.57

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.js CHANGED
@@ -606,7 +606,7 @@ function handleFetchError({ error, url, requestBodyValues }) {
606
606
  }
607
607
  //#endregion
608
608
  //#region src/version.ts
609
- const VERSION = "5.0.55";
609
+ const VERSION = "5.0.57";
610
610
  //#endregion
611
611
  //#region src/normalize-headers.ts
612
612
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/provider-utils",
3
- "version": "5.0.55",
3
+ "version": "5.0.57",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -42,7 +42,7 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "@ai-sdk/provider": "4.0.23",
45
+ "@ai-sdk/provider": "4.0.25",
46
46
  "@standard-schema/spec": "^1.1.0",
47
47
  "@workflow/serde": "4.1.0",
48
48
  "eventsource-parser": "^3.0.8",
@@ -2,6 +2,7 @@ import {
2
2
  Experimental_DecisionUnsupportedQuestionTypeError as DecisionUnsupportedQuestionTypeError,
3
3
  InvalidArgumentError,
4
4
  InvalidResponseDataError,
5
+ UnsupportedFunctionalityError,
5
6
  type Experimental_DecisionModelV4 as DecisionModelV4,
6
7
  type Experimental_DecisionModelV4Answer as DecisionModelV4Answer,
7
8
  type Experimental_DecisionModelV4CallOptions as DecisionModelV4CallOptions,
@@ -10,6 +11,7 @@ import {
10
11
  type LanguageModelV4,
11
12
  } from '@ai-sdk/provider';
12
13
  import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from '@workflow/serde';
14
+ import { getTopLevelMediaType } from './detect-media-type';
13
15
  import { safeParseJSON } from './parse-json';
14
16
 
15
17
  /** Adapts structured language-model output to Choice, Score, and Boolean decisions. */
@@ -65,6 +67,16 @@ export class DecisionLanguageModel implements DecisionModelV4 {
65
67
  providerOptions,
66
68
  }: DecisionModelV4CallOptions): Promise<DecisionModelV4Result> {
67
69
  abortSignal?.throwIfAborted();
70
+ for (const part of state) {
71
+ if (
72
+ part.type === 'file' &&
73
+ getTopLevelMediaType(part.mediaType) !== 'image'
74
+ ) {
75
+ throw new UnsupportedFunctionalityError({
76
+ functionality: `Decision file media type: ${part.mediaType}`,
77
+ });
78
+ }
79
+ }
68
80
  const entries = Object.entries(questions).map(([id, question]) => {
69
81
  if (!this.supportedQuestionTypes.includes(question.type)) {
70
82
  throw new DecisionUnsupportedQuestionTypeError({
@@ -146,10 +158,13 @@ export class DecisionLanguageModel implements DecisionModelV4 {
146
158
  {
147
159
  role: 'user',
148
160
  content: [
149
- {
150
- type: 'text',
151
- text: JSON.stringify({ state, questions: rubrics }),
152
- },
161
+ { type: 'text', text: JSON.stringify({ questions: rubrics }) },
162
+ { type: 'text', text: 'Shared state:' },
163
+ ...state.map(part =>
164
+ part.type === 'json'
165
+ ? { type: 'text' as const, text: JSON.stringify(part.value) }
166
+ : part,
167
+ ),
153
168
  ],
154
169
  },
155
170
  ],