@ai-sdk/gateway 4.0.107 → 4.0.108
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 +18 -0
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/gateway-decision-model.ts +20 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/gateway",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.108",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ai-sdk/provider": "4.0.
|
|
34
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
33
|
+
"@ai-sdk/provider": "4.0.25",
|
|
34
|
+
"@ai-sdk/provider-utils": "5.0.57",
|
|
35
35
|
"@vercel/oidc": "3.2.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
UnsupportedFunctionalityError,
|
|
3
|
+
type Experimental_DecisionModelV4 as DecisionModelV4,
|
|
4
|
+
type SharedV4ProviderMetadata,
|
|
4
5
|
} from '@ai-sdk/provider';
|
|
5
6
|
import {
|
|
6
7
|
combineHeaders,
|
|
@@ -51,6 +52,21 @@ export class GatewayDecisionModel implements DecisionModelV4 {
|
|
|
51
52
|
}: Parameters<DecisionModelV4['doDecide']>[0]): Promise<
|
|
52
53
|
Awaited<ReturnType<DecisionModelV4['doDecide']>>
|
|
53
54
|
> {
|
|
55
|
+
const values = state.map(part => {
|
|
56
|
+
if (part.type === 'file') {
|
|
57
|
+
throw new UnsupportedFunctionalityError({
|
|
58
|
+
functionality: 'Gateway decision file input',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return part.type === 'text' ? part.text : part.value;
|
|
62
|
+
});
|
|
63
|
+
// Keep the legacy Gateway state format: string, JSON object, or JSON array.
|
|
64
|
+
const requestState =
|
|
65
|
+
values.length === 1 &&
|
|
66
|
+
(typeof values[0] === 'string' ||
|
|
67
|
+
(typeof values[0] === 'object' && values[0] !== null))
|
|
68
|
+
? values[0]
|
|
69
|
+
: values;
|
|
54
70
|
const gatewayOptions = await parseProviderOptions({
|
|
55
71
|
provider: 'gateway',
|
|
56
72
|
providerOptions,
|
|
@@ -77,7 +93,7 @@ export class GatewayDecisionModel implements DecisionModelV4 {
|
|
|
77
93
|
await resolve(this.config.o11yHeaders),
|
|
78
94
|
),
|
|
79
95
|
body: {
|
|
80
|
-
state,
|
|
96
|
+
state: requestState,
|
|
81
97
|
questions,
|
|
82
98
|
...(validatedProviderOptions
|
|
83
99
|
? { providerOptions: validatedProviderOptions }
|