@ai-sdk/open-responses 2.0.0-beta.3 → 2.0.0-beta.31
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 +232 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +149 -93
- package/dist/index.js.map +1 -1
- package/package.json +11 -12
- package/src/index.ts +1 -0
- package/src/open-responses-provider.ts +1 -1
- package/src/responses/convert-to-open-responses-input.ts +38 -21
- package/src/responses/open-responses-config.ts +2 -1
- package/src/responses/open-responses-language-model.ts +58 -2
- package/src/responses/open-responses-options.ts +18 -0
- package/dist/index.d.mts +0 -34
- package/dist/index.mjs +0 -613
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,237 @@
|
|
|
1
1
|
# @ai-sdk/open-responses
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
8
|
+
- Updated dependencies [9f0e36c]
|
|
9
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
11
|
+
|
|
12
|
+
## 2.0.0-beta.30
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 58a2ad7: fix: more precise default message for tool execution denial
|
|
17
|
+
- Updated dependencies [785fe16]
|
|
18
|
+
- Updated dependencies [67df0a0]
|
|
19
|
+
- Updated dependencies [befb78c]
|
|
20
|
+
- Updated dependencies [0458559]
|
|
21
|
+
- Updated dependencies [5852c0a]
|
|
22
|
+
- Updated dependencies [fc92055]
|
|
23
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
24
|
+
|
|
25
|
+
## 2.0.0-beta.29
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [2e98477]
|
|
30
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
31
|
+
|
|
32
|
+
## 2.0.0-beta.28
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [eea8d98]
|
|
37
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
38
|
+
|
|
39
|
+
## 2.0.0-beta.27
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [f807e45]
|
|
44
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
45
|
+
|
|
46
|
+
## 2.0.0-beta.26
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [350ea38]
|
|
51
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
52
|
+
|
|
53
|
+
## 2.0.0-beta.25
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Updated dependencies [083947b]
|
|
58
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
59
|
+
|
|
60
|
+
## 2.0.0-beta.24
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [add1126]
|
|
65
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
66
|
+
|
|
67
|
+
## 2.0.0-beta.23
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
72
|
+
|
|
73
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
74
|
+
|
|
75
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
76
|
+
|
|
77
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
78
|
+
|
|
79
|
+
- ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
|
|
80
|
+
- Updated dependencies [b3976a2]
|
|
81
|
+
- Updated dependencies [ff5eba1]
|
|
82
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
83
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
84
|
+
|
|
85
|
+
## 2.0.0-beta.22
|
|
86
|
+
|
|
87
|
+
### Major Changes
|
|
88
|
+
|
|
89
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [ef992f8]
|
|
94
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
95
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
96
|
+
|
|
97
|
+
## 2.0.0-beta.21
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
102
|
+
- Updated dependencies [90e2d8a]
|
|
103
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
104
|
+
|
|
105
|
+
## 2.0.0-beta.20
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [3ae1786]
|
|
110
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
111
|
+
|
|
112
|
+
## 2.0.0-beta.19
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- Updated dependencies [176466a]
|
|
117
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
118
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
119
|
+
|
|
120
|
+
## 2.0.0-beta.18
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- Updated dependencies [e311194]
|
|
125
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
126
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
127
|
+
|
|
128
|
+
## 2.0.0-beta.17
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- e69a836: feat(open-responses): add option to pass reasoning summary for OpenResponses
|
|
133
|
+
|
|
134
|
+
## 2.0.0-beta.16
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- Updated dependencies [34bd95d]
|
|
139
|
+
- Updated dependencies [008271d]
|
|
140
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
141
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
142
|
+
|
|
143
|
+
## 2.0.0-beta.15
|
|
144
|
+
|
|
145
|
+
### Patch Changes
|
|
146
|
+
|
|
147
|
+
- Updated dependencies [b0c2869]
|
|
148
|
+
- Updated dependencies [7e26e81]
|
|
149
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
150
|
+
|
|
151
|
+
## 2.0.0-beta.14
|
|
152
|
+
|
|
153
|
+
### Patch Changes
|
|
154
|
+
|
|
155
|
+
- Updated dependencies [46d1149]
|
|
156
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
157
|
+
|
|
158
|
+
## 2.0.0-beta.13
|
|
159
|
+
|
|
160
|
+
### Patch Changes
|
|
161
|
+
|
|
162
|
+
- Updated dependencies [6fd51c0]
|
|
163
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
164
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
165
|
+
|
|
166
|
+
## 2.0.0-beta.12
|
|
167
|
+
|
|
168
|
+
### Patch Changes
|
|
169
|
+
|
|
170
|
+
- c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
|
|
171
|
+
- Updated dependencies [c29a26f]
|
|
172
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
173
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
174
|
+
|
|
175
|
+
## 2.0.0-beta.11
|
|
176
|
+
|
|
177
|
+
### Patch Changes
|
|
178
|
+
|
|
179
|
+
- Updated dependencies [2e17091]
|
|
180
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
181
|
+
|
|
182
|
+
## 2.0.0-beta.10
|
|
183
|
+
|
|
184
|
+
### Patch Changes
|
|
185
|
+
|
|
186
|
+
- Updated dependencies [986c6fd]
|
|
187
|
+
- Updated dependencies [493295c]
|
|
188
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
189
|
+
|
|
190
|
+
## 2.0.0-beta.9
|
|
191
|
+
|
|
192
|
+
### Patch Changes
|
|
193
|
+
|
|
194
|
+
- Updated dependencies [1f509d4]
|
|
195
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
196
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
197
|
+
|
|
198
|
+
## 2.0.0-beta.8
|
|
199
|
+
|
|
200
|
+
### Patch Changes
|
|
201
|
+
|
|
202
|
+
- 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
|
|
203
|
+
|
|
204
|
+
## 2.0.0-beta.7
|
|
205
|
+
|
|
206
|
+
### Patch Changes
|
|
207
|
+
|
|
208
|
+
- Updated dependencies [3887c70]
|
|
209
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
210
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
211
|
+
|
|
212
|
+
## 2.0.0-beta.6
|
|
213
|
+
|
|
214
|
+
### Patch Changes
|
|
215
|
+
|
|
216
|
+
- Updated dependencies [776b617]
|
|
217
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
218
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
219
|
+
|
|
220
|
+
## 2.0.0-beta.5
|
|
221
|
+
|
|
222
|
+
### Patch Changes
|
|
223
|
+
|
|
224
|
+
- Updated dependencies [61753c3]
|
|
225
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
226
|
+
|
|
227
|
+
## 2.0.0-beta.4
|
|
228
|
+
|
|
229
|
+
### Patch Changes
|
|
230
|
+
|
|
231
|
+
- Updated dependencies [f7d4f01]
|
|
232
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
233
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
234
|
+
|
|
3
235
|
## 2.0.0-beta.3
|
|
4
236
|
|
|
5
237
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
|
|
2
|
-
import
|
|
2
|
+
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
+
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
3
4
|
|
|
4
5
|
declare const VERSION: string;
|
|
5
6
|
|
|
@@ -31,4 +32,9 @@ interface OpenResponsesProviderSettings {
|
|
|
31
32
|
}
|
|
32
33
|
declare function createOpenResponses(options: OpenResponsesProviderSettings): OpenResponsesProvider;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
declare const openResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
36
|
+
reasoningSummary?: "auto" | "concise" | "detailed" | null | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
type OpenResponsesOptions = InferSchema<typeof openResponsesOptionsSchema>;
|
|
39
|
+
|
|
40
|
+
export { type OpenResponsesOptions, VERSION, createOpenResponses };
|
package/dist/index.js
CHANGED
|
@@ -1,43 +1,37 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
VERSION: () => VERSION,
|
|
24
|
-
createOpenResponses: () => createOpenResponses
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
|
|
28
1
|
// src/version.ts
|
|
29
|
-
var VERSION = true ? "2.0.0-beta.
|
|
2
|
+
var VERSION = true ? "2.0.0-beta.31" : "0.0.0-test";
|
|
30
3
|
|
|
31
4
|
// src/open-responses-provider.ts
|
|
32
|
-
|
|
33
|
-
|
|
5
|
+
import {
|
|
6
|
+
NoSuchModelError
|
|
7
|
+
} from "@ai-sdk/provider";
|
|
8
|
+
import {
|
|
9
|
+
generateId,
|
|
10
|
+
withUserAgentSuffix
|
|
11
|
+
} from "@ai-sdk/provider-utils";
|
|
34
12
|
|
|
35
13
|
// src/responses/open-responses-language-model.ts
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
import {
|
|
15
|
+
combineHeaders,
|
|
16
|
+
createEventSourceResponseHandler,
|
|
17
|
+
createJsonErrorResponseHandler,
|
|
18
|
+
createJsonResponseHandler,
|
|
19
|
+
isCustomReasoning,
|
|
20
|
+
jsonSchema,
|
|
21
|
+
mapReasoningToProviderEffort,
|
|
22
|
+
parseProviderOptions,
|
|
23
|
+
postJsonToApi,
|
|
24
|
+
serializeModelOptions,
|
|
25
|
+
WORKFLOW_SERIALIZE,
|
|
26
|
+
WORKFLOW_DESERIALIZE
|
|
27
|
+
} from "@ai-sdk/provider-utils";
|
|
28
|
+
import { z as z3 } from "zod/v4";
|
|
38
29
|
|
|
39
30
|
// src/responses/convert-to-open-responses-input.ts
|
|
40
|
-
|
|
31
|
+
import {
|
|
32
|
+
UnsupportedFunctionalityError
|
|
33
|
+
} from "@ai-sdk/provider";
|
|
34
|
+
import { convertToBase64, isProviderReference } from "@ai-sdk/provider-utils";
|
|
41
35
|
async function convertToOpenResponsesInput({
|
|
42
36
|
prompt
|
|
43
37
|
}) {
|
|
@@ -60,6 +54,11 @@ async function convertToOpenResponsesInput({
|
|
|
60
54
|
break;
|
|
61
55
|
}
|
|
62
56
|
case "file": {
|
|
57
|
+
if (isProviderReference(part.data)) {
|
|
58
|
+
throw new UnsupportedFunctionalityError({
|
|
59
|
+
functionality: "file parts with provider references"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
63
62
|
if (!part.mediaType.startsWith("image/")) {
|
|
64
63
|
warnings.push({
|
|
65
64
|
type: "other",
|
|
@@ -71,7 +70,7 @@ async function convertToOpenResponsesInput({
|
|
|
71
70
|
userContent.push({
|
|
72
71
|
type: "input_image",
|
|
73
72
|
...part.data instanceof URL ? { image_url: part.data.toString() } : {
|
|
74
|
-
image_url: `data:${mediaType};base64,${
|
|
73
|
+
image_url: `data:${mediaType};base64,${convertToBase64(part.data)}`
|
|
75
74
|
}
|
|
76
75
|
});
|
|
77
76
|
break;
|
|
@@ -125,7 +124,7 @@ async function convertToOpenResponsesInput({
|
|
|
125
124
|
contentValue = output.value;
|
|
126
125
|
break;
|
|
127
126
|
case "execution-denied":
|
|
128
|
-
contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
|
|
127
|
+
contentValue = (_a = output.reason) != null ? _a : "Tool call execution denied.";
|
|
129
128
|
break;
|
|
130
129
|
case "json":
|
|
131
130
|
case "error-json":
|
|
@@ -142,26 +141,33 @@ async function convertToOpenResponsesInput({
|
|
|
142
141
|
});
|
|
143
142
|
break;
|
|
144
143
|
}
|
|
145
|
-
case "
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
144
|
+
case "file-data": {
|
|
145
|
+
if (item.mediaType.startsWith("image/")) {
|
|
146
|
+
contentParts.push({
|
|
147
|
+
type: "input_image",
|
|
148
|
+
image_url: `data:${item.mediaType};base64,${item.data}`
|
|
149
|
+
});
|
|
150
|
+
} else {
|
|
151
|
+
contentParts.push({
|
|
152
|
+
type: "input_file",
|
|
153
|
+
filename: (_b = item.filename) != null ? _b : "data",
|
|
154
|
+
file_data: `data:${item.mediaType};base64,${item.data}`
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
157
|
break;
|
|
158
158
|
}
|
|
159
|
-
case "file-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
case "file-url": {
|
|
160
|
+
if (item.mediaType.startsWith("image/")) {
|
|
161
|
+
contentParts.push({
|
|
162
|
+
type: "input_image",
|
|
163
|
+
image_url: item.url
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
contentParts.push({
|
|
167
|
+
type: "input_file",
|
|
168
|
+
file_url: item.url
|
|
169
|
+
});
|
|
170
|
+
}
|
|
165
171
|
break;
|
|
166
172
|
}
|
|
167
173
|
default: {
|
|
@@ -196,17 +202,17 @@ async function convertToOpenResponsesInput({
|
|
|
196
202
|
}
|
|
197
203
|
|
|
198
204
|
// src/responses/open-responses-api.ts
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
var openResponsesErrorSchema =
|
|
203
|
-
() =>
|
|
204
|
-
|
|
205
|
-
error:
|
|
206
|
-
message:
|
|
207
|
-
type:
|
|
208
|
-
param:
|
|
209
|
-
code:
|
|
205
|
+
import { lazySchema } from "@ai-sdk/provider-utils";
|
|
206
|
+
import { z } from "zod/v4";
|
|
207
|
+
import { zodSchema } from "@ai-sdk/provider-utils";
|
|
208
|
+
var openResponsesErrorSchema = lazySchema(
|
|
209
|
+
() => zodSchema(
|
|
210
|
+
z.object({
|
|
211
|
+
error: z.object({
|
|
212
|
+
message: z.string(),
|
|
213
|
+
type: z.string(),
|
|
214
|
+
param: z.string(),
|
|
215
|
+
code: z.string()
|
|
210
216
|
})
|
|
211
217
|
})
|
|
212
218
|
)
|
|
@@ -230,8 +236,23 @@ function mapOpenResponsesFinishReason({
|
|
|
230
236
|
}
|
|
231
237
|
}
|
|
232
238
|
|
|
239
|
+
// src/responses/open-responses-options.ts
|
|
240
|
+
import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
|
|
241
|
+
import { z as z2 } from "zod/v4";
|
|
242
|
+
var openResponsesOptionsSchema = lazySchema2(
|
|
243
|
+
() => zodSchema2(
|
|
244
|
+
z2.object({
|
|
245
|
+
/**
|
|
246
|
+
* Controls reasoning summary output from the model.
|
|
247
|
+
* Valid values: 'concise', 'detailed', 'auto'.
|
|
248
|
+
*/
|
|
249
|
+
reasoningSummary: z2.enum(["concise", "detailed", "auto"]).nullish()
|
|
250
|
+
})
|
|
251
|
+
)
|
|
252
|
+
);
|
|
253
|
+
|
|
233
254
|
// src/responses/open-responses-language-model.ts
|
|
234
|
-
var OpenResponsesLanguageModel = class {
|
|
255
|
+
var OpenResponsesLanguageModel = class _OpenResponsesLanguageModel {
|
|
235
256
|
constructor(modelId, config) {
|
|
236
257
|
this.specificationVersion = "v4";
|
|
237
258
|
this.supportedUrls = {
|
|
@@ -240,6 +261,15 @@ var OpenResponsesLanguageModel = class {
|
|
|
240
261
|
this.modelId = modelId;
|
|
241
262
|
this.config = config;
|
|
242
263
|
}
|
|
264
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
265
|
+
return serializeModelOptions({
|
|
266
|
+
modelId: model.modelId,
|
|
267
|
+
config: model.config
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
271
|
+
return new _OpenResponsesLanguageModel(options.modelId, options.config);
|
|
272
|
+
}
|
|
243
273
|
get provider() {
|
|
244
274
|
return this.config.provider;
|
|
245
275
|
}
|
|
@@ -252,6 +282,7 @@ var OpenResponsesLanguageModel = class {
|
|
|
252
282
|
presencePenalty,
|
|
253
283
|
frequencyPenalty,
|
|
254
284
|
seed,
|
|
285
|
+
reasoning,
|
|
255
286
|
prompt,
|
|
256
287
|
providerOptions,
|
|
257
288
|
tools,
|
|
@@ -294,6 +325,22 @@ var OpenResponsesLanguageModel = class {
|
|
|
294
325
|
strict: true
|
|
295
326
|
} : {}
|
|
296
327
|
} : void 0;
|
|
328
|
+
const openResponsesOptions = await parseProviderOptions({
|
|
329
|
+
provider: this.config.providerOptionsName,
|
|
330
|
+
providerOptions,
|
|
331
|
+
schema: openResponsesOptionsSchema
|
|
332
|
+
});
|
|
333
|
+
const resolvedReasoningEffort = isCustomReasoning(reasoning) ? reasoning === "none" ? "none" : mapReasoningToProviderEffort({
|
|
334
|
+
reasoning,
|
|
335
|
+
effortMap: {
|
|
336
|
+
minimal: "low",
|
|
337
|
+
low: "low",
|
|
338
|
+
medium: "medium",
|
|
339
|
+
high: "high",
|
|
340
|
+
xhigh: "xhigh"
|
|
341
|
+
},
|
|
342
|
+
warnings
|
|
343
|
+
}) : void 0;
|
|
297
344
|
return {
|
|
298
345
|
body: {
|
|
299
346
|
model: this.modelId,
|
|
@@ -304,6 +351,14 @@ var OpenResponsesLanguageModel = class {
|
|
|
304
351
|
top_p: topP,
|
|
305
352
|
presence_penalty: presencePenalty,
|
|
306
353
|
frequency_penalty: frequencyPenalty,
|
|
354
|
+
reasoning: resolvedReasoningEffort != null || (openResponsesOptions == null ? void 0 : openResponsesOptions.reasoningSummary) != null ? {
|
|
355
|
+
...resolvedReasoningEffort != null && {
|
|
356
|
+
effort: resolvedReasoningEffort
|
|
357
|
+
},
|
|
358
|
+
...(openResponsesOptions == null ? void 0 : openResponsesOptions.reasoningSummary) != null && {
|
|
359
|
+
summary: openResponsesOptions.reasoningSummary
|
|
360
|
+
}
|
|
361
|
+
} : void 0,
|
|
307
362
|
tools: (functionTools == null ? void 0 : functionTools.length) ? functionTools : void 0,
|
|
308
363
|
tool_choice: convertedToolChoice,
|
|
309
364
|
...textFormat != null && { text: { format: textFormat } }
|
|
@@ -312,23 +367,23 @@ var OpenResponsesLanguageModel = class {
|
|
|
312
367
|
};
|
|
313
368
|
}
|
|
314
369
|
async doGenerate(options) {
|
|
315
|
-
var _a, _b, _c, _d, _e, _f;
|
|
370
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
316
371
|
const { body, warnings } = await this.getArgs(options);
|
|
317
372
|
const {
|
|
318
373
|
responseHeaders,
|
|
319
374
|
value: response,
|
|
320
375
|
rawValue: rawResponse
|
|
321
|
-
} = await
|
|
376
|
+
} = await postJsonToApi({
|
|
322
377
|
url: this.config.url,
|
|
323
|
-
headers: (
|
|
378
|
+
headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
|
|
324
379
|
body,
|
|
325
|
-
failedResponseHandler:
|
|
380
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
326
381
|
errorSchema: openResponsesErrorSchema,
|
|
327
382
|
errorToMessage: (error) => error.error.message
|
|
328
383
|
}),
|
|
329
|
-
successfulResponseHandler:
|
|
384
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
330
385
|
// do not validate the response body, only apply types to the response body
|
|
331
|
-
|
|
386
|
+
jsonSchema(() => {
|
|
332
387
|
throw new Error("json schema not implemented");
|
|
333
388
|
})
|
|
334
389
|
),
|
|
@@ -341,7 +396,7 @@ var OpenResponsesLanguageModel = class {
|
|
|
341
396
|
switch (part.type) {
|
|
342
397
|
// TODO AI SDK 7 adjust reasoning in the specification to better support the reasoning structure from open responses.
|
|
343
398
|
case "reasoning": {
|
|
344
|
-
for (const contentPart of (
|
|
399
|
+
for (const contentPart of (_c = part.content) != null ? _c : []) {
|
|
345
400
|
content.push({
|
|
346
401
|
type: "reasoning",
|
|
347
402
|
text: contentPart.text
|
|
@@ -372,17 +427,17 @@ var OpenResponsesLanguageModel = class {
|
|
|
372
427
|
}
|
|
373
428
|
const usage = response.usage;
|
|
374
429
|
const inputTokens = usage == null ? void 0 : usage.input_tokens;
|
|
375
|
-
const cachedInputTokens = (
|
|
430
|
+
const cachedInputTokens = (_d = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _d.cached_tokens;
|
|
376
431
|
const outputTokens = usage == null ? void 0 : usage.output_tokens;
|
|
377
|
-
const reasoningTokens = (
|
|
432
|
+
const reasoningTokens = (_e = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens;
|
|
378
433
|
return {
|
|
379
434
|
content,
|
|
380
435
|
finishReason: {
|
|
381
436
|
unified: mapOpenResponsesFinishReason({
|
|
382
|
-
finishReason: (
|
|
437
|
+
finishReason: (_f = response.incomplete_details) == null ? void 0 : _f.reason,
|
|
383
438
|
hasToolCalls
|
|
384
439
|
}),
|
|
385
|
-
raw: (
|
|
440
|
+
raw: (_h = (_g = response.incomplete_details) == null ? void 0 : _g.reason) != null ? _h : void 0
|
|
386
441
|
},
|
|
387
442
|
usage: {
|
|
388
443
|
inputTokens: {
|
|
@@ -411,20 +466,21 @@ var OpenResponsesLanguageModel = class {
|
|
|
411
466
|
};
|
|
412
467
|
}
|
|
413
468
|
async doStream(options) {
|
|
469
|
+
var _a, _b;
|
|
414
470
|
const { body, warnings } = await this.getArgs(options);
|
|
415
|
-
const { responseHeaders, value: response } = await
|
|
471
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
416
472
|
url: this.config.url,
|
|
417
|
-
headers: (
|
|
473
|
+
headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
|
|
418
474
|
body: {
|
|
419
475
|
...body,
|
|
420
476
|
stream: true
|
|
421
477
|
},
|
|
422
|
-
failedResponseHandler:
|
|
478
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
423
479
|
errorSchema: openResponsesErrorSchema,
|
|
424
480
|
errorToMessage: (error) => error.error.message
|
|
425
481
|
}),
|
|
426
482
|
// TODO consider validation
|
|
427
|
-
successfulResponseHandler:
|
|
483
|
+
successfulResponseHandler: createEventSourceResponseHandler(z3.any()),
|
|
428
484
|
abortSignal: options.abortSignal,
|
|
429
485
|
fetch: this.config.fetch
|
|
430
486
|
});
|
|
@@ -442,14 +498,14 @@ var OpenResponsesLanguageModel = class {
|
|
|
442
498
|
}
|
|
443
499
|
};
|
|
444
500
|
const updateUsage = (responseUsage) => {
|
|
445
|
-
var
|
|
501
|
+
var _a2, _b2;
|
|
446
502
|
if (!responseUsage) {
|
|
447
503
|
return;
|
|
448
504
|
}
|
|
449
505
|
const inputTokens = responseUsage.input_tokens;
|
|
450
|
-
const cachedInputTokens = (
|
|
506
|
+
const cachedInputTokens = (_a2 = responseUsage.input_tokens_details) == null ? void 0 : _a2.cached_tokens;
|
|
451
507
|
const outputTokens = responseUsage.output_tokens;
|
|
452
|
-
const reasoningTokens = (
|
|
508
|
+
const reasoningTokens = (_b2 = responseUsage.output_tokens_details) == null ? void 0 : _b2.reasoning_tokens;
|
|
453
509
|
usage.inputTokens = {
|
|
454
510
|
total: inputTokens,
|
|
455
511
|
noCache: (inputTokens != null ? inputTokens : 0) - (cachedInputTokens != null ? cachedInputTokens : 0),
|
|
@@ -477,7 +533,7 @@ var OpenResponsesLanguageModel = class {
|
|
|
477
533
|
controller.enqueue({ type: "stream-start", warnings });
|
|
478
534
|
},
|
|
479
535
|
transform(parseResult, controller) {
|
|
480
|
-
var
|
|
536
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
481
537
|
if (options.includeRawChunks) {
|
|
482
538
|
controller.enqueue({
|
|
483
539
|
type: "raw",
|
|
@@ -497,8 +553,8 @@ var OpenResponsesLanguageModel = class {
|
|
|
497
553
|
};
|
|
498
554
|
} else if (chunk.type === "response.function_call_arguments.delta") {
|
|
499
555
|
const functionCallChunk = chunk;
|
|
500
|
-
const toolCall = (
|
|
501
|
-
toolCall.arguments = ((
|
|
556
|
+
const toolCall = (_a2 = toolCallsByItemId[functionCallChunk.item_id]) != null ? _a2 : toolCallsByItemId[functionCallChunk.item_id] = {};
|
|
557
|
+
toolCall.arguments = ((_b2 = toolCall.arguments) != null ? _b2 : "") + functionCallChunk.delta;
|
|
502
558
|
} else if (chunk.type === "response.function_call_arguments.done") {
|
|
503
559
|
const functionCallChunk = chunk;
|
|
504
560
|
const toolCall = (_c = toolCallsByItemId[functionCallChunk.item_id]) != null ? _c : toolCallsByItemId[functionCallChunk.item_id] = {};
|
|
@@ -582,7 +638,7 @@ var OpenResponsesLanguageModel = class {
|
|
|
582
638
|
// src/open-responses-provider.ts
|
|
583
639
|
function createOpenResponses(options) {
|
|
584
640
|
const providerName = options.name;
|
|
585
|
-
const getHeaders = () =>
|
|
641
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
586
642
|
{
|
|
587
643
|
...options.apiKey ? {
|
|
588
644
|
Authorization: `Bearer ${options.apiKey}`
|
|
@@ -594,10 +650,11 @@ function createOpenResponses(options) {
|
|
|
594
650
|
const createResponsesModel = (modelId) => {
|
|
595
651
|
return new OpenResponsesLanguageModel(modelId, {
|
|
596
652
|
provider: `${providerName}.responses`,
|
|
653
|
+
providerOptionsName: providerName,
|
|
597
654
|
headers: getHeaders,
|
|
598
655
|
url: options.url,
|
|
599
656
|
fetch: options.fetch,
|
|
600
|
-
generateId: () =>
|
|
657
|
+
generateId: () => generateId()
|
|
601
658
|
});
|
|
602
659
|
};
|
|
603
660
|
const createLanguageModel = (modelId) => {
|
|
@@ -614,16 +671,15 @@ function createOpenResponses(options) {
|
|
|
614
671
|
provider.specificationVersion = "v4";
|
|
615
672
|
provider.languageModel = createLanguageModel;
|
|
616
673
|
provider.embeddingModel = (modelId) => {
|
|
617
|
-
throw new
|
|
674
|
+
throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
618
675
|
};
|
|
619
676
|
provider.imageModel = (modelId) => {
|
|
620
|
-
throw new
|
|
677
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
621
678
|
};
|
|
622
679
|
return provider;
|
|
623
680
|
}
|
|
624
|
-
|
|
625
|
-
0 && (module.exports = {
|
|
681
|
+
export {
|
|
626
682
|
VERSION,
|
|
627
683
|
createOpenResponses
|
|
628
|
-
}
|
|
684
|
+
};
|
|
629
685
|
//# sourceMappingURL=index.js.map
|