@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/CHANGELOG.md +24 -0
- package/dist/experimental-decision/index.d.ts.map +1 -1
- package/dist/experimental-decision/index.js +32 -8
- package/dist/experimental-decision/index.js.map +1 -1
- package/dist/experimental-evaluation/index.d.ts.map +1 -1
- package/dist/experimental-evaluation/index.js +32 -8
- package/dist/experimental-evaluation/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/decision-language-model.ts +19 -4
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/provider-utils",
|
|
3
|
-
"version": "5.0.
|
|
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.
|
|
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
|
-
|
|
151
|
-
|
|
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
|
],
|