@ai-sdk/deepinfra 3.0.0-beta.8 → 3.0.0-canary.37
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 +277 -0
- package/README.md +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +84 -70
- package/dist/index.js.map +1 -1
- package/docs/11-deepinfra.mdx +14 -14
- package/package.json +12 -10
- package/src/deepinfra-chat-language-model.ts +22 -4
- package/src/deepinfra-completion-options.ts +1 -1
- package/src/deepinfra-image-model.ts +23 -6
- package/src/deepinfra-provider.ts +7 -7
- package/src/index.ts +6 -1
- package/dist/index.d.mts +0 -71
- package/dist/index.mjs +0 -344
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,282 @@
|
|
|
1
1
|
# @ai-sdk/deepinfra
|
|
2
2
|
|
|
3
|
+
## 3.0.0-canary.37
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0c4c275: trigger initial canary release
|
|
8
|
+
- Updated dependencies [0c4c275]
|
|
9
|
+
- @ai-sdk/openai-compatible@3.0.0-canary.37
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.0-canary.31
|
|
11
|
+
- @ai-sdk/provider@4.0.0-canary.15
|
|
12
|
+
|
|
13
|
+
## 3.0.0-beta.36
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [e59c955]
|
|
18
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.36
|
|
19
|
+
|
|
20
|
+
## 3.0.0-beta.35
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
|
|
25
|
+
|
|
26
|
+
For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [08d2129]
|
|
31
|
+
- Updated dependencies [04e9009]
|
|
32
|
+
- @ai-sdk/provider-utils@5.0.0-beta.30
|
|
33
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.35
|
|
34
|
+
|
|
35
|
+
## 3.0.0-beta.34
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
40
|
+
- Updated dependencies [9bd6512]
|
|
41
|
+
- Updated dependencies [258c093]
|
|
42
|
+
- Updated dependencies [b6783da]
|
|
43
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.34
|
|
44
|
+
- @ai-sdk/provider-utils@5.0.0-beta.29
|
|
45
|
+
- @ai-sdk/provider@4.0.0-beta.14
|
|
46
|
+
|
|
47
|
+
## 3.0.0-beta.33
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
52
|
+
- Updated dependencies [9f0e36c]
|
|
53
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.33
|
|
54
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
55
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
56
|
+
|
|
57
|
+
## 3.0.0-beta.32
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Updated dependencies [ab81968]
|
|
62
|
+
- Updated dependencies [785fe16]
|
|
63
|
+
- Updated dependencies [67df0a0]
|
|
64
|
+
- Updated dependencies [befb78c]
|
|
65
|
+
- Updated dependencies [0458559]
|
|
66
|
+
- Updated dependencies [58a2ad7]
|
|
67
|
+
- Updated dependencies [5852c0a]
|
|
68
|
+
- Updated dependencies [fc92055]
|
|
69
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.32
|
|
70
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
71
|
+
|
|
72
|
+
## 3.0.0-beta.31
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies [2e98477]
|
|
77
|
+
- Updated dependencies [bfb756d]
|
|
78
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
79
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.31
|
|
80
|
+
|
|
81
|
+
## 3.0.0-beta.30
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- Updated dependencies [eea8d98]
|
|
86
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
87
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.30
|
|
88
|
+
|
|
89
|
+
## 3.0.0-beta.29
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [f807e45]
|
|
94
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
95
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.29
|
|
96
|
+
|
|
97
|
+
## 3.0.0-beta.28
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- Updated dependencies [350ea38]
|
|
102
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
103
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.28
|
|
104
|
+
|
|
105
|
+
## 3.0.0-beta.27
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [083947b]
|
|
110
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
111
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.27
|
|
112
|
+
|
|
113
|
+
## 3.0.0-beta.26
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- Updated dependencies [add1126]
|
|
118
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
119
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.26
|
|
120
|
+
|
|
121
|
+
## 3.0.0-beta.25
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
126
|
+
|
|
127
|
+
**`@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.
|
|
128
|
+
|
|
129
|
+
**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.
|
|
130
|
+
|
|
131
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
132
|
+
|
|
133
|
+
- Updated dependencies [b3976a2]
|
|
134
|
+
- Updated dependencies [ff5eba1]
|
|
135
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
136
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.25
|
|
137
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
138
|
+
|
|
139
|
+
## 3.0.0-beta.24
|
|
140
|
+
|
|
141
|
+
### Major Changes
|
|
142
|
+
|
|
143
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
144
|
+
|
|
145
|
+
### Patch Changes
|
|
146
|
+
|
|
147
|
+
- Updated dependencies [ef992f8]
|
|
148
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.24
|
|
149
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
150
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
151
|
+
|
|
152
|
+
## 3.0.0-beta.23
|
|
153
|
+
|
|
154
|
+
### Patch Changes
|
|
155
|
+
|
|
156
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
157
|
+
- Updated dependencies [90e2d8a]
|
|
158
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.23
|
|
159
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
160
|
+
|
|
161
|
+
## 3.0.0-beta.22
|
|
162
|
+
|
|
163
|
+
### Patch Changes
|
|
164
|
+
|
|
165
|
+
- Updated dependencies [3ae1786]
|
|
166
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
167
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.22
|
|
168
|
+
|
|
169
|
+
## 3.0.0-beta.21
|
|
170
|
+
|
|
171
|
+
### Patch Changes
|
|
172
|
+
|
|
173
|
+
- Updated dependencies [176466a]
|
|
174
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
175
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.21
|
|
176
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
177
|
+
|
|
178
|
+
## 3.0.0-beta.20
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- Updated dependencies [e311194]
|
|
183
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
184
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.20
|
|
185
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
186
|
+
|
|
187
|
+
## 3.0.0-beta.19
|
|
188
|
+
|
|
189
|
+
### Patch Changes
|
|
190
|
+
|
|
191
|
+
- Updated dependencies [34bd95d]
|
|
192
|
+
- Updated dependencies [008271d]
|
|
193
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
194
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.19
|
|
195
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
196
|
+
|
|
197
|
+
## 3.0.0-beta.18
|
|
198
|
+
|
|
199
|
+
### Patch Changes
|
|
200
|
+
|
|
201
|
+
- Updated dependencies [b0c2869]
|
|
202
|
+
- Updated dependencies [7e26e81]
|
|
203
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
204
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.18
|
|
205
|
+
|
|
206
|
+
## 3.0.0-beta.17
|
|
207
|
+
|
|
208
|
+
### Patch Changes
|
|
209
|
+
|
|
210
|
+
- Updated dependencies [816ff67]
|
|
211
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.17
|
|
212
|
+
|
|
213
|
+
## 3.0.0-beta.16
|
|
214
|
+
|
|
215
|
+
### Patch Changes
|
|
216
|
+
|
|
217
|
+
- Updated dependencies [46d1149]
|
|
218
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
219
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.16
|
|
220
|
+
|
|
221
|
+
## 3.0.0-beta.15
|
|
222
|
+
|
|
223
|
+
### Patch Changes
|
|
224
|
+
|
|
225
|
+
- Updated dependencies [6fd51c0]
|
|
226
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
227
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
228
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.15
|
|
229
|
+
|
|
230
|
+
## 3.0.0-beta.14
|
|
231
|
+
|
|
232
|
+
### Patch Changes
|
|
233
|
+
|
|
234
|
+
- Updated dependencies [c29a26f]
|
|
235
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.14
|
|
236
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
237
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
238
|
+
|
|
239
|
+
## 3.0.0-beta.13
|
|
240
|
+
|
|
241
|
+
### Patch Changes
|
|
242
|
+
|
|
243
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
244
|
+
- Updated dependencies [38fc777]
|
|
245
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.13
|
|
246
|
+
|
|
247
|
+
## 3.0.0-beta.12
|
|
248
|
+
|
|
249
|
+
### Patch Changes
|
|
250
|
+
|
|
251
|
+
- Updated dependencies [2e17091]
|
|
252
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
253
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.12
|
|
254
|
+
|
|
255
|
+
## 3.0.0-beta.11
|
|
256
|
+
|
|
257
|
+
### Patch Changes
|
|
258
|
+
|
|
259
|
+
- Updated dependencies [986c6fd]
|
|
260
|
+
- Updated dependencies [493295c]
|
|
261
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
262
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.11
|
|
263
|
+
|
|
264
|
+
## 3.0.0-beta.10
|
|
265
|
+
|
|
266
|
+
### Patch Changes
|
|
267
|
+
|
|
268
|
+
- Updated dependencies [1f509d4]
|
|
269
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
270
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
271
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.10
|
|
272
|
+
|
|
273
|
+
## 3.0.0-beta.9
|
|
274
|
+
|
|
275
|
+
### Patch Changes
|
|
276
|
+
|
|
277
|
+
- Updated dependencies [74d520f]
|
|
278
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.9
|
|
279
|
+
|
|
3
280
|
## 3.0.0-beta.8
|
|
4
281
|
|
|
5
282
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
The **[DeepInfra provider](https://ai-sdk.dev/providers/ai-sdk-providers/deepinfra)** for the [AI SDK](https://ai-sdk.dev/docs)
|
|
4
4
|
contains language model support for the DeepInfra API, giving you access to models like Llama 3, Mixtral, and other state-of-the-art LLMs.
|
|
5
5
|
|
|
6
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access DeepInfra (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
7
|
+
|
|
6
8
|
## Setup
|
|
7
9
|
|
|
8
10
|
The DeepInfra provider is available in the `@ai-sdk/deepinfra` module. You can install it with
|
package/dist/index.d.ts
CHANGED
|
@@ -64,8 +64,8 @@ interface DeepInfraProvider extends ProviderV4 {
|
|
|
64
64
|
textEmbeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV4;
|
|
65
65
|
}
|
|
66
66
|
declare function createDeepInfra(options?: DeepInfraProviderSettings): DeepInfraProvider;
|
|
67
|
-
declare const
|
|
67
|
+
declare const deepInfra: DeepInfraProvider;
|
|
68
68
|
|
|
69
69
|
declare const VERSION: string;
|
|
70
70
|
|
|
71
|
-
export { type DeepInfraProvider, type DeepInfraProviderSettings, VERSION, createDeepInfra, deepinfra };
|
|
71
|
+
export { type DeepInfraProvider, type DeepInfraProviderSettings, VERSION, createDeepInfra, deepInfra, deepInfra as deepinfra };
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,30 @@
|
|
|
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
|
-
createDeepInfra: () => createDeepInfra,
|
|
25
|
-
deepinfra: () => deepinfra
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/deepinfra-provider.ts
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import {
|
|
3
|
+
OpenAICompatibleCompletionLanguageModel,
|
|
4
|
+
OpenAICompatibleEmbeddingModel
|
|
5
|
+
} from "@ai-sdk/openai-compatible";
|
|
6
|
+
import {
|
|
7
|
+
loadApiKey,
|
|
8
|
+
withoutTrailingSlash,
|
|
9
|
+
withUserAgentSuffix
|
|
10
|
+
} from "@ai-sdk/provider-utils";
|
|
32
11
|
|
|
33
12
|
// src/deepinfra-image-model.ts
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
import {
|
|
14
|
+
combineHeaders,
|
|
15
|
+
convertBase64ToUint8Array,
|
|
16
|
+
convertToFormData,
|
|
17
|
+
createJsonErrorResponseHandler,
|
|
18
|
+
createJsonResponseHandler,
|
|
19
|
+
downloadBlob,
|
|
20
|
+
postFormDataToApi,
|
|
21
|
+
postJsonToApi,
|
|
22
|
+
serializeModelOptions,
|
|
23
|
+
WORKFLOW_SERIALIZE,
|
|
24
|
+
WORKFLOW_DESERIALIZE
|
|
25
|
+
} from "@ai-sdk/provider-utils";
|
|
26
|
+
import { z } from "zod/v4";
|
|
27
|
+
var DeepInfraImageModel = class _DeepInfraImageModel {
|
|
37
28
|
constructor(modelId, config) {
|
|
38
29
|
this.modelId = modelId;
|
|
39
30
|
this.config = config;
|
|
@@ -43,6 +34,15 @@ var DeepInfraImageModel = class {
|
|
|
43
34
|
get provider() {
|
|
44
35
|
return this.config.provider;
|
|
45
36
|
}
|
|
37
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
38
|
+
return serializeModelOptions({
|
|
39
|
+
modelId: model.modelId,
|
|
40
|
+
config: model.config
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
44
|
+
return new _DeepInfraImageModel(options.modelId, options.config);
|
|
45
|
+
}
|
|
46
46
|
async doGenerate({
|
|
47
47
|
prompt,
|
|
48
48
|
n,
|
|
@@ -55,14 +55,14 @@ var DeepInfraImageModel = class {
|
|
|
55
55
|
files,
|
|
56
56
|
mask
|
|
57
57
|
}) {
|
|
58
|
-
var _a, _b, _c, _d, _e;
|
|
58
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
59
59
|
const warnings = [];
|
|
60
60
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
61
61
|
if (files != null && files.length > 0) {
|
|
62
|
-
const { value: response2, responseHeaders: responseHeaders2 } = await
|
|
62
|
+
const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
|
|
63
63
|
url: this.getEditUrl(),
|
|
64
|
-
headers: (
|
|
65
|
-
formData:
|
|
64
|
+
headers: combineHeaders((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), headers),
|
|
65
|
+
formData: convertToFormData(
|
|
66
66
|
{
|
|
67
67
|
model: this.modelId,
|
|
68
68
|
prompt,
|
|
@@ -70,18 +70,18 @@ var DeepInfraImageModel = class {
|
|
|
70
70
|
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
71
71
|
n,
|
|
72
72
|
size,
|
|
73
|
-
...(
|
|
73
|
+
...(_f = providerOptions.deepinfra) != null ? _f : {}
|
|
74
74
|
},
|
|
75
75
|
{ useArrayBrackets: false }
|
|
76
76
|
),
|
|
77
|
-
failedResponseHandler:
|
|
77
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
78
78
|
errorSchema: deepInfraEditErrorSchema,
|
|
79
79
|
errorToMessage: (error) => {
|
|
80
80
|
var _a2, _b2;
|
|
81
81
|
return (_b2 = (_a2 = error.error) == null ? void 0 : _a2.message) != null ? _b2 : "Unknown error";
|
|
82
82
|
}
|
|
83
83
|
}),
|
|
84
|
-
successfulResponseHandler:
|
|
84
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
85
85
|
deepInfraEditResponseSchema
|
|
86
86
|
),
|
|
87
87
|
abortSignal,
|
|
@@ -98,22 +98,22 @@ var DeepInfraImageModel = class {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
const splitSize = size == null ? void 0 : size.split("x");
|
|
101
|
-
const { value: response, responseHeaders } = await
|
|
101
|
+
const { value: response, responseHeaders } = await postJsonToApi({
|
|
102
102
|
url: `${this.config.baseURL}/${this.modelId}`,
|
|
103
|
-
headers: (
|
|
103
|
+
headers: combineHeaders((_h = (_g = this.config).headers) == null ? void 0 : _h.call(_g), headers),
|
|
104
104
|
body: {
|
|
105
105
|
prompt,
|
|
106
106
|
num_images: n,
|
|
107
107
|
...aspectRatio && { aspect_ratio: aspectRatio },
|
|
108
108
|
...splitSize && { width: splitSize[0], height: splitSize[1] },
|
|
109
109
|
...seed != null && { seed },
|
|
110
|
-
...(
|
|
110
|
+
...(_i = providerOptions.deepinfra) != null ? _i : {}
|
|
111
111
|
},
|
|
112
|
-
failedResponseHandler:
|
|
112
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
113
113
|
errorSchema: deepInfraErrorSchema,
|
|
114
114
|
errorToMessage: (error) => error.detail.error
|
|
115
115
|
}),
|
|
116
|
-
successfulResponseHandler:
|
|
116
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
117
117
|
deepInfraImageResponseSchema
|
|
118
118
|
),
|
|
119
119
|
abortSignal,
|
|
@@ -136,33 +136,47 @@ var DeepInfraImageModel = class {
|
|
|
136
136
|
return `${baseUrl}/images/edits`;
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
|
-
var deepInfraErrorSchema =
|
|
140
|
-
detail:
|
|
141
|
-
error:
|
|
139
|
+
var deepInfraErrorSchema = z.object({
|
|
140
|
+
detail: z.object({
|
|
141
|
+
error: z.string()
|
|
142
142
|
})
|
|
143
143
|
});
|
|
144
|
-
var deepInfraImageResponseSchema =
|
|
145
|
-
images:
|
|
144
|
+
var deepInfraImageResponseSchema = z.object({
|
|
145
|
+
images: z.array(z.string())
|
|
146
146
|
});
|
|
147
|
-
var deepInfraEditErrorSchema =
|
|
148
|
-
error:
|
|
149
|
-
message:
|
|
147
|
+
var deepInfraEditErrorSchema = z.object({
|
|
148
|
+
error: z.object({
|
|
149
|
+
message: z.string()
|
|
150
150
|
}).optional()
|
|
151
151
|
});
|
|
152
|
-
var deepInfraEditResponseSchema =
|
|
153
|
-
data:
|
|
152
|
+
var deepInfraEditResponseSchema = z.object({
|
|
153
|
+
data: z.array(z.object({ b64_json: z.string() }))
|
|
154
154
|
});
|
|
155
155
|
async function fileToBlob(file) {
|
|
156
156
|
if (file.type === "url") {
|
|
157
|
-
return
|
|
157
|
+
return downloadBlob(file.url);
|
|
158
158
|
}
|
|
159
|
-
const data = file.data instanceof Uint8Array ? file.data :
|
|
159
|
+
const data = file.data instanceof Uint8Array ? file.data : convertBase64ToUint8Array(file.data);
|
|
160
160
|
return new Blob([data], { type: file.mediaType });
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
// src/deepinfra-chat-language-model.ts
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
import { OpenAICompatibleChatLanguageModel } from "@ai-sdk/openai-compatible";
|
|
165
|
+
import {
|
|
166
|
+
serializeModelOptions as serializeModelOptions2,
|
|
167
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
168
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
|
|
169
|
+
} from "@ai-sdk/provider-utils";
|
|
170
|
+
var DeepInfraChatLanguageModel = class _DeepInfraChatLanguageModel extends OpenAICompatibleChatLanguageModel {
|
|
171
|
+
static [WORKFLOW_SERIALIZE2](model) {
|
|
172
|
+
return serializeModelOptions2({
|
|
173
|
+
modelId: model.modelId,
|
|
174
|
+
config: model.config
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
static [WORKFLOW_DESERIALIZE2](options) {
|
|
178
|
+
return new _DeepInfraChatLanguageModel(options.modelId, options.config);
|
|
179
|
+
}
|
|
166
180
|
constructor(modelId, config) {
|
|
167
181
|
super(modelId, config);
|
|
168
182
|
}
|
|
@@ -293,17 +307,17 @@ var DeepInfraChatLanguageModel = class extends import_openai_compatible.OpenAICo
|
|
|
293
307
|
};
|
|
294
308
|
|
|
295
309
|
// src/version.ts
|
|
296
|
-
var VERSION = true ? "3.0.0-
|
|
310
|
+
var VERSION = true ? "3.0.0-canary.37" : "0.0.0-test";
|
|
297
311
|
|
|
298
312
|
// src/deepinfra-provider.ts
|
|
299
313
|
function createDeepInfra(options = {}) {
|
|
300
314
|
var _a;
|
|
301
|
-
const baseURL =
|
|
315
|
+
const baseURL = withoutTrailingSlash(
|
|
302
316
|
(_a = options.baseURL) != null ? _a : "https://api.deepinfra.com/v1"
|
|
303
317
|
);
|
|
304
|
-
const getHeaders = () =>
|
|
318
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
305
319
|
{
|
|
306
|
-
Authorization: `Bearer ${
|
|
320
|
+
Authorization: `Bearer ${loadApiKey({
|
|
307
321
|
apiKey: options.apiKey,
|
|
308
322
|
environmentVariableName: "DEEPINFRA_API_KEY",
|
|
309
323
|
description: "DeepInfra's API key"
|
|
@@ -324,11 +338,11 @@ function createDeepInfra(options = {}) {
|
|
|
324
338
|
getCommonModelConfig("chat")
|
|
325
339
|
);
|
|
326
340
|
};
|
|
327
|
-
const createCompletionModel = (modelId) => new
|
|
341
|
+
const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(
|
|
328
342
|
modelId,
|
|
329
343
|
getCommonModelConfig("completion")
|
|
330
344
|
);
|
|
331
|
-
const createEmbeddingModel = (modelId) => new
|
|
345
|
+
const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(
|
|
332
346
|
modelId,
|
|
333
347
|
getCommonModelConfig("embedding")
|
|
334
348
|
);
|
|
@@ -347,11 +361,11 @@ function createDeepInfra(options = {}) {
|
|
|
347
361
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
348
362
|
return provider;
|
|
349
363
|
}
|
|
350
|
-
var
|
|
351
|
-
|
|
352
|
-
0 && (module.exports = {
|
|
364
|
+
var deepInfra = createDeepInfra();
|
|
365
|
+
export {
|
|
353
366
|
VERSION,
|
|
354
367
|
createDeepInfra,
|
|
355
|
-
|
|
356
|
-
|
|
368
|
+
deepInfra,
|
|
369
|
+
deepInfra as deepinfra
|
|
370
|
+
};
|
|
357
371
|
//# sourceMappingURL=index.js.map
|