@ai-sdk/togetherai 3.0.0-beta.9 → 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 +270 -0
- package/README.md +2 -0
- package/dist/index.js +130 -114
- package/dist/index.js.map +1 -1
- package/package.json +12 -10
- package/src/index.ts +2 -2
- package/src/reranking/togetherai-reranking-api.ts +1 -1
- package/src/reranking/{togetherai-reranking-options.ts → togetherai-reranking-model-options.ts} +5 -1
- package/src/reranking/togetherai-reranking-model.ts +5 -6
- package/src/togetherai-image-model-options.ts +43 -0
- package/src/togetherai-image-model.ts +23 -45
- package/src/togetherai-provider.ts +7 -7
- 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,275 @@
|
|
|
1
1
|
# @ai-sdk/togetherai
|
|
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
|
+
|
|
3
273
|
## 3.0.0-beta.9
|
|
4
274
|
|
|
5
275
|
### Patch Changes
|
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,66 @@
|
|
|
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
|
-
// src/reranking/togetherai-reranking-options.ts
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
54
|
+
// src/reranking/togetherai-reranking-model-options.ts
|
|
55
|
+
import {
|
|
56
|
+
lazySchema as lazySchema2,
|
|
57
|
+
zodSchema as zodSchema2
|
|
58
|
+
} from "@ai-sdk/provider-utils";
|
|
59
|
+
import { z as z2 } from "zod/v4";
|
|
60
|
+
var togetheraiRerankingModelOptionsSchema = lazySchema2(
|
|
61
|
+
() => zodSchema2(
|
|
62
|
+
z2.object({
|
|
63
|
+
rankFields: z2.array(z2.string()).optional()
|
|
75
64
|
})
|
|
76
65
|
)
|
|
77
66
|
);
|
|
@@ -96,7 +85,7 @@ var TogetherAIRerankingModel = class {
|
|
|
96
85
|
providerOptions
|
|
97
86
|
}) {
|
|
98
87
|
var _a, _b;
|
|
99
|
-
const rerankingOptions = await
|
|
88
|
+
const rerankingOptions = await parseProviderOptions({
|
|
100
89
|
provider: "togetherai",
|
|
101
90
|
providerOptions,
|
|
102
91
|
schema: togetheraiRerankingModelOptionsSchema
|
|
@@ -105,9 +94,9 @@ var TogetherAIRerankingModel = class {
|
|
|
105
94
|
responseHeaders,
|
|
106
95
|
value: response,
|
|
107
96
|
rawValue
|
|
108
|
-
} = await
|
|
97
|
+
} = await postJsonToApi({
|
|
109
98
|
url: `${this.config.baseURL}/rerank`,
|
|
110
|
-
headers:
|
|
99
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
111
100
|
body: {
|
|
112
101
|
model: this.modelId,
|
|
113
102
|
documents: documents.values,
|
|
@@ -117,11 +106,11 @@ var TogetherAIRerankingModel = class {
|
|
|
117
106
|
return_documents: false
|
|
118
107
|
// reduce response size
|
|
119
108
|
},
|
|
120
|
-
failedResponseHandler:
|
|
109
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
121
110
|
errorSchema: togetheraiErrorSchema,
|
|
122
111
|
errorToMessage: (data) => data.error.message
|
|
123
112
|
}),
|
|
124
|
-
successfulResponseHandler:
|
|
113
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
125
114
|
togetheraiRerankingResponseSchema
|
|
126
115
|
),
|
|
127
116
|
abortSignal,
|
|
@@ -143,9 +132,52 @@ var TogetherAIRerankingModel = class {
|
|
|
143
132
|
};
|
|
144
133
|
|
|
145
134
|
// src/togetherai-image-model.ts
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
135
|
+
import {
|
|
136
|
+
combineHeaders as combineHeaders2,
|
|
137
|
+
convertImageModelFileToDataUri,
|
|
138
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
139
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
|
|
140
|
+
parseProviderOptions as parseProviderOptions2,
|
|
141
|
+
postJsonToApi as postJsonToApi2,
|
|
142
|
+
serializeModelOptions,
|
|
143
|
+
WORKFLOW_SERIALIZE,
|
|
144
|
+
WORKFLOW_DESERIALIZE
|
|
145
|
+
} from "@ai-sdk/provider-utils";
|
|
146
|
+
|
|
147
|
+
// src/togetherai-image-model-options.ts
|
|
148
|
+
import {
|
|
149
|
+
lazySchema as lazySchema3,
|
|
150
|
+
zodSchema as zodSchema3
|
|
151
|
+
} from "@ai-sdk/provider-utils";
|
|
152
|
+
import { z as z3 } from "zod/v4";
|
|
153
|
+
var togetheraiImageModelOptionsSchema = lazySchema3(
|
|
154
|
+
() => zodSchema3(
|
|
155
|
+
z3.object({
|
|
156
|
+
/**
|
|
157
|
+
* Number of generation steps. Higher values can improve quality.
|
|
158
|
+
*/
|
|
159
|
+
steps: z3.number().nullish(),
|
|
160
|
+
/**
|
|
161
|
+
* Guidance scale for image generation.
|
|
162
|
+
*/
|
|
163
|
+
guidance: z3.number().nullish(),
|
|
164
|
+
/**
|
|
165
|
+
* Negative prompt to guide what to avoid.
|
|
166
|
+
*/
|
|
167
|
+
negative_prompt: z3.string().nullish(),
|
|
168
|
+
/**
|
|
169
|
+
* Disable the safety checker for image generation.
|
|
170
|
+
* When true, the API will not reject images flagged as potentially NSFW.
|
|
171
|
+
* Not available for Flux Schnell Free and Flux Pro models.
|
|
172
|
+
*/
|
|
173
|
+
disable_safety_checker: z3.boolean().nullish()
|
|
174
|
+
}).passthrough()
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// src/togetherai-image-model.ts
|
|
179
|
+
import { z as z4 } from "zod/v4";
|
|
180
|
+
var TogetherAIImageModel = class _TogetherAIImageModel {
|
|
149
181
|
constructor(modelId, config) {
|
|
150
182
|
this.modelId = modelId;
|
|
151
183
|
this.config = config;
|
|
@@ -155,6 +187,15 @@ var TogetherAIImageModel = class {
|
|
|
155
187
|
get provider() {
|
|
156
188
|
return this.config.provider;
|
|
157
189
|
}
|
|
190
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
191
|
+
return serializeModelOptions({
|
|
192
|
+
modelId: model.modelId,
|
|
193
|
+
config: model.config
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
197
|
+
return new _TogetherAIImageModel(options.modelId, options.config);
|
|
198
|
+
}
|
|
158
199
|
async doGenerate({
|
|
159
200
|
prompt,
|
|
160
201
|
n,
|
|
@@ -166,7 +207,7 @@ var TogetherAIImageModel = class {
|
|
|
166
207
|
files,
|
|
167
208
|
mask
|
|
168
209
|
}) {
|
|
169
|
-
var _a, _b, _c;
|
|
210
|
+
var _a, _b, _c, _d, _e;
|
|
170
211
|
const warnings = [];
|
|
171
212
|
if (mask != null) {
|
|
172
213
|
throw new Error(
|
|
@@ -181,14 +222,14 @@ var TogetherAIImageModel = class {
|
|
|
181
222
|
});
|
|
182
223
|
}
|
|
183
224
|
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 (
|
|
225
|
+
const togetheraiOptions = await parseProviderOptions2({
|
|
185
226
|
provider: "togetherai",
|
|
186
227
|
providerOptions,
|
|
187
228
|
schema: togetheraiImageModelOptionsSchema
|
|
188
229
|
});
|
|
189
230
|
let imageUrl;
|
|
190
231
|
if (files != null && files.length > 0) {
|
|
191
|
-
imageUrl =
|
|
232
|
+
imageUrl = convertImageModelFileToDataUri(files[0]);
|
|
192
233
|
if (files.length > 1) {
|
|
193
234
|
warnings.push({
|
|
194
235
|
type: "other",
|
|
@@ -197,9 +238,9 @@ var TogetherAIImageModel = class {
|
|
|
197
238
|
}
|
|
198
239
|
}
|
|
199
240
|
const splitSize = size == null ? void 0 : size.split("x");
|
|
200
|
-
const { value: response, responseHeaders } = await (
|
|
241
|
+
const { value: response, responseHeaders } = await postJsonToApi2({
|
|
201
242
|
url: `${this.config.baseURL}/images/generations`,
|
|
202
|
-
headers: (
|
|
243
|
+
headers: combineHeaders2((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), headers),
|
|
203
244
|
body: {
|
|
204
245
|
model: this.modelId,
|
|
205
246
|
prompt,
|
|
@@ -213,11 +254,11 @@ var TogetherAIImageModel = class {
|
|
|
213
254
|
response_format: "base64",
|
|
214
255
|
...togetheraiOptions != null ? togetheraiOptions : {}
|
|
215
256
|
},
|
|
216
|
-
failedResponseHandler: (
|
|
257
|
+
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
217
258
|
errorSchema: togetheraiErrorSchema2,
|
|
218
259
|
errorToMessage: (data) => data.error.message
|
|
219
260
|
}),
|
|
220
|
-
successfulResponseHandler: (
|
|
261
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
221
262
|
togetheraiImageResponseSchema
|
|
222
263
|
),
|
|
223
264
|
abortSignal,
|
|
@@ -234,45 +275,21 @@ var TogetherAIImageModel = class {
|
|
|
234
275
|
};
|
|
235
276
|
}
|
|
236
277
|
};
|
|
237
|
-
var togetheraiImageResponseSchema =
|
|
238
|
-
data:
|
|
239
|
-
|
|
240
|
-
b64_json:
|
|
278
|
+
var togetheraiImageResponseSchema = z4.object({
|
|
279
|
+
data: z4.array(
|
|
280
|
+
z4.object({
|
|
281
|
+
b64_json: z4.string()
|
|
241
282
|
})
|
|
242
283
|
)
|
|
243
284
|
});
|
|
244
|
-
var togetheraiErrorSchema2 =
|
|
245
|
-
error:
|
|
246
|
-
message:
|
|
285
|
+
var togetheraiErrorSchema2 = z4.object({
|
|
286
|
+
error: z4.object({
|
|
287
|
+
message: z4.string()
|
|
247
288
|
})
|
|
248
289
|
});
|
|
249
|
-
var togetheraiImageModelOptionsSchema = (0, import_provider_utils4.lazySchema)(
|
|
250
|
-
() => (0, import_provider_utils4.zodSchema)(
|
|
251
|
-
import_v43.z.object({
|
|
252
|
-
/**
|
|
253
|
-
* Number of generation steps. Higher values can improve quality.
|
|
254
|
-
*/
|
|
255
|
-
steps: import_v43.z.number().nullish(),
|
|
256
|
-
/**
|
|
257
|
-
* Guidance scale for image generation.
|
|
258
|
-
*/
|
|
259
|
-
guidance: import_v43.z.number().nullish(),
|
|
260
|
-
/**
|
|
261
|
-
* Negative prompt to guide what to avoid.
|
|
262
|
-
*/
|
|
263
|
-
negative_prompt: import_v43.z.string().nullish(),
|
|
264
|
-
/**
|
|
265
|
-
* Disable the safety checker for image generation.
|
|
266
|
-
* When true, the API will not reject images flagged as potentially NSFW.
|
|
267
|
-
* Not available for Flux Schnell Free and Flux Pro models.
|
|
268
|
-
*/
|
|
269
|
-
disable_safety_checker: import_v43.z.boolean().nullish()
|
|
270
|
-
}).passthrough()
|
|
271
|
-
)
|
|
272
|
-
);
|
|
273
290
|
|
|
274
291
|
// src/version.ts
|
|
275
|
-
var VERSION = true ? "3.0.0-
|
|
292
|
+
var VERSION = true ? "3.0.0-canary.37" : "0.0.0-test";
|
|
276
293
|
|
|
277
294
|
// src/togetherai-provider.ts
|
|
278
295
|
function loadDeprecatedApiKey() {
|
|
@@ -292,14 +309,14 @@ function loadDeprecatedApiKey() {
|
|
|
292
309
|
}
|
|
293
310
|
function createTogetherAI(options = {}) {
|
|
294
311
|
var _a;
|
|
295
|
-
const baseURL =
|
|
312
|
+
const baseURL = withoutTrailingSlash(
|
|
296
313
|
(_a = options.baseURL) != null ? _a : "https://api.together.xyz/v1/"
|
|
297
314
|
);
|
|
298
315
|
const getHeaders = () => {
|
|
299
316
|
var _a2;
|
|
300
|
-
return
|
|
317
|
+
return withUserAgentSuffix(
|
|
301
318
|
{
|
|
302
|
-
Authorization: `Bearer ${
|
|
319
|
+
Authorization: `Bearer ${loadApiKey({
|
|
303
320
|
apiKey: (_a2 = options.apiKey) != null ? _a2 : loadDeprecatedApiKey(),
|
|
304
321
|
environmentVariableName: "TOGETHER_API_KEY",
|
|
305
322
|
description: "TogetherAI"
|
|
@@ -316,16 +333,16 @@ function createTogetherAI(options = {}) {
|
|
|
316
333
|
fetch: options.fetch
|
|
317
334
|
});
|
|
318
335
|
const createChatModel = (modelId) => {
|
|
319
|
-
return new
|
|
336
|
+
return new OpenAICompatibleChatLanguageModel(
|
|
320
337
|
modelId,
|
|
321
338
|
getCommonModelConfig("chat")
|
|
322
339
|
);
|
|
323
340
|
};
|
|
324
|
-
const createCompletionModel = (modelId) => new
|
|
341
|
+
const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(
|
|
325
342
|
modelId,
|
|
326
343
|
getCommonModelConfig("completion")
|
|
327
344
|
);
|
|
328
|
-
const createEmbeddingModel = (modelId) => new
|
|
345
|
+
const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(
|
|
329
346
|
modelId,
|
|
330
347
|
getCommonModelConfig("embedding")
|
|
331
348
|
);
|
|
@@ -351,10 +368,9 @@ function createTogetherAI(options = {}) {
|
|
|
351
368
|
return provider;
|
|
352
369
|
}
|
|
353
370
|
var togetherai = createTogetherAI();
|
|
354
|
-
|
|
355
|
-
0 && (module.exports = {
|
|
371
|
+
export {
|
|
356
372
|
VERSION,
|
|
357
373
|
createTogetherAI,
|
|
358
374
|
togetherai
|
|
359
|
-
}
|
|
375
|
+
};
|
|
360
376
|
//# sourceMappingURL=index.js.map
|