@ai-sdk/cerebras 3.0.0-beta.2 → 3.0.0-beta.20
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 +158 -4
- package/README.md +2 -0
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -6
- package/src/cerebras-provider.ts +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,159 @@
|
|
|
1
1
|
# @ai-sdk/cerebras
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [e311194]
|
|
8
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
9
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.20
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
11
|
+
|
|
12
|
+
## 3.0.0-beta.19
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [34bd95d]
|
|
17
|
+
- Updated dependencies [008271d]
|
|
18
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
19
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.19
|
|
20
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
21
|
+
|
|
22
|
+
## 3.0.0-beta.18
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [b0c2869]
|
|
27
|
+
- Updated dependencies [7e26e81]
|
|
28
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
29
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.18
|
|
30
|
+
|
|
31
|
+
## 3.0.0-beta.17
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [816ff67]
|
|
36
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.17
|
|
37
|
+
|
|
38
|
+
## 3.0.0-beta.16
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [46d1149]
|
|
43
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
44
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.16
|
|
45
|
+
|
|
46
|
+
## 3.0.0-beta.15
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [6fd51c0]
|
|
51
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
52
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
53
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.15
|
|
54
|
+
|
|
55
|
+
## 3.0.0-beta.14
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [c29a26f]
|
|
60
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.14
|
|
61
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
62
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
63
|
+
|
|
64
|
+
## 3.0.0-beta.13
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
69
|
+
- Updated dependencies [38fc777]
|
|
70
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.13
|
|
71
|
+
|
|
72
|
+
## 3.0.0-beta.12
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies [2e17091]
|
|
77
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
78
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.12
|
|
79
|
+
|
|
80
|
+
## 3.0.0-beta.11
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- Updated dependencies [986c6fd]
|
|
85
|
+
- Updated dependencies [493295c]
|
|
86
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
87
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.11
|
|
88
|
+
|
|
89
|
+
## 3.0.0-beta.10
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [1f509d4]
|
|
94
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
95
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
96
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.10
|
|
97
|
+
|
|
98
|
+
## 3.0.0-beta.9
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [74d520f]
|
|
103
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.9
|
|
104
|
+
|
|
105
|
+
## 3.0.0-beta.8
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [3887c70]
|
|
110
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
111
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
112
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.8
|
|
113
|
+
|
|
114
|
+
## 3.0.0-beta.7
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Updated dependencies [776b617]
|
|
119
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
120
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
121
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.7
|
|
122
|
+
|
|
123
|
+
## 3.0.0-beta.6
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- Updated dependencies [61753c3]
|
|
128
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
129
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.6
|
|
130
|
+
|
|
131
|
+
## 3.0.0-beta.5
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- Updated dependencies [f7d4f01]
|
|
136
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
137
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
138
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.5
|
|
139
|
+
|
|
140
|
+
## 3.0.0-beta.4
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- Updated dependencies [5c2a5a2]
|
|
145
|
+
- @ai-sdk/provider@4.0.0-beta.1
|
|
146
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.4
|
|
147
|
+
- @ai-sdk/provider-utils@5.0.0-beta.2
|
|
148
|
+
|
|
149
|
+
## 3.0.0-beta.3
|
|
150
|
+
|
|
151
|
+
### Patch Changes
|
|
152
|
+
|
|
153
|
+
- 8f3e1da: chore(openai-compat): update v3 specs to v4
|
|
154
|
+
- Updated dependencies [8f3e1da]
|
|
155
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.3
|
|
156
|
+
|
|
3
157
|
## 3.0.0-beta.2
|
|
4
158
|
|
|
5
159
|
### Patch Changes
|
|
@@ -347,13 +501,13 @@
|
|
|
347
501
|
Before
|
|
348
502
|
|
|
349
503
|
```ts
|
|
350
|
-
model.textEmbeddingModel(
|
|
504
|
+
model.textEmbeddingModel("my-model-id");
|
|
351
505
|
```
|
|
352
506
|
|
|
353
507
|
After
|
|
354
508
|
|
|
355
509
|
```ts
|
|
356
|
-
model.embeddingModel(
|
|
510
|
+
model.embeddingModel("my-model-id");
|
|
357
511
|
```
|
|
358
512
|
|
|
359
513
|
- 42e9f64: Add support for 5 new Cerebras models:
|
|
@@ -586,13 +740,13 @@
|
|
|
586
740
|
Before
|
|
587
741
|
|
|
588
742
|
```ts
|
|
589
|
-
model.textEmbeddingModel(
|
|
743
|
+
model.textEmbeddingModel("my-model-id");
|
|
590
744
|
```
|
|
591
745
|
|
|
592
746
|
After
|
|
593
747
|
|
|
594
748
|
```ts
|
|
595
|
-
model.embeddingModel(
|
|
749
|
+
model.embeddingModel("my-model-id");
|
|
596
750
|
```
|
|
597
751
|
|
|
598
752
|
- Updated dependencies [8d9e8ad]
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The **Cerebras provider** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for [Cerebras](https://cerebras.ai), offering high-speed AI model inference powered by Cerebras Wafer-Scale Engines and CS-3 systems.
|
|
4
4
|
|
|
5
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access Cerebras (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 Cerebras provider is available in the `@ai-sdk/cerebras` module. You can install it with
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
@@ -30,19 +30,19 @@ interface CerebrasProviderSettings {
|
|
|
30
30
|
*/
|
|
31
31
|
fetch?: FetchFunction;
|
|
32
32
|
}
|
|
33
|
-
interface CerebrasProvider extends
|
|
33
|
+
interface CerebrasProvider extends ProviderV4 {
|
|
34
34
|
/**
|
|
35
35
|
* Creates a Cerebras model for text generation.
|
|
36
36
|
*/
|
|
37
|
-
(modelId: CerebrasChatModelId):
|
|
37
|
+
(modelId: CerebrasChatModelId): LanguageModelV4;
|
|
38
38
|
/**
|
|
39
39
|
* Creates a Cerebras model for text generation.
|
|
40
40
|
*/
|
|
41
|
-
languageModel(modelId: CerebrasChatModelId):
|
|
41
|
+
languageModel(modelId: CerebrasChatModelId): LanguageModelV4;
|
|
42
42
|
/**
|
|
43
43
|
* Creates a Cerebras chat model for text generation.
|
|
44
44
|
*/
|
|
45
|
-
chat(modelId: CerebrasChatModelId):
|
|
45
|
+
chat(modelId: CerebrasChatModelId): LanguageModelV4;
|
|
46
46
|
/**
|
|
47
47
|
* @deprecated Use `embeddingModel` instead.
|
|
48
48
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
@@ -30,19 +30,19 @@ interface CerebrasProviderSettings {
|
|
|
30
30
|
*/
|
|
31
31
|
fetch?: FetchFunction;
|
|
32
32
|
}
|
|
33
|
-
interface CerebrasProvider extends
|
|
33
|
+
interface CerebrasProvider extends ProviderV4 {
|
|
34
34
|
/**
|
|
35
35
|
* Creates a Cerebras model for text generation.
|
|
36
36
|
*/
|
|
37
|
-
(modelId: CerebrasChatModelId):
|
|
37
|
+
(modelId: CerebrasChatModelId): LanguageModelV4;
|
|
38
38
|
/**
|
|
39
39
|
* Creates a Cerebras model for text generation.
|
|
40
40
|
*/
|
|
41
|
-
languageModel(modelId: CerebrasChatModelId):
|
|
41
|
+
languageModel(modelId: CerebrasChatModelId): LanguageModelV4;
|
|
42
42
|
/**
|
|
43
43
|
* Creates a Cerebras chat model for text generation.
|
|
44
44
|
*/
|
|
45
|
-
chat(modelId: CerebrasChatModelId):
|
|
45
|
+
chat(modelId: CerebrasChatModelId): LanguageModelV4;
|
|
46
46
|
/**
|
|
47
47
|
* @deprecated Use `embeddingModel` instead.
|
|
48
48
|
*/
|
package/dist/index.js
CHANGED
|
@@ -18,13 +18,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
VERSION: () => VERSION,
|
|
24
24
|
cerebras: () => cerebras,
|
|
25
25
|
createCerebras: () => createCerebras
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// src/cerebras-provider.ts
|
|
30
30
|
var import_openai_compatible = require("@ai-sdk/openai-compatible");
|
|
@@ -33,7 +33,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
|
33
33
|
var import_v4 = require("zod/v4");
|
|
34
34
|
|
|
35
35
|
// src/version.ts
|
|
36
|
-
var VERSION = true ? "3.0.0-beta.
|
|
36
|
+
var VERSION = true ? "3.0.0-beta.20" : "0.0.0-test";
|
|
37
37
|
|
|
38
38
|
// src/cerebras-provider.ts
|
|
39
39
|
var cerebrasErrorSchema = import_v4.z.object({
|
|
@@ -73,7 +73,7 @@ function createCerebras(options = {}) {
|
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
75
|
const provider = (modelId) => createLanguageModel(modelId);
|
|
76
|
-
provider.specificationVersion = "
|
|
76
|
+
provider.specificationVersion = "v4";
|
|
77
77
|
provider.languageModel = createLanguageModel;
|
|
78
78
|
provider.chat = createLanguageModel;
|
|
79
79
|
provider.embeddingModel = (modelId) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/cerebras-provider.ts","../src/version.ts"],"sourcesContent":["export { createCerebras, cerebras } from './cerebras-provider';\nexport type {\n CerebrasProvider,\n CerebrasProviderSettings,\n} from './cerebras-provider';\nexport type { CerebrasErrorData } from './cerebras-provider';\nexport { VERSION } from './version';\n","import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/cerebras-provider.ts","../src/version.ts"],"sourcesContent":["export { createCerebras, cerebras } from './cerebras-provider';\nexport type {\n CerebrasProvider,\n CerebrasProviderSettings,\n} from './cerebras-provider';\nexport type { CerebrasErrorData } from './cerebras-provider';\nexport { VERSION } from './version';\n","import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n LanguageModelV4,\n NoSuchModelError,\n ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { CerebrasChatModelId } from './cerebras-chat-options';\nimport { z } from 'zod/v4';\nimport { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\nimport { VERSION } from './version';\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 /**\n * Cerebras API key.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\n */\n baseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV4 {\n /**\n * Creates a Cerebras model for text generation.\n */\n (modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras model for text generation.\n */\n languageModel(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras chat model for text generation.\n */\n chat(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\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 withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'CEREBRAS_API_KEY',\n description: 'Cerebras API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/cerebras/${VERSION}`,\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 supportsStructuredOutputs: true,\n });\n };\n\n const provider = (modelId: CerebrasChatModelId) =>\n createLanguageModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const cerebras = createCerebras();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,+BAAkD;AAClD,sBAIO;AACP,4BAKO;AAEP,gBAAkB;;;ACXX,IAAM,UACX,OACI,kBACA;;;ADaN,IAAM,sBAAsB,YAAE,OAAO;AAAA,EACnC,SAAS,YAAE,OAAO;AAAA,EAClB,MAAM,YAAE,OAAO;AAAA,EACf,OAAO,YAAE,OAAO;AAAA,EAChB,MAAM,YAAE,OAAO;AACjB,CAAC;AAID,IAAM,yBAAoE;AAAA,EACxE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK;AAC/B;AA4CO,SAAS,eACd,UAAoC,CAAC,GACnB;AA5EpB;AA6EE,QAAM,cAAU;AAAA,KACd,aAAQ,YAAR,YAAmB;AAAA,EACrB;AACA,QAAM,aAAa,UACjB;AAAA,IACE;AAAA,MACE,eAAe,cAAU,kCAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,mBAAmB,OAAO;AAAA,EAC5B;AAEF,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,MAChB,2BAA2B;AAAA,IAC7B,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,YAChB,oBAAoB,OAAO;AAE7B,WAAS,uBAAuB;AAChC,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAEhB,WAAS,iBAAiB,CAAC,YAAoB;AAC7C,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,iBAAiB,CAAC;AAAA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,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
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { z } from "zod/v4";
|
|
12
12
|
|
|
13
13
|
// src/version.ts
|
|
14
|
-
var VERSION = true ? "3.0.0-beta.
|
|
14
|
+
var VERSION = true ? "3.0.0-beta.20" : "0.0.0-test";
|
|
15
15
|
|
|
16
16
|
// src/cerebras-provider.ts
|
|
17
17
|
var cerebrasErrorSchema = z.object({
|
|
@@ -51,7 +51,7 @@ function createCerebras(options = {}) {
|
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
53
|
const provider = (modelId) => createLanguageModel(modelId);
|
|
54
|
-
provider.specificationVersion = "
|
|
54
|
+
provider.specificationVersion = "v4";
|
|
55
55
|
provider.languageModel = createLanguageModel;
|
|
56
56
|
provider.chat = createLanguageModel;
|
|
57
57
|
provider.embeddingModel = (modelId) => {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cerebras-provider.ts","../src/version.ts"],"sourcesContent":["import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../src/cerebras-provider.ts","../src/version.ts"],"sourcesContent":["import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n LanguageModelV4,\n NoSuchModelError,\n ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { CerebrasChatModelId } from './cerebras-chat-options';\nimport { z } from 'zod/v4';\nimport { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\nimport { VERSION } from './version';\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 /**\n * Cerebras API key.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\n */\n baseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV4 {\n /**\n * Creates a Cerebras model for text generation.\n */\n (modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras model for text generation.\n */\n languageModel(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras chat model for text generation.\n */\n chat(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\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 withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'CEREBRAS_API_KEY',\n description: 'Cerebras API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/cerebras/${VERSION}`,\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 supportsStructuredOutputs: true,\n });\n };\n\n const provider = (modelId: CerebrasChatModelId) =>\n createLanguageModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const cerebras = createCerebras();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA,SAAS,yCAAyC;AAClD;AAAA,EAEE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS;;;ACXX,IAAM,UACX,OACI,kBACA;;;ADaN,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;AA4CO,SAAS,eACd,UAAoC,CAAC,GACnB;AA5EpB;AA6EE,QAAM,UAAU;AAAA,KACd,aAAQ,YAAR,YAAmB;AAAA,EACrB;AACA,QAAM,aAAa,MACjB;AAAA,IACE;AAAA,MACE,eAAe,UAAU,WAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,mBAAmB,OAAO;AAAA,EAC5B;AAEF,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,MAChB,2BAA2B;AAAA,IAC7B,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,YAChB,oBAAoB,OAAO;AAE7B,WAAS,uBAAuB;AAChC,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAEhB,WAAS,iBAAiB,CAAC,YAAoB;AAC7C,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,iBAAiB,CAAC;AAAA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,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": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.20",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/openai-compatible": "3.0.0-beta.
|
|
33
|
-
"@ai-sdk/provider": "4.0.0-beta.
|
|
34
|
-
"@ai-sdk/provider-utils": "5.0.0-beta.
|
|
32
|
+
"@ai-sdk/openai-compatible": "3.0.0-beta.20",
|
|
33
|
+
"@ai-sdk/provider": "4.0.0-beta.9",
|
|
34
|
+
"@ai-sdk/provider-utils": "5.0.0-beta.15"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "20.17.24",
|
|
@@ -67,9 +67,7 @@
|
|
|
67
67
|
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
68
68
|
"build:watch": "pnpm clean && tsup --watch",
|
|
69
69
|
"clean": "del-cli dist docs *.tsbuildinfo",
|
|
70
|
-
"lint": "eslint \"./**/*.ts*\"",
|
|
71
70
|
"type-check": "tsc --build",
|
|
72
|
-
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
|
73
71
|
"test": "pnpm test:node && pnpm test:edge",
|
|
74
72
|
"test:update": "pnpm test:node -u",
|
|
75
73
|
"test:watch": "vitest --config vitest.node.config.js",
|
package/src/cerebras-provider.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
LanguageModelV4,
|
|
4
4
|
NoSuchModelError,
|
|
5
|
-
|
|
5
|
+
ProviderV4,
|
|
6
6
|
} from '@ai-sdk/provider';
|
|
7
7
|
import {
|
|
8
8
|
FetchFunction,
|
|
@@ -50,21 +50,21 @@ export interface CerebrasProviderSettings {
|
|
|
50
50
|
fetch?: FetchFunction;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export interface CerebrasProvider extends
|
|
53
|
+
export interface CerebrasProvider extends ProviderV4 {
|
|
54
54
|
/**
|
|
55
55
|
* Creates a Cerebras model for text generation.
|
|
56
56
|
*/
|
|
57
|
-
(modelId: CerebrasChatModelId):
|
|
57
|
+
(modelId: CerebrasChatModelId): LanguageModelV4;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Creates a Cerebras model for text generation.
|
|
61
61
|
*/
|
|
62
|
-
languageModel(modelId: CerebrasChatModelId):
|
|
62
|
+
languageModel(modelId: CerebrasChatModelId): LanguageModelV4;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Creates a Cerebras chat model for text generation.
|
|
66
66
|
*/
|
|
67
|
-
chat(modelId: CerebrasChatModelId):
|
|
67
|
+
chat(modelId: CerebrasChatModelId): LanguageModelV4;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* @deprecated Use `embeddingModel` instead.
|
|
@@ -105,7 +105,7 @@ export function createCerebras(
|
|
|
105
105
|
const provider = (modelId: CerebrasChatModelId) =>
|
|
106
106
|
createLanguageModel(modelId);
|
|
107
107
|
|
|
108
|
-
provider.specificationVersion = '
|
|
108
|
+
provider.specificationVersion = 'v4' as const;
|
|
109
109
|
provider.languageModel = createLanguageModel;
|
|
110
110
|
provider.chat = createLanguageModel;
|
|
111
111
|
|