@ai-sdk/cerebras 0.2.14 → 1.0.0-alpha.2
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 +205 -35
- package/dist/index.d.mts +5 -8
- package/dist/index.d.ts +5 -8
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,75 +1,245 @@
|
|
|
1
1
|
# @ai-sdk/cerebras
|
|
2
2
|
|
|
3
|
-
## 0.2
|
|
3
|
+
## 1.0.0-alpha.2
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- Updated dependencies [
|
|
8
|
-
- @ai-sdk/provider
|
|
9
|
-
- @ai-sdk/openai-compatible@0.2
|
|
7
|
+
- Updated dependencies [26535e0]
|
|
8
|
+
- @ai-sdk/provider@2.0.0-alpha.2
|
|
9
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.2
|
|
10
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.2
|
|
10
11
|
|
|
11
|
-
## 0.
|
|
12
|
+
## 1.0.0-alpha.1
|
|
12
13
|
|
|
13
14
|
### Patch Changes
|
|
14
15
|
|
|
15
|
-
- Updated dependencies [
|
|
16
|
-
- @ai-sdk/
|
|
16
|
+
- Updated dependencies [3f2f00c]
|
|
17
|
+
- @ai-sdk/provider@2.0.0-alpha.1
|
|
18
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.1
|
|
19
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.1
|
|
17
20
|
|
|
18
|
-
## 0.
|
|
21
|
+
## 1.0.0-canary.19
|
|
19
22
|
|
|
20
23
|
### Patch Changes
|
|
21
24
|
|
|
22
|
-
- Updated dependencies [
|
|
23
|
-
- @ai-sdk/
|
|
25
|
+
- Updated dependencies [faf8446]
|
|
26
|
+
- @ai-sdk/provider-utils@3.0.0-canary.19
|
|
27
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.19
|
|
24
28
|
|
|
25
|
-
## 0.
|
|
29
|
+
## 1.0.0-canary.18
|
|
26
30
|
|
|
27
31
|
### Patch Changes
|
|
28
32
|
|
|
29
|
-
- Updated dependencies [
|
|
30
|
-
- @ai-sdk/
|
|
33
|
+
- Updated dependencies [40acf9b]
|
|
34
|
+
- @ai-sdk/provider-utils@3.0.0-canary.18
|
|
35
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.18
|
|
31
36
|
|
|
32
|
-
## 0.
|
|
37
|
+
## 1.0.0-canary.17
|
|
33
38
|
|
|
34
39
|
### Patch Changes
|
|
35
40
|
|
|
36
|
-
- Updated dependencies [
|
|
37
|
-
|
|
38
|
-
- @ai-sdk/openai-compatible@0.
|
|
39
|
-
- @ai-sdk/provider-utils@
|
|
41
|
+
- Updated dependencies [516be5b]
|
|
42
|
+
- Updated dependencies [ea7a7c9]
|
|
43
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.17
|
|
44
|
+
- @ai-sdk/provider-utils@3.0.0-canary.17
|
|
40
45
|
|
|
41
|
-
## 0.
|
|
46
|
+
## 1.0.0-canary.16
|
|
42
47
|
|
|
43
48
|
### Patch Changes
|
|
44
49
|
|
|
45
|
-
- Updated dependencies [
|
|
46
|
-
- @ai-sdk/
|
|
50
|
+
- Updated dependencies [87b828f]
|
|
51
|
+
- @ai-sdk/provider-utils@3.0.0-canary.16
|
|
52
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.16
|
|
47
53
|
|
|
48
|
-
## 0.
|
|
54
|
+
## 1.0.0-canary.15
|
|
49
55
|
|
|
50
56
|
### Patch Changes
|
|
51
57
|
|
|
52
|
-
- Updated dependencies [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
- Updated dependencies [a571d6e]
|
|
59
|
+
- Updated dependencies [a8c8bd5]
|
|
60
|
+
- Updated dependencies [7979f7f]
|
|
61
|
+
- Updated dependencies [41fa418]
|
|
62
|
+
- @ai-sdk/provider-utils@3.0.0-canary.15
|
|
63
|
+
- @ai-sdk/provider@2.0.0-canary.14
|
|
64
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.15
|
|
56
65
|
|
|
57
|
-
## 0.
|
|
66
|
+
## 1.0.0-canary.14
|
|
58
67
|
|
|
59
68
|
### Patch Changes
|
|
60
69
|
|
|
61
|
-
- Updated dependencies [
|
|
62
|
-
|
|
63
|
-
- @ai-sdk/provider@
|
|
64
|
-
- @ai-sdk/
|
|
70
|
+
- Updated dependencies [957b739]
|
|
71
|
+
- Updated dependencies [9bd5ab5]
|
|
72
|
+
- @ai-sdk/provider-utils@3.0.0-canary.14
|
|
73
|
+
- @ai-sdk/provider@2.0.0-canary.13
|
|
74
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.14
|
|
65
75
|
|
|
66
|
-
## 0.
|
|
76
|
+
## 1.0.0-canary.13
|
|
67
77
|
|
|
68
78
|
### Patch Changes
|
|
69
79
|
|
|
70
|
-
- Updated dependencies [
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
- Updated dependencies [7b3ae3f]
|
|
81
|
+
- Updated dependencies [d9209ca]
|
|
82
|
+
- Updated dependencies [0ff02bb]
|
|
83
|
+
- @ai-sdk/provider@2.0.0-canary.12
|
|
84
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.13
|
|
85
|
+
- @ai-sdk/provider-utils@3.0.0-canary.13
|
|
86
|
+
|
|
87
|
+
## 1.0.0-canary.12
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [9bf7291]
|
|
92
|
+
- Updated dependencies [4617fab]
|
|
93
|
+
- Updated dependencies [e030615]
|
|
94
|
+
- @ai-sdk/provider@2.0.0-canary.11
|
|
95
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.12
|
|
96
|
+
- @ai-sdk/provider-utils@3.0.0-canary.12
|
|
97
|
+
|
|
98
|
+
## 1.0.0-canary.11
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [db72adc]
|
|
103
|
+
- Updated dependencies [42e32b0]
|
|
104
|
+
- Updated dependencies [66962ed]
|
|
105
|
+
- Updated dependencies [9301f86]
|
|
106
|
+
- Updated dependencies [a3f768e]
|
|
107
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.11
|
|
108
|
+
- @ai-sdk/provider-utils@3.0.0-canary.11
|
|
109
|
+
- @ai-sdk/provider@2.0.0-canary.10
|
|
110
|
+
|
|
111
|
+
## 1.0.0-canary.10
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- Updated dependencies [cf8280e]
|
|
116
|
+
- Updated dependencies [e86be6f]
|
|
117
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.10
|
|
118
|
+
- @ai-sdk/provider@2.0.0-canary.9
|
|
119
|
+
- @ai-sdk/provider-utils@3.0.0-canary.10
|
|
120
|
+
|
|
121
|
+
## 1.0.0-canary.9
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- Updated dependencies [95857aa]
|
|
126
|
+
- Updated dependencies [7ea4132]
|
|
127
|
+
- @ai-sdk/provider@2.0.0-canary.8
|
|
128
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.9
|
|
129
|
+
- @ai-sdk/provider-utils@3.0.0-canary.9
|
|
130
|
+
|
|
131
|
+
## 1.0.0-canary.8
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- Updated dependencies [5d142ab]
|
|
136
|
+
- Updated dependencies [b6b43c7]
|
|
137
|
+
- Updated dependencies [b9a6121]
|
|
138
|
+
- Updated dependencies [8aa9e20]
|
|
139
|
+
- Updated dependencies [3795467]
|
|
140
|
+
- @ai-sdk/provider-utils@3.0.0-canary.8
|
|
141
|
+
- @ai-sdk/provider@2.0.0-canary.7
|
|
142
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.8
|
|
143
|
+
|
|
144
|
+
## 1.0.0-canary.7
|
|
145
|
+
|
|
146
|
+
### Patch Changes
|
|
147
|
+
|
|
148
|
+
- fa49207: feat(providers/openai-compatible): convert to providerOptions
|
|
149
|
+
- Updated dependencies [fa49207]
|
|
150
|
+
- Updated dependencies [26735b5]
|
|
151
|
+
- Updated dependencies [443d8ec]
|
|
152
|
+
- Updated dependencies [14c9410]
|
|
153
|
+
- Updated dependencies [d9c98f4]
|
|
154
|
+
- Updated dependencies [c4a2fec]
|
|
155
|
+
- Updated dependencies [0054544]
|
|
156
|
+
- Updated dependencies [9e9c809]
|
|
157
|
+
- Updated dependencies [32831c6]
|
|
158
|
+
- Updated dependencies [d0f9495]
|
|
159
|
+
- Updated dependencies [fd65bc6]
|
|
160
|
+
- Updated dependencies [393138b]
|
|
161
|
+
- Updated dependencies [7182d14]
|
|
162
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.7
|
|
163
|
+
- @ai-sdk/provider@2.0.0-canary.6
|
|
164
|
+
- @ai-sdk/provider-utils@3.0.0-canary.7
|
|
165
|
+
|
|
166
|
+
## 1.0.0-canary.6
|
|
167
|
+
|
|
168
|
+
### Patch Changes
|
|
169
|
+
|
|
170
|
+
- Updated dependencies [6db02c9]
|
|
171
|
+
- Updated dependencies [411e483]
|
|
172
|
+
- Updated dependencies [79457bd]
|
|
173
|
+
- Updated dependencies [ad80501]
|
|
174
|
+
- Updated dependencies [1766ede]
|
|
175
|
+
- Updated dependencies [f10304b]
|
|
176
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.6
|
|
177
|
+
- @ai-sdk/provider@2.0.0-canary.5
|
|
178
|
+
- @ai-sdk/provider-utils@3.0.0-canary.6
|
|
179
|
+
|
|
180
|
+
## 1.0.0-canary.5
|
|
181
|
+
|
|
182
|
+
### Patch Changes
|
|
183
|
+
|
|
184
|
+
- Updated dependencies [6f6bb89]
|
|
185
|
+
- @ai-sdk/provider@2.0.0-canary.4
|
|
186
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.5
|
|
187
|
+
- @ai-sdk/provider-utils@3.0.0-canary.5
|
|
188
|
+
|
|
189
|
+
## 1.0.0-canary.4
|
|
190
|
+
|
|
191
|
+
### Patch Changes
|
|
192
|
+
|
|
193
|
+
- Updated dependencies [d1a1aa1]
|
|
194
|
+
- @ai-sdk/provider@2.0.0-canary.3
|
|
195
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.4
|
|
196
|
+
- @ai-sdk/provider-utils@3.0.0-canary.4
|
|
197
|
+
|
|
198
|
+
## 1.0.0-canary.3
|
|
199
|
+
|
|
200
|
+
### Patch Changes
|
|
201
|
+
|
|
202
|
+
- Updated dependencies [a166433]
|
|
203
|
+
- Updated dependencies [abf9a79]
|
|
204
|
+
- Updated dependencies [9f95b35]
|
|
205
|
+
- Updated dependencies [0a87932]
|
|
206
|
+
- Updated dependencies [6dc848c]
|
|
207
|
+
- @ai-sdk/provider-utils@3.0.0-canary.3
|
|
208
|
+
- @ai-sdk/provider@2.0.0-canary.2
|
|
209
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.3
|
|
210
|
+
|
|
211
|
+
## 1.0.0-canary.2
|
|
212
|
+
|
|
213
|
+
### Patch Changes
|
|
214
|
+
|
|
215
|
+
- Updated dependencies [c57e248]
|
|
216
|
+
- Updated dependencies [33f4a6a]
|
|
217
|
+
- @ai-sdk/provider@2.0.0-canary.1
|
|
218
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.2
|
|
219
|
+
- @ai-sdk/provider-utils@3.0.0-canary.2
|
|
220
|
+
|
|
221
|
+
## 1.0.0-canary.1
|
|
222
|
+
|
|
223
|
+
### Patch Changes
|
|
224
|
+
|
|
225
|
+
- Updated dependencies [060370c]
|
|
226
|
+
- Updated dependencies [0c0c0b3]
|
|
227
|
+
- Updated dependencies [63d791d]
|
|
228
|
+
- @ai-sdk/provider-utils@3.0.0-canary.1
|
|
229
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.1
|
|
230
|
+
|
|
231
|
+
## 1.0.0-canary.0
|
|
232
|
+
|
|
233
|
+
### Major Changes
|
|
234
|
+
|
|
235
|
+
- d5f588f: AI SDK 5
|
|
236
|
+
|
|
237
|
+
### Patch Changes
|
|
238
|
+
|
|
239
|
+
- Updated dependencies [d5f588f]
|
|
240
|
+
- @ai-sdk/provider-utils@3.0.0-canary.0
|
|
241
|
+
- @ai-sdk/openai-compatible@1.0.0-canary.0
|
|
242
|
+
- @ai-sdk/provider@2.0.0-canary.0
|
|
73
243
|
|
|
74
244
|
## 0.2.5
|
|
75
245
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { OpenAICompatibleChatSettings } from '@ai-sdk/openai-compatible';
|
|
4
3
|
import { z } from 'zod';
|
|
5
4
|
|
|
6
5
|
type CerebrasChatModelId = 'llama3.1-8b' | 'llama3.1-70b' | 'llama-3.3-70b' | (string & {});
|
|
7
|
-
interface CerebrasChatSettings extends OpenAICompatibleChatSettings {
|
|
8
|
-
}
|
|
9
6
|
|
|
10
7
|
declare const cerebrasErrorSchema: z.ZodObject<{
|
|
11
8
|
message: z.ZodString;
|
|
@@ -43,19 +40,19 @@ interface CerebrasProviderSettings {
|
|
|
43
40
|
*/
|
|
44
41
|
fetch?: FetchFunction;
|
|
45
42
|
}
|
|
46
|
-
interface CerebrasProvider extends
|
|
43
|
+
interface CerebrasProvider extends ProviderV2 {
|
|
47
44
|
/**
|
|
48
45
|
Creates a Cerebras model for text generation.
|
|
49
46
|
*/
|
|
50
|
-
(modelId: CerebrasChatModelId
|
|
47
|
+
(modelId: CerebrasChatModelId): LanguageModelV2;
|
|
51
48
|
/**
|
|
52
49
|
Creates a Cerebras model for text generation.
|
|
53
50
|
*/
|
|
54
|
-
languageModel(modelId: CerebrasChatModelId
|
|
51
|
+
languageModel(modelId: CerebrasChatModelId): LanguageModelV2;
|
|
55
52
|
/**
|
|
56
53
|
Creates a Cerebras chat model for text generation.
|
|
57
54
|
*/
|
|
58
|
-
chat(modelId: CerebrasChatModelId
|
|
55
|
+
chat(modelId: CerebrasChatModelId): LanguageModelV2;
|
|
59
56
|
}
|
|
60
57
|
declare function createCerebras(options?: CerebrasProviderSettings): CerebrasProvider;
|
|
61
58
|
declare const cerebras: CerebrasProvider;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { OpenAICompatibleChatSettings } from '@ai-sdk/openai-compatible';
|
|
4
3
|
import { z } from 'zod';
|
|
5
4
|
|
|
6
5
|
type CerebrasChatModelId = 'llama3.1-8b' | 'llama3.1-70b' | 'llama-3.3-70b' | (string & {});
|
|
7
|
-
interface CerebrasChatSettings extends OpenAICompatibleChatSettings {
|
|
8
|
-
}
|
|
9
6
|
|
|
10
7
|
declare const cerebrasErrorSchema: z.ZodObject<{
|
|
11
8
|
message: z.ZodString;
|
|
@@ -43,19 +40,19 @@ interface CerebrasProviderSettings {
|
|
|
43
40
|
*/
|
|
44
41
|
fetch?: FetchFunction;
|
|
45
42
|
}
|
|
46
|
-
interface CerebrasProvider extends
|
|
43
|
+
interface CerebrasProvider extends ProviderV2 {
|
|
47
44
|
/**
|
|
48
45
|
Creates a Cerebras model for text generation.
|
|
49
46
|
*/
|
|
50
|
-
(modelId: CerebrasChatModelId
|
|
47
|
+
(modelId: CerebrasChatModelId): LanguageModelV2;
|
|
51
48
|
/**
|
|
52
49
|
Creates a Cerebras model for text generation.
|
|
53
50
|
*/
|
|
54
|
-
languageModel(modelId: CerebrasChatModelId
|
|
51
|
+
languageModel(modelId: CerebrasChatModelId): LanguageModelV2;
|
|
55
52
|
/**
|
|
56
53
|
Creates a Cerebras chat model for text generation.
|
|
57
54
|
*/
|
|
58
|
-
chat(modelId: CerebrasChatModelId
|
|
55
|
+
chat(modelId: CerebrasChatModelId): LanguageModelV2;
|
|
59
56
|
}
|
|
60
57
|
declare function createCerebras(options?: CerebrasProviderSettings): CerebrasProvider;
|
|
61
58
|
declare const cerebras: CerebrasProvider;
|
package/dist/index.js
CHANGED
|
@@ -53,22 +53,24 @@ function createCerebras(options = {}) {
|
|
|
53
53
|
})}`,
|
|
54
54
|
...options.headers
|
|
55
55
|
});
|
|
56
|
-
const createLanguageModel = (modelId
|
|
57
|
-
return new import_openai_compatible.OpenAICompatibleChatLanguageModel(modelId,
|
|
56
|
+
const createLanguageModel = (modelId) => {
|
|
57
|
+
return new import_openai_compatible.OpenAICompatibleChatLanguageModel(modelId, {
|
|
58
58
|
provider: `cerebras.chat`,
|
|
59
59
|
url: ({ path }) => `${baseURL}${path}`,
|
|
60
60
|
headers: getHeaders,
|
|
61
61
|
fetch: options.fetch,
|
|
62
|
-
defaultObjectGenerationMode: "tool",
|
|
63
62
|
errorStructure: cerebrasErrorStructure
|
|
64
63
|
});
|
|
65
64
|
};
|
|
66
|
-
const provider = (modelId
|
|
65
|
+
const provider = (modelId) => createLanguageModel(modelId);
|
|
67
66
|
provider.languageModel = createLanguageModel;
|
|
68
67
|
provider.chat = createLanguageModel;
|
|
69
68
|
provider.textEmbeddingModel = (modelId) => {
|
|
70
69
|
throw new import_provider.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
71
70
|
};
|
|
71
|
+
provider.imageModel = (modelId) => {
|
|
72
|
+
throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
73
|
+
};
|
|
72
74
|
return provider;
|
|
73
75
|
}
|
|
74
76
|
var cerebras = createCerebras();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/cerebras-provider.ts"],"sourcesContent":["export { createCerebras, cerebras } from './cerebras-provider';\nexport type {\n CerebrasProvider,\n CerebrasProviderSettings,\n} from './cerebras-provider';\nexport type { CerebrasErrorData } from './cerebras-provider';\n","import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/cerebras-provider.ts"],"sourcesContent":["export { createCerebras, cerebras } from './cerebras-provider';\nexport type {\n CerebrasProvider,\n CerebrasProviderSettings,\n} from './cerebras-provider';\nexport type { CerebrasErrorData } from './cerebras-provider';\n","import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n LanguageModelV2,\n NoSuchModelError,\n ProviderV2,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { CerebrasChatModelId } from './cerebras-chat-options';\nimport { z } from 'zod';\nimport { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\n\n// Add error schema and structure\nconst cerebrasErrorSchema = z.object({\n message: z.string(),\n type: z.string(),\n param: z.string(),\n code: z.string(),\n});\n\nexport type CerebrasErrorData = z.infer<typeof cerebrasErrorSchema>;\n\nconst cerebrasErrorStructure: ProviderErrorStructure<CerebrasErrorData> = {\n errorSchema: cerebrasErrorSchema,\n errorToMessage: data => data.message,\n};\n\nexport interface CerebrasProviderSettings {\n /**\nCerebras API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV2 {\n /**\nCreates a Cerebras model for text generation.\n*/\n (modelId: CerebrasChatModelId): LanguageModelV2;\n\n /**\nCreates a Cerebras model for text generation.\n*/\n languageModel(modelId: CerebrasChatModelId): LanguageModelV2;\n\n /**\nCreates a Cerebras chat model for text generation.\n*/\n chat(modelId: CerebrasChatModelId): LanguageModelV2;\n}\n\nexport function createCerebras(\n options: CerebrasProviderSettings = {},\n): CerebrasProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.cerebras.ai/v1',\n );\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'CEREBRAS_API_KEY',\n description: 'Cerebras API key',\n })}`,\n ...options.headers,\n });\n\n const createLanguageModel = (modelId: CerebrasChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n provider: `cerebras.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n errorStructure: cerebrasErrorStructure,\n });\n };\n\n const provider = (modelId: CerebrasChatModelId) =>\n createLanguageModel(modelId);\n\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const cerebras = createCerebras();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,+BAAkD;AAClD,sBAIO;AACP,4BAIO;AAEP,iBAAkB;AAIlB,IAAM,sBAAsB,aAAE,OAAO;AAAA,EACnC,SAAS,aAAE,OAAO;AAAA,EAClB,MAAM,aAAE,OAAO;AAAA,EACf,OAAO,aAAE,OAAO;AAAA,EAChB,MAAM,aAAE,OAAO;AACjB,CAAC;AAID,IAAM,yBAAoE;AAAA,EACxE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK;AAC/B;AAuCO,SAAS,eACd,UAAoC,CAAC,GACnB;AArEpB;AAsEE,QAAM,cAAU;AAAA,KACd,aAAQ,YAAR,YAAmB;AAAA,EACrB;AACA,QAAM,aAAa,OAAO;AAAA,IACxB,eAAe,cAAU,kCAAW;AAAA,MAClC,QAAQ,QAAQ;AAAA,MAChB,yBAAyB;AAAA,MACzB,aAAa;AAAA,IACf,CAAC,CAAC;AAAA,IACF,GAAG,QAAQ;AAAA,EACb;AAEA,QAAM,sBAAsB,CAAC,YAAiC;AAC5D,WAAO,IAAI,2DAAkC,SAAS;AAAA,MACpD,UAAU;AAAA,MACV,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,MACpC,SAAS;AAAA,MACT,OAAO,QAAQ;AAAA,MACf,gBAAgB;AAAA,IAClB,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,YAChB,oBAAoB,OAAO;AAE7B,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAEhB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AACA,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -31,22 +31,24 @@ function createCerebras(options = {}) {
|
|
|
31
31
|
})}`,
|
|
32
32
|
...options.headers
|
|
33
33
|
});
|
|
34
|
-
const createLanguageModel = (modelId
|
|
35
|
-
return new OpenAICompatibleChatLanguageModel(modelId,
|
|
34
|
+
const createLanguageModel = (modelId) => {
|
|
35
|
+
return new OpenAICompatibleChatLanguageModel(modelId, {
|
|
36
36
|
provider: `cerebras.chat`,
|
|
37
37
|
url: ({ path }) => `${baseURL}${path}`,
|
|
38
38
|
headers: getHeaders,
|
|
39
39
|
fetch: options.fetch,
|
|
40
|
-
defaultObjectGenerationMode: "tool",
|
|
41
40
|
errorStructure: cerebrasErrorStructure
|
|
42
41
|
});
|
|
43
42
|
};
|
|
44
|
-
const provider = (modelId
|
|
43
|
+
const provider = (modelId) => createLanguageModel(modelId);
|
|
45
44
|
provider.languageModel = createLanguageModel;
|
|
46
45
|
provider.chat = createLanguageModel;
|
|
47
46
|
provider.textEmbeddingModel = (modelId) => {
|
|
48
47
|
throw new NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
|
|
49
48
|
};
|
|
49
|
+
provider.imageModel = (modelId) => {
|
|
50
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
51
|
+
};
|
|
50
52
|
return provider;
|
|
51
53
|
}
|
|
52
54
|
var cerebras = createCerebras();
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cerebras-provider.ts"],"sourcesContent":["import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../src/cerebras-provider.ts"],"sourcesContent":["import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n LanguageModelV2,\n NoSuchModelError,\n ProviderV2,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport { CerebrasChatModelId } from './cerebras-chat-options';\nimport { z } from 'zod';\nimport { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\n\n// Add error schema and structure\nconst cerebrasErrorSchema = z.object({\n message: z.string(),\n type: z.string(),\n param: z.string(),\n code: z.string(),\n});\n\nexport type CerebrasErrorData = z.infer<typeof cerebrasErrorSchema>;\n\nconst cerebrasErrorStructure: ProviderErrorStructure<CerebrasErrorData> = {\n errorSchema: cerebrasErrorSchema,\n errorToMessage: data => data.message,\n};\n\nexport interface CerebrasProviderSettings {\n /**\nCerebras API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV2 {\n /**\nCreates a Cerebras model for text generation.\n*/\n (modelId: CerebrasChatModelId): LanguageModelV2;\n\n /**\nCreates a Cerebras model for text generation.\n*/\n languageModel(modelId: CerebrasChatModelId): LanguageModelV2;\n\n /**\nCreates a Cerebras chat model for text generation.\n*/\n chat(modelId: CerebrasChatModelId): LanguageModelV2;\n}\n\nexport function createCerebras(\n options: CerebrasProviderSettings = {},\n): CerebrasProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.cerebras.ai/v1',\n );\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'CEREBRAS_API_KEY',\n description: 'Cerebras API key',\n })}`,\n ...options.headers,\n });\n\n const createLanguageModel = (modelId: CerebrasChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n provider: `cerebras.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n errorStructure: cerebrasErrorStructure,\n });\n };\n\n const provider = (modelId: CerebrasChatModelId) =>\n createLanguageModel(modelId);\n\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const cerebras = createCerebras();\n"],"mappings":";AAAA,SAAS,yCAAyC;AAClD;AAAA,EAEE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS;AAIlB,IAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,SAAS,EAAE,OAAO;AAAA,EAClB,MAAM,EAAE,OAAO;AAAA,EACf,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AACjB,CAAC;AAID,IAAM,yBAAoE;AAAA,EACxE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK;AAC/B;AAuCO,SAAS,eACd,UAAoC,CAAC,GACnB;AArEpB;AAsEE,QAAM,UAAU;AAAA,KACd,aAAQ,YAAR,YAAmB;AAAA,EACrB;AACA,QAAM,aAAa,OAAO;AAAA,IACxB,eAAe,UAAU,WAAW;AAAA,MAClC,QAAQ,QAAQ;AAAA,MAChB,yBAAyB;AAAA,MACzB,aAAa;AAAA,IACf,CAAC,CAAC;AAAA,IACF,GAAG,QAAQ;AAAA,EACb;AAEA,QAAM,sBAAsB,CAAC,YAAiC;AAC5D,WAAO,IAAI,kCAAkC,SAAS;AAAA,MACpD,UAAU;AAAA,MACV,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,MACpC,SAAS;AAAA,MACT,OAAO,QAAQ;AAAA,MACf,gBAAgB;AAAA,IAClB,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,YAChB,oBAAoB,OAAO;AAE7B,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAEhB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AACA,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/cerebras",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@ai-sdk/openai-compatible": "0.2
|
|
23
|
-
"@ai-sdk/provider": "
|
|
24
|
-
"@ai-sdk/provider-utils": "
|
|
22
|
+
"@ai-sdk/openai-compatible": "1.0.0-alpha.2",
|
|
23
|
+
"@ai-sdk/provider": "2.0.0-alpha.2",
|
|
24
|
+
"@ai-sdk/provider-utils": "3.0.0-alpha.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "20.17.24",
|
|
28
28
|
"tsup": "^8",
|
|
29
|
-
"typescript": "5.
|
|
30
|
-
"zod": "3.
|
|
29
|
+
"typescript": "5.8.3",
|
|
30
|
+
"zod": "3.24.4",
|
|
31
31
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"zod": "^3.
|
|
34
|
+
"zod": "^3.24.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=18"
|
|
@@ -51,13 +51,15 @@
|
|
|
51
51
|
"ai"
|
|
52
52
|
],
|
|
53
53
|
"scripts": {
|
|
54
|
-
"build": "tsup",
|
|
55
|
-
"build:watch": "tsup --watch",
|
|
56
|
-
"clean": "rm -rf dist",
|
|
54
|
+
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
55
|
+
"build:watch": "pnpm clean && tsup --watch",
|
|
56
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
57
57
|
"lint": "eslint \"./**/*.ts*\"",
|
|
58
|
-
"type-check": "tsc --
|
|
58
|
+
"type-check": "tsc --build",
|
|
59
59
|
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
|
60
60
|
"test": "pnpm test:node && pnpm test:edge",
|
|
61
|
+
"test:update": "pnpm test:node -u",
|
|
62
|
+
"test:watch": "vitest --config vitest.node.config.js",
|
|
61
63
|
"test:edge": "vitest --config vitest.edge.config.js --run",
|
|
62
64
|
"test:node": "vitest --config vitest.node.config.js --run"
|
|
63
65
|
}
|