@ai-sdk/cerebras 1.0.0-alpha.9 → 1.0.0-beta.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 +94 -0
- package/dist/index.d.mts +2 -12
- package/dist/index.d.ts +2 -12
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
# @ai-sdk/cerebras
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d1a034f: feature: using Zod 4 for internal stuff
|
|
8
|
+
- Updated dependencies [0571b98]
|
|
9
|
+
- Updated dependencies [39a4fab]
|
|
10
|
+
- Updated dependencies [d1a034f]
|
|
11
|
+
- @ai-sdk/provider-utils@3.0.0-beta.2
|
|
12
|
+
- @ai-sdk/openai-compatible@1.0.0-beta.2
|
|
13
|
+
|
|
14
|
+
## 1.0.0-beta.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [742b7be]
|
|
19
|
+
- Updated dependencies [7cddb72]
|
|
20
|
+
- Updated dependencies [ccce59b]
|
|
21
|
+
- Updated dependencies [e2b9e4b]
|
|
22
|
+
- Updated dependencies [45c1ea2]
|
|
23
|
+
- Updated dependencies [e025824]
|
|
24
|
+
- Updated dependencies [0d06df6]
|
|
25
|
+
- Updated dependencies [472524a]
|
|
26
|
+
- Updated dependencies [dd3ff01]
|
|
27
|
+
- Updated dependencies [7435eb5]
|
|
28
|
+
- Updated dependencies [cb68df0]
|
|
29
|
+
- Updated dependencies [bfdca8d]
|
|
30
|
+
- Updated dependencies [44f4aba]
|
|
31
|
+
- Updated dependencies [023ba40]
|
|
32
|
+
- Updated dependencies [5e57fae]
|
|
33
|
+
- Updated dependencies [71f938d]
|
|
34
|
+
- Updated dependencies [28a5ed5]
|
|
35
|
+
- @ai-sdk/provider@2.0.0-beta.1
|
|
36
|
+
- @ai-sdk/provider-utils@3.0.0-beta.1
|
|
37
|
+
- @ai-sdk/openai-compatible@1.0.0-beta.1
|
|
38
|
+
|
|
39
|
+
## 1.0.0-alpha.15
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [48d257a]
|
|
44
|
+
- Updated dependencies [8ba77a7]
|
|
45
|
+
- @ai-sdk/provider@2.0.0-alpha.15
|
|
46
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.15
|
|
47
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.15
|
|
48
|
+
|
|
49
|
+
## 1.0.0-alpha.14
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [b5da06a]
|
|
54
|
+
- Updated dependencies [63f9e9b]
|
|
55
|
+
- Updated dependencies [2e13791]
|
|
56
|
+
- @ai-sdk/provider@2.0.0-alpha.14
|
|
57
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.14
|
|
58
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.14
|
|
59
|
+
|
|
60
|
+
## 1.0.0-alpha.13
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [68ecf2f]
|
|
65
|
+
- @ai-sdk/provider@2.0.0-alpha.13
|
|
66
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.13
|
|
67
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.13
|
|
68
|
+
|
|
69
|
+
## 1.0.0-alpha.12
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- e2aceaf: feat: add raw chunk support
|
|
74
|
+
- Updated dependencies [e2aceaf]
|
|
75
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.12
|
|
76
|
+
- @ai-sdk/provider@2.0.0-alpha.12
|
|
77
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.12
|
|
78
|
+
|
|
79
|
+
## 1.0.0-alpha.11
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [c1e6647]
|
|
84
|
+
- @ai-sdk/provider@2.0.0-alpha.11
|
|
85
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.11
|
|
86
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.11
|
|
87
|
+
|
|
88
|
+
## 1.0.0-alpha.10
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- Updated dependencies [c4df419]
|
|
93
|
+
- @ai-sdk/provider@2.0.0-alpha.10
|
|
94
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.10
|
|
95
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.10
|
|
96
|
+
|
|
3
97
|
## 1.0.0-alpha.9
|
|
4
98
|
|
|
5
99
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { z } from 'zod';
|
|
3
|
+
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
5
|
type CerebrasChatModelId = 'llama3.1-8b' | 'llama3.1-70b' | 'llama-3.3-70b' | (string & {});
|
|
6
6
|
|
|
@@ -9,17 +9,7 @@ declare const cerebrasErrorSchema: z.ZodObject<{
|
|
|
9
9
|
type: z.ZodString;
|
|
10
10
|
param: z.ZodString;
|
|
11
11
|
code: z.ZodString;
|
|
12
|
-
},
|
|
13
|
-
message: string;
|
|
14
|
-
type: string;
|
|
15
|
-
param: string;
|
|
16
|
-
code: string;
|
|
17
|
-
}, {
|
|
18
|
-
message: string;
|
|
19
|
-
type: string;
|
|
20
|
-
param: string;
|
|
21
|
-
code: string;
|
|
22
|
-
}>;
|
|
12
|
+
}, z.core.$strip>;
|
|
23
13
|
type CerebrasErrorData = z.infer<typeof cerebrasErrorSchema>;
|
|
24
14
|
interface CerebrasProviderSettings {
|
|
25
15
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { z } from 'zod';
|
|
3
|
+
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
5
|
type CerebrasChatModelId = 'llama3.1-8b' | 'llama3.1-70b' | 'llama-3.3-70b' | (string & {});
|
|
6
6
|
|
|
@@ -9,17 +9,7 @@ declare const cerebrasErrorSchema: z.ZodObject<{
|
|
|
9
9
|
type: z.ZodString;
|
|
10
10
|
param: z.ZodString;
|
|
11
11
|
code: z.ZodString;
|
|
12
|
-
},
|
|
13
|
-
message: string;
|
|
14
|
-
type: string;
|
|
15
|
-
param: string;
|
|
16
|
-
code: string;
|
|
17
|
-
}, {
|
|
18
|
-
message: string;
|
|
19
|
-
type: string;
|
|
20
|
-
param: string;
|
|
21
|
-
code: string;
|
|
22
|
-
}>;
|
|
12
|
+
}, z.core.$strip>;
|
|
23
13
|
type CerebrasErrorData = z.infer<typeof cerebrasErrorSchema>;
|
|
24
14
|
interface CerebrasProviderSettings {
|
|
25
15
|
/**
|
package/dist/index.js
CHANGED
|
@@ -29,12 +29,12 @@ module.exports = __toCommonJS(src_exports);
|
|
|
29
29
|
var import_openai_compatible = require("@ai-sdk/openai-compatible");
|
|
30
30
|
var import_provider = require("@ai-sdk/provider");
|
|
31
31
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
32
|
-
var
|
|
33
|
-
var cerebrasErrorSchema =
|
|
34
|
-
message:
|
|
35
|
-
type:
|
|
36
|
-
param:
|
|
37
|
-
code:
|
|
32
|
+
var import_v4 = require("zod/v4");
|
|
33
|
+
var cerebrasErrorSchema = import_v4.z.object({
|
|
34
|
+
message: import_v4.z.string(),
|
|
35
|
+
type: import_v4.z.string(),
|
|
36
|
+
param: import_v4.z.string(),
|
|
37
|
+
code: import_v4.z.string()
|
|
38
38
|
});
|
|
39
39
|
var cerebrasErrorStructure = {
|
|
40
40
|
errorSchema: cerebrasErrorSchema,
|
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 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,
|
|
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/v4';\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,gBAAkB;AAIlB,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;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
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 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":[]}
|
|
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/v4';\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": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@ai-sdk/openai-compatible": "1.0.0-
|
|
23
|
-
"@ai-sdk/provider": "2.0.0-
|
|
24
|
-
"@ai-sdk/provider-utils": "3.0.0-
|
|
22
|
+
"@ai-sdk/openai-compatible": "1.0.0-beta.2",
|
|
23
|
+
"@ai-sdk/provider": "2.0.0-beta.1",
|
|
24
|
+
"@ai-sdk/provider-utils": "3.0.0-beta.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "20.17.24",
|