-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lint, add to universal chat model
- Loading branch information
1 parent
54c30d5
commit 3601a00
Showing
8 changed files
with
165 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
index.cjs | ||
index.js | ||
index.d.ts | ||
index.d.cts | ||
node_modules | ||
dist | ||
.yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# @langchain/cerebras | ||
|
||
This package contains the LangChain.js integrations for Cerebras via the `@cerebras/cerebras_cloud_sdk` package. | ||
|
||
## Installation | ||
|
||
```bash npm2yarn | ||
npm install @langchain/cerebras @langchain/core | ||
``` | ||
|
||
## Chat models | ||
|
||
This package adds support for Cerebras chat model inference. | ||
|
||
Set the necessary environment variable (or pass it in via the constructor): | ||
|
||
```bash | ||
export CEREBRAS_API_KEY= | ||
``` | ||
|
||
```typescript | ||
import { ChatCerebras } from "@langchain/cerebras"; | ||
import { HumanMessage } from "@langchain/core/messages"; | ||
|
||
const model = new ChatCerebras({ | ||
apiKey: process.env.CEREBRAS_API_KEY, // Default value. | ||
}); | ||
|
||
const message = new HumanMessage("What color is the sky?"); | ||
|
||
const res = await model.invoke([message]); | ||
``` | ||
|
||
## Development | ||
|
||
To develop the `@langchain/cerebras` package, you'll need to follow these instructions: | ||
|
||
### Install dependencies | ||
|
||
```bash | ||
yarn install | ||
``` | ||
|
||
### Build the package | ||
|
||
```bash | ||
yarn build | ||
``` | ||
|
||
Or from the repo root: | ||
|
||
```bash | ||
yarn build --filter=@langchain/cerebras | ||
``` | ||
|
||
### Run tests | ||
|
||
Test files should live within a `tests/` file in the `src/` folder. Unit tests should end in `.test.ts` and integration tests should | ||
end in `.int.test.ts`: | ||
|
||
```bash | ||
$ yarn test | ||
$ yarn test:int | ||
``` | ||
|
||
### Lint & Format | ||
|
||
Run the linter & formatter to ensure your code is up to standard: | ||
|
||
```bash | ||
yarn lint && yarn format | ||
``` | ||
|
||
### Adding new entrypoints | ||
|
||
If you add a new file to be exported, either import & re-export from `src/index.ts`, or add it to the `entrypoints` field in the `config` variable located inside `langchain.config.js` and run `yarn build` to generate the new entrypoint. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "langchain-cerebras", | ||
"name": "@langchain/cerebras", | ||
"version": "0.0.0", | ||
"description": "Sample integration for LangChain.js", | ||
"type": "module", | ||
|
@@ -12,9 +12,9 @@ | |
"type": "git", | ||
"url": "[email protected]:langchain-ai/langchainjs.git" | ||
}, | ||
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/", | ||
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-cerebras/", | ||
"scripts": { | ||
"build": "yarn turbo:command build:internal --filter=@langchain/INTEGRATION_NAME", | ||
"build": "yarn turbo:command build:internal --filter=@langchain/cerebras", | ||
"build:internal": "yarn lc_build --create-entrypoints --pre --tree-shaking", | ||
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", | ||
"lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", | ||
|
@@ -33,6 +33,7 @@ | |
"license": "MIT", | ||
"dependencies": { | ||
"@cerebras/cerebras_cloud_sdk": "^1.15.0", | ||
"uuid": "^10.0.0", | ||
"zod": "^3.22.4", | ||
"zod-to-json-schema": "^3.22.3" | ||
}, | ||
|
@@ -41,10 +42,13 @@ | |
}, | ||
"devDependencies": { | ||
"@jest/globals": "^29.5.0", | ||
"@langchain/core": "workspace:*", | ||
"@langchain/scripts": ">=0.1.0 <0.2.0", | ||
"@langchain/standard-tests": "0.0.0", | ||
"@swc/core": "^1.3.90", | ||
"@swc/jest": "^0.2.29", | ||
"@tsconfig/recommended": "^1.0.3", | ||
"@types/uuid": "^10", | ||
"@typescript-eslint/eslint-plugin": "^6.12.0", | ||
"@typescript-eslint/parser": "^6.12.0", | ||
"dotenv": "^16.3.1", | ||
|
@@ -68,7 +72,11 @@ | |
}, | ||
"exports": { | ||
".": { | ||
"types": "./index.d.ts", | ||
"types": { | ||
"import": "./index.d.ts", | ||
"require": "./index.d.cts", | ||
"default": "./index.d.ts" | ||
}, | ||
"import": "./index.js", | ||
"require": "./index.cjs" | ||
}, | ||
|
@@ -78,6 +86,7 @@ | |
"dist/", | ||
"index.cjs", | ||
"index.js", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"index.d.cts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters