@ai-sdk/togetherai 3.0.0-beta.3 → 3.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 +260 -8
- package/README.md +2 -0
- package/dist/index.js +102 -96
- package/dist/index.js.map +1 -1
- package/package.json +8 -10
- package/src/togetherai-image-model.ts +19 -2
- package/dist/index.d.mts +0 -103
- package/dist/index.mjs +0 -354
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,257 @@
|
|
|
1
1
|
# @ai-sdk/togetherai
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [2e98477]
|
|
8
|
+
- Updated dependencies [bfb756d]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
10
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.31
|
|
11
|
+
|
|
12
|
+
## 3.0.0-beta.30
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [eea8d98]
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
18
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.30
|
|
19
|
+
|
|
20
|
+
## 3.0.0-beta.29
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [f807e45]
|
|
25
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
26
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.29
|
|
27
|
+
|
|
28
|
+
## 3.0.0-beta.28
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [350ea38]
|
|
33
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
34
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.28
|
|
35
|
+
|
|
36
|
+
## 3.0.0-beta.27
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [083947b]
|
|
41
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
42
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.27
|
|
43
|
+
|
|
44
|
+
## 3.0.0-beta.26
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [add1126]
|
|
49
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
50
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.26
|
|
51
|
+
|
|
52
|
+
## 3.0.0-beta.25
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
57
|
+
|
|
58
|
+
**`@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.
|
|
59
|
+
|
|
60
|
+
**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.
|
|
61
|
+
|
|
62
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [b3976a2]
|
|
65
|
+
- Updated dependencies [ff5eba1]
|
|
66
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
67
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.25
|
|
68
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
69
|
+
|
|
70
|
+
## 3.0.0-beta.24
|
|
71
|
+
|
|
72
|
+
### Major Changes
|
|
73
|
+
|
|
74
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [ef992f8]
|
|
79
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.24
|
|
80
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
81
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
82
|
+
|
|
83
|
+
## 3.0.0-beta.23
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
88
|
+
- Updated dependencies [90e2d8a]
|
|
89
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.23
|
|
90
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
91
|
+
|
|
92
|
+
## 3.0.0-beta.22
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- Updated dependencies [3ae1786]
|
|
97
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
98
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.22
|
|
99
|
+
|
|
100
|
+
## 3.0.0-beta.21
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- Updated dependencies [176466a]
|
|
105
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
106
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.21
|
|
107
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
108
|
+
|
|
109
|
+
## 3.0.0-beta.20
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- Updated dependencies [e311194]
|
|
114
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
115
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.20
|
|
116
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
117
|
+
|
|
118
|
+
## 3.0.0-beta.19
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- Updated dependencies [34bd95d]
|
|
123
|
+
- Updated dependencies [008271d]
|
|
124
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
125
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.19
|
|
126
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
127
|
+
|
|
128
|
+
## 3.0.0-beta.18
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- Updated dependencies [b0c2869]
|
|
133
|
+
- Updated dependencies [7e26e81]
|
|
134
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
135
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.18
|
|
136
|
+
|
|
137
|
+
## 3.0.0-beta.17
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- Updated dependencies [816ff67]
|
|
142
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.17
|
|
143
|
+
|
|
144
|
+
## 3.0.0-beta.16
|
|
145
|
+
|
|
146
|
+
### Patch Changes
|
|
147
|
+
|
|
148
|
+
- Updated dependencies [46d1149]
|
|
149
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
150
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.16
|
|
151
|
+
|
|
152
|
+
## 3.0.0-beta.15
|
|
153
|
+
|
|
154
|
+
### Patch Changes
|
|
155
|
+
|
|
156
|
+
- Updated dependencies [6fd51c0]
|
|
157
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
158
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
159
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.15
|
|
160
|
+
|
|
161
|
+
## 3.0.0-beta.14
|
|
162
|
+
|
|
163
|
+
### Patch Changes
|
|
164
|
+
|
|
165
|
+
- Updated dependencies [c29a26f]
|
|
166
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.14
|
|
167
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
168
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
169
|
+
|
|
170
|
+
## 3.0.0-beta.13
|
|
171
|
+
|
|
172
|
+
### Patch Changes
|
|
173
|
+
|
|
174
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
175
|
+
- Updated dependencies [38fc777]
|
|
176
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.13
|
|
177
|
+
|
|
178
|
+
## 3.0.0-beta.12
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- Updated dependencies [2e17091]
|
|
183
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
184
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.12
|
|
185
|
+
|
|
186
|
+
## 3.0.0-beta.11
|
|
187
|
+
|
|
188
|
+
### Patch Changes
|
|
189
|
+
|
|
190
|
+
- Updated dependencies [986c6fd]
|
|
191
|
+
- Updated dependencies [493295c]
|
|
192
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
193
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.11
|
|
194
|
+
|
|
195
|
+
## 3.0.0-beta.10
|
|
196
|
+
|
|
197
|
+
### Patch Changes
|
|
198
|
+
|
|
199
|
+
- Updated dependencies [1f509d4]
|
|
200
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
201
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
202
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.10
|
|
203
|
+
|
|
204
|
+
## 3.0.0-beta.9
|
|
205
|
+
|
|
206
|
+
### Patch Changes
|
|
207
|
+
|
|
208
|
+
- Updated dependencies [74d520f]
|
|
209
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.9
|
|
210
|
+
|
|
211
|
+
## 3.0.0-beta.8
|
|
212
|
+
|
|
213
|
+
### Patch Changes
|
|
214
|
+
|
|
215
|
+
- Updated dependencies [3887c70]
|
|
216
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
217
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
218
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.8
|
|
219
|
+
|
|
220
|
+
## 3.0.0-beta.7
|
|
221
|
+
|
|
222
|
+
### Patch Changes
|
|
223
|
+
|
|
224
|
+
- Updated dependencies [776b617]
|
|
225
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
226
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
227
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.7
|
|
228
|
+
|
|
229
|
+
## 3.0.0-beta.6
|
|
230
|
+
|
|
231
|
+
### Patch Changes
|
|
232
|
+
|
|
233
|
+
- Updated dependencies [61753c3]
|
|
234
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
235
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.6
|
|
236
|
+
|
|
237
|
+
## 3.0.0-beta.5
|
|
238
|
+
|
|
239
|
+
### Patch Changes
|
|
240
|
+
|
|
241
|
+
- Updated dependencies [f7d4f01]
|
|
242
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
243
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
244
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.5
|
|
245
|
+
|
|
246
|
+
## 3.0.0-beta.4
|
|
247
|
+
|
|
248
|
+
### Patch Changes
|
|
249
|
+
|
|
250
|
+
- Updated dependencies [5c2a5a2]
|
|
251
|
+
- @ai-sdk/provider@4.0.0-beta.1
|
|
252
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.4
|
|
253
|
+
- @ai-sdk/provider-utils@5.0.0-beta.2
|
|
254
|
+
|
|
3
255
|
## 3.0.0-beta.3
|
|
4
256
|
|
|
5
257
|
### Patch Changes
|
|
@@ -356,13 +608,13 @@
|
|
|
356
608
|
Before
|
|
357
609
|
|
|
358
610
|
```ts
|
|
359
|
-
model.textEmbeddingModel(
|
|
611
|
+
model.textEmbeddingModel("my-model-id");
|
|
360
612
|
```
|
|
361
613
|
|
|
362
614
|
After
|
|
363
615
|
|
|
364
616
|
```ts
|
|
365
|
-
model.embeddingModel(
|
|
617
|
+
model.embeddingModel("my-model-id");
|
|
366
618
|
```
|
|
367
619
|
|
|
368
620
|
- 95f65c2: chore: use import \* from zod/v4
|
|
@@ -592,13 +844,13 @@
|
|
|
592
844
|
Before
|
|
593
845
|
|
|
594
846
|
```ts
|
|
595
|
-
model.textEmbeddingModel(
|
|
847
|
+
model.textEmbeddingModel("my-model-id");
|
|
596
848
|
```
|
|
597
849
|
|
|
598
850
|
After
|
|
599
851
|
|
|
600
852
|
```ts
|
|
601
|
-
model.embeddingModel(
|
|
853
|
+
model.embeddingModel("my-model-id");
|
|
602
854
|
```
|
|
603
855
|
|
|
604
856
|
- Updated dependencies [8d9e8ad]
|
|
@@ -1093,7 +1345,7 @@
|
|
|
1093
1345
|
|
|
1094
1346
|
```js
|
|
1095
1347
|
await generateImage({
|
|
1096
|
-
model: luma.image(
|
|
1348
|
+
model: luma.image("photon-flash-1", {
|
|
1097
1349
|
maxImagesPerCall: 5,
|
|
1098
1350
|
pollIntervalMillis: 500,
|
|
1099
1351
|
}),
|
|
@@ -1106,7 +1358,7 @@
|
|
|
1106
1358
|
|
|
1107
1359
|
```js
|
|
1108
1360
|
await generateImage({
|
|
1109
|
-
model: luma.image(
|
|
1361
|
+
model: luma.image("photon-flash-1"),
|
|
1110
1362
|
prompt,
|
|
1111
1363
|
n: 10,
|
|
1112
1364
|
maxImagesPerCall: 5,
|
|
@@ -1394,7 +1646,7 @@
|
|
|
1394
1646
|
|
|
1395
1647
|
```js
|
|
1396
1648
|
await generateImage({
|
|
1397
|
-
model: luma.image(
|
|
1649
|
+
model: luma.image("photon-flash-1", {
|
|
1398
1650
|
maxImagesPerCall: 5,
|
|
1399
1651
|
pollIntervalMillis: 500,
|
|
1400
1652
|
}),
|
|
@@ -1407,7 +1659,7 @@
|
|
|
1407
1659
|
|
|
1408
1660
|
```js
|
|
1409
1661
|
await generateImage({
|
|
1410
|
-
model: luma.image(
|
|
1662
|
+
model: luma.image("photon-flash-1"),
|
|
1411
1663
|
prompt,
|
|
1412
1664
|
n: 10,
|
|
1413
1665
|
maxImagesPerCall: 5,
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The **[Together.ai provider](https://ai-sdk.dev/providers/ai-sdk-providers/togetherai)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Together.ai](https://together.ai) platform.
|
|
4
4
|
|
|
5
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access Together.ai (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).
|
|
6
|
+
|
|
5
7
|
## Setup
|
|
6
8
|
|
|
7
9
|
The Together.ai provider is available in the `@ai-sdk/togetherai` module. You can install it with
|
package/dist/index.js
CHANGED
|
@@ -1,77 +1,63 @@
|
|
|
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
|
-
createTogetherAI: () => createTogetherAI,
|
|
25
|
-
togetherai: () => togetherai
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/togetherai-provider.ts
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import {
|
|
3
|
+
OpenAICompatibleChatLanguageModel,
|
|
4
|
+
OpenAICompatibleCompletionLanguageModel,
|
|
5
|
+
OpenAICompatibleEmbeddingModel
|
|
6
|
+
} from "@ai-sdk/openai-compatible";
|
|
7
|
+
import {
|
|
8
|
+
loadApiKey,
|
|
9
|
+
withoutTrailingSlash,
|
|
10
|
+
withUserAgentSuffix
|
|
11
|
+
} from "@ai-sdk/provider-utils";
|
|
32
12
|
|
|
33
13
|
// src/reranking/togetherai-reranking-model.ts
|
|
34
|
-
|
|
14
|
+
import {
|
|
15
|
+
combineHeaders,
|
|
16
|
+
createJsonErrorResponseHandler,
|
|
17
|
+
createJsonResponseHandler,
|
|
18
|
+
parseProviderOptions,
|
|
19
|
+
postJsonToApi
|
|
20
|
+
} from "@ai-sdk/provider-utils";
|
|
35
21
|
|
|
36
22
|
// src/reranking/togetherai-reranking-api.ts
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var togetheraiErrorSchema =
|
|
40
|
-
() =>
|
|
41
|
-
|
|
42
|
-
error:
|
|
43
|
-
message:
|
|
23
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
24
|
+
import { z } from "zod/v4";
|
|
25
|
+
var togetheraiErrorSchema = lazySchema(
|
|
26
|
+
() => zodSchema(
|
|
27
|
+
z.object({
|
|
28
|
+
error: z.object({
|
|
29
|
+
message: z.string()
|
|
44
30
|
})
|
|
45
31
|
})
|
|
46
32
|
)
|
|
47
33
|
);
|
|
48
|
-
var togetheraiRerankingResponseSchema =
|
|
49
|
-
() =>
|
|
50
|
-
|
|
51
|
-
id:
|
|
52
|
-
model:
|
|
53
|
-
results:
|
|
54
|
-
|
|
55
|
-
index:
|
|
56
|
-
relevance_score:
|
|
34
|
+
var togetheraiRerankingResponseSchema = lazySchema(
|
|
35
|
+
() => zodSchema(
|
|
36
|
+
z.object({
|
|
37
|
+
id: z.string().nullish(),
|
|
38
|
+
model: z.string().nullish(),
|
|
39
|
+
results: z.array(
|
|
40
|
+
z.object({
|
|
41
|
+
index: z.number(),
|
|
42
|
+
relevance_score: z.number()
|
|
57
43
|
})
|
|
58
44
|
),
|
|
59
|
-
usage:
|
|
60
|
-
prompt_tokens:
|
|
61
|
-
completion_tokens:
|
|
62
|
-
total_tokens:
|
|
45
|
+
usage: z.object({
|
|
46
|
+
prompt_tokens: z.number(),
|
|
47
|
+
completion_tokens: z.number(),
|
|
48
|
+
total_tokens: z.number()
|
|
63
49
|
})
|
|
64
50
|
})
|
|
65
51
|
)
|
|
66
52
|
);
|
|
67
53
|
|
|
68
54
|
// src/reranking/togetherai-reranking-options.ts
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var togetheraiRerankingModelOptionsSchema = (
|
|
72
|
-
() => (
|
|
73
|
-
|
|
74
|
-
rankFields:
|
|
55
|
+
import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
|
|
56
|
+
import { z as z2 } from "zod/v4";
|
|
57
|
+
var togetheraiRerankingModelOptionsSchema = lazySchema2(
|
|
58
|
+
() => zodSchema2(
|
|
59
|
+
z2.object({
|
|
60
|
+
rankFields: z2.array(z2.string()).optional()
|
|
75
61
|
})
|
|
76
62
|
)
|
|
77
63
|
);
|
|
@@ -96,7 +82,7 @@ var TogetherAIRerankingModel = class {
|
|
|
96
82
|
providerOptions
|
|
97
83
|
}) {
|
|
98
84
|
var _a, _b;
|
|
99
|
-
const rerankingOptions = await
|
|
85
|
+
const rerankingOptions = await parseProviderOptions({
|
|
100
86
|
provider: "togetherai",
|
|
101
87
|
providerOptions,
|
|
102
88
|
schema: togetheraiRerankingModelOptionsSchema
|
|
@@ -105,9 +91,9 @@ var TogetherAIRerankingModel = class {
|
|
|
105
91
|
responseHeaders,
|
|
106
92
|
value: response,
|
|
107
93
|
rawValue
|
|
108
|
-
} = await
|
|
94
|
+
} = await postJsonToApi({
|
|
109
95
|
url: `${this.config.baseURL}/rerank`,
|
|
110
|
-
headers:
|
|
96
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
111
97
|
body: {
|
|
112
98
|
model: this.modelId,
|
|
113
99
|
documents: documents.values,
|
|
@@ -117,11 +103,11 @@ var TogetherAIRerankingModel = class {
|
|
|
117
103
|
return_documents: false
|
|
118
104
|
// reduce response size
|
|
119
105
|
},
|
|
120
|
-
failedResponseHandler:
|
|
106
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
121
107
|
errorSchema: togetheraiErrorSchema,
|
|
122
108
|
errorToMessage: (data) => data.error.message
|
|
123
109
|
}),
|
|
124
|
-
successfulResponseHandler:
|
|
110
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
125
111
|
togetheraiRerankingResponseSchema
|
|
126
112
|
),
|
|
127
113
|
abortSignal,
|
|
@@ -143,9 +129,21 @@ var TogetherAIRerankingModel = class {
|
|
|
143
129
|
};
|
|
144
130
|
|
|
145
131
|
// src/togetherai-image-model.ts
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
132
|
+
import {
|
|
133
|
+
combineHeaders as combineHeaders2,
|
|
134
|
+
convertImageModelFileToDataUri,
|
|
135
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
136
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
|
|
137
|
+
lazySchema as lazySchema3,
|
|
138
|
+
parseProviderOptions as parseProviderOptions2,
|
|
139
|
+
postJsonToApi as postJsonToApi2,
|
|
140
|
+
serializeModelOptions,
|
|
141
|
+
WORKFLOW_SERIALIZE,
|
|
142
|
+
WORKFLOW_DESERIALIZE,
|
|
143
|
+
zodSchema as zodSchema3
|
|
144
|
+
} from "@ai-sdk/provider-utils";
|
|
145
|
+
import { z as z3 } from "zod/v4";
|
|
146
|
+
var TogetherAIImageModel = class _TogetherAIImageModel {
|
|
149
147
|
constructor(modelId, config) {
|
|
150
148
|
this.modelId = modelId;
|
|
151
149
|
this.config = config;
|
|
@@ -155,6 +153,15 @@ var TogetherAIImageModel = class {
|
|
|
155
153
|
get provider() {
|
|
156
154
|
return this.config.provider;
|
|
157
155
|
}
|
|
156
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
157
|
+
return serializeModelOptions({
|
|
158
|
+
modelId: model.modelId,
|
|
159
|
+
config: model.config
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
163
|
+
return new _TogetherAIImageModel(options.modelId, options.config);
|
|
164
|
+
}
|
|
158
165
|
async doGenerate({
|
|
159
166
|
prompt,
|
|
160
167
|
n,
|
|
@@ -166,7 +173,7 @@ var TogetherAIImageModel = class {
|
|
|
166
173
|
files,
|
|
167
174
|
mask
|
|
168
175
|
}) {
|
|
169
|
-
var _a, _b, _c;
|
|
176
|
+
var _a, _b, _c, _d, _e;
|
|
170
177
|
const warnings = [];
|
|
171
178
|
if (mask != null) {
|
|
172
179
|
throw new Error(
|
|
@@ -181,14 +188,14 @@ var TogetherAIImageModel = class {
|
|
|
181
188
|
});
|
|
182
189
|
}
|
|
183
190
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
184
|
-
const togetheraiOptions = await (
|
|
191
|
+
const togetheraiOptions = await parseProviderOptions2({
|
|
185
192
|
provider: "togetherai",
|
|
186
193
|
providerOptions,
|
|
187
194
|
schema: togetheraiImageModelOptionsSchema
|
|
188
195
|
});
|
|
189
196
|
let imageUrl;
|
|
190
197
|
if (files != null && files.length > 0) {
|
|
191
|
-
imageUrl =
|
|
198
|
+
imageUrl = convertImageModelFileToDataUri(files[0]);
|
|
192
199
|
if (files.length > 1) {
|
|
193
200
|
warnings.push({
|
|
194
201
|
type: "other",
|
|
@@ -197,9 +204,9 @@ var TogetherAIImageModel = class {
|
|
|
197
204
|
}
|
|
198
205
|
}
|
|
199
206
|
const splitSize = size == null ? void 0 : size.split("x");
|
|
200
|
-
const { value: response, responseHeaders } = await (
|
|
207
|
+
const { value: response, responseHeaders } = await postJsonToApi2({
|
|
201
208
|
url: `${this.config.baseURL}/images/generations`,
|
|
202
|
-
headers: (
|
|
209
|
+
headers: combineHeaders2((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), headers),
|
|
203
210
|
body: {
|
|
204
211
|
model: this.modelId,
|
|
205
212
|
prompt,
|
|
@@ -213,11 +220,11 @@ var TogetherAIImageModel = class {
|
|
|
213
220
|
response_format: "base64",
|
|
214
221
|
...togetheraiOptions != null ? togetheraiOptions : {}
|
|
215
222
|
},
|
|
216
|
-
failedResponseHandler: (
|
|
223
|
+
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
217
224
|
errorSchema: togetheraiErrorSchema2,
|
|
218
225
|
errorToMessage: (data) => data.error.message
|
|
219
226
|
}),
|
|
220
|
-
successfulResponseHandler: (
|
|
227
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
221
228
|
togetheraiImageResponseSchema
|
|
222
229
|
),
|
|
223
230
|
abortSignal,
|
|
@@ -234,45 +241,45 @@ var TogetherAIImageModel = class {
|
|
|
234
241
|
};
|
|
235
242
|
}
|
|
236
243
|
};
|
|
237
|
-
var togetheraiImageResponseSchema =
|
|
238
|
-
data:
|
|
239
|
-
|
|
240
|
-
b64_json:
|
|
244
|
+
var togetheraiImageResponseSchema = z3.object({
|
|
245
|
+
data: z3.array(
|
|
246
|
+
z3.object({
|
|
247
|
+
b64_json: z3.string()
|
|
241
248
|
})
|
|
242
249
|
)
|
|
243
250
|
});
|
|
244
|
-
var togetheraiErrorSchema2 =
|
|
245
|
-
error:
|
|
246
|
-
message:
|
|
251
|
+
var togetheraiErrorSchema2 = z3.object({
|
|
252
|
+
error: z3.object({
|
|
253
|
+
message: z3.string()
|
|
247
254
|
})
|
|
248
255
|
});
|
|
249
|
-
var togetheraiImageModelOptionsSchema = (
|
|
250
|
-
() => (
|
|
251
|
-
|
|
256
|
+
var togetheraiImageModelOptionsSchema = lazySchema3(
|
|
257
|
+
() => zodSchema3(
|
|
258
|
+
z3.object({
|
|
252
259
|
/**
|
|
253
260
|
* Number of generation steps. Higher values can improve quality.
|
|
254
261
|
*/
|
|
255
|
-
steps:
|
|
262
|
+
steps: z3.number().nullish(),
|
|
256
263
|
/**
|
|
257
264
|
* Guidance scale for image generation.
|
|
258
265
|
*/
|
|
259
|
-
guidance:
|
|
266
|
+
guidance: z3.number().nullish(),
|
|
260
267
|
/**
|
|
261
268
|
* Negative prompt to guide what to avoid.
|
|
262
269
|
*/
|
|
263
|
-
negative_prompt:
|
|
270
|
+
negative_prompt: z3.string().nullish(),
|
|
264
271
|
/**
|
|
265
272
|
* Disable the safety checker for image generation.
|
|
266
273
|
* When true, the API will not reject images flagged as potentially NSFW.
|
|
267
274
|
* Not available for Flux Schnell Free and Flux Pro models.
|
|
268
275
|
*/
|
|
269
|
-
disable_safety_checker:
|
|
276
|
+
disable_safety_checker: z3.boolean().nullish()
|
|
270
277
|
}).passthrough()
|
|
271
278
|
)
|
|
272
279
|
);
|
|
273
280
|
|
|
274
281
|
// src/version.ts
|
|
275
|
-
var VERSION = true ? "3.0.0-beta.
|
|
282
|
+
var VERSION = true ? "3.0.0-beta.31" : "0.0.0-test";
|
|
276
283
|
|
|
277
284
|
// src/togetherai-provider.ts
|
|
278
285
|
function loadDeprecatedApiKey() {
|
|
@@ -292,14 +299,14 @@ function loadDeprecatedApiKey() {
|
|
|
292
299
|
}
|
|
293
300
|
function createTogetherAI(options = {}) {
|
|
294
301
|
var _a;
|
|
295
|
-
const baseURL =
|
|
302
|
+
const baseURL = withoutTrailingSlash(
|
|
296
303
|
(_a = options.baseURL) != null ? _a : "https://api.together.xyz/v1/"
|
|
297
304
|
);
|
|
298
305
|
const getHeaders = () => {
|
|
299
306
|
var _a2;
|
|
300
|
-
return
|
|
307
|
+
return withUserAgentSuffix(
|
|
301
308
|
{
|
|
302
|
-
Authorization: `Bearer ${
|
|
309
|
+
Authorization: `Bearer ${loadApiKey({
|
|
303
310
|
apiKey: (_a2 = options.apiKey) != null ? _a2 : loadDeprecatedApiKey(),
|
|
304
311
|
environmentVariableName: "TOGETHER_API_KEY",
|
|
305
312
|
description: "TogetherAI"
|
|
@@ -316,16 +323,16 @@ function createTogetherAI(options = {}) {
|
|
|
316
323
|
fetch: options.fetch
|
|
317
324
|
});
|
|
318
325
|
const createChatModel = (modelId) => {
|
|
319
|
-
return new
|
|
326
|
+
return new OpenAICompatibleChatLanguageModel(
|
|
320
327
|
modelId,
|
|
321
328
|
getCommonModelConfig("chat")
|
|
322
329
|
);
|
|
323
330
|
};
|
|
324
|
-
const createCompletionModel = (modelId) => new
|
|
331
|
+
const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(
|
|
325
332
|
modelId,
|
|
326
333
|
getCommonModelConfig("completion")
|
|
327
334
|
);
|
|
328
|
-
const createEmbeddingModel = (modelId) => new
|
|
335
|
+
const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(
|
|
329
336
|
modelId,
|
|
330
337
|
getCommonModelConfig("embedding")
|
|
331
338
|
);
|
|
@@ -351,10 +358,9 @@ function createTogetherAI(options = {}) {
|
|
|
351
358
|
return provider;
|
|
352
359
|
}
|
|
353
360
|
var togetherai = createTogetherAI();
|
|
354
|
-
|
|
355
|
-
0 && (module.exports = {
|
|
361
|
+
export {
|
|
356
362
|
VERSION,
|
|
357
363
|
createTogetherAI,
|
|
358
364
|
togetherai
|
|
359
|
-
}
|
|
365
|
+
};
|
|
360
366
|
//# sourceMappingURL=index.js.map
|