@langchain/anthropic 0.0.3 → 0.0.5

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.
Files changed (2) hide show
  1. package/README.md +122 -1
  2. package/package.json +14 -11
package/README.md CHANGED
@@ -1 +1,122 @@
1
- # langchain-anthropic
1
+ # @langchain/anthropic
2
+
3
+ This package contains the LangChain.js integrations for Anthropic through their SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash npm2yarn
8
+ npm install @langchain/anthropic
9
+ ```
10
+
11
+ This package, along with the main LangChain package, depends on [`@langchain/core`](https://npmjs.com/package/@langchain/core/).
12
+ If you are using this package with other LangChain packages, you should make sure that all of the packages depend on the same instance of @langchain/core.
13
+ You can do so by adding appropriate fields to your project's `package.json` like this:
14
+
15
+ ```json
16
+ {
17
+ "name": "your-project",
18
+ "version": "0.0.0",
19
+ "dependencies": {
20
+ "@langchain/anthropic": "^0.0.0",
21
+ "langchain": "0.0.207"
22
+ },
23
+ "resolutions": {
24
+ "@langchain/core": "0.1.1"
25
+ },
26
+ "overrides": {
27
+ "@langchain/core": "0.1.1"
28
+ },
29
+ "pnpm": {
30
+ "overrides": {
31
+ "@langchain/core": "0.1.1"
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ The field you need depends on the package manager you're using, but we recommend adding a field for the common `yarn`, `npm`, and `pnpm` to maximize compatibility.
38
+
39
+ ## Chat Models
40
+
41
+ This package contains the `ChatAnthropic` class, which is the recommended way to interface with the Anthropic series of models.
42
+
43
+ To use, install the requirements, and configure your environment.
44
+
45
+ ```bash
46
+ export ANTHROPIC_API_KEY=your-api-key
47
+ ```
48
+
49
+ Then initialize
50
+
51
+ ```typescript
52
+ import { ChatAnthropic } from "@langchain/anthropic";
53
+
54
+ const model = new ChatAnthropic({
55
+ anthropicApiKey: process.env.ANTHROPIC_API_KEY,
56
+ });
57
+ const response = await model.invoke(new HumanMessage("Hello world!"));
58
+ ```
59
+
60
+ ### Streaming
61
+
62
+ ```typescript
63
+ import { ChatAnthropic } from "@langchain/anthropic";
64
+
65
+ const model = new ChatAnthropic({
66
+ anthropicApiKey: process.env.ANTHROPIC_API_KEY,
67
+ modelName: "claude-2",
68
+ });
69
+ const response = await model.stream(new HumanMessage("Hello world!"));
70
+ ```
71
+
72
+ ## Development
73
+
74
+ To develop the Anthropic package, you'll need to follow these instructions:
75
+
76
+ ### Install dependencies
77
+
78
+ ```bash
79
+ yarn install
80
+ ```
81
+
82
+ ### Build the package
83
+
84
+ ```bash
85
+ yarn build
86
+ ```
87
+
88
+ Or from the repo root:
89
+
90
+ ```bash
91
+ yarn build --filter=@langchain/anthropic
92
+ ```
93
+
94
+ ### Run tests
95
+
96
+ Test files should live within a `tests/` file in the `src/` folder. Unit tests should end in `.test.ts` and integration tests should
97
+ end in `.int.test.ts`:
98
+
99
+ ```bash
100
+ $ yarn test
101
+ $ yarn test:int
102
+ ```
103
+
104
+ ### Lint & Format
105
+
106
+ Run the linter & formatter to ensure your code is up to standard:
107
+
108
+ ```bash
109
+ yarn lint && yarn format
110
+ ```
111
+
112
+ ### Adding new entrypoints
113
+
114
+ If you add a new file to be exported, either import & re-export from `src/index.ts`, or add it to `scripts/create-entrypoints.js` and run `yarn build` to generate the new entrypoint.
115
+
116
+ ## Publishing
117
+
118
+ After running `yarn build`, publish a new version with:
119
+
120
+ ```bash
121
+ $ npm publish
122
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -13,19 +13,22 @@
13
13
  "url": "git@github.com:langchain-ai/langchainjs.git"
14
14
  },
15
15
  "scripts": {
16
- "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts",
16
+ "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts",
17
+ "build:deps": "yarn run turbo:command build --filter=@langchain/core",
17
18
  "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/",
18
19
  "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && node scripts/move-cjs-to-dist.js && rimraf dist-cjs",
19
20
  "build:watch": "node scripts/create-entrypoints.js && tsc --outDir dist/ --watch",
20
21
  "build:scripts": "node scripts/create-entrypoints.js && node scripts/check-tree-shaking.js",
21
- "lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint src && dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
22
- "lint:fix": "yarn lint --fix",
23
- "clean": "rimraf dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
22
+ "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint src",
23
+ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
24
+ "lint": "yarn lint:eslint && yarn lint:dpdm",
25
+ "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
26
+ "clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
24
27
  "prepack": "yarn build",
25
28
  "release": "release-it --only-version --config .release-it.json",
26
- "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
27
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
28
- "test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
29
+ "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
30
+ "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
31
+ "test:single": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
29
32
  "format": "prettier --write \"src\"",
30
33
  "format:check": "prettier --check \"src\""
31
34
  },
@@ -33,11 +36,10 @@
33
36
  "license": "MIT",
34
37
  "dependencies": {
35
38
  "@anthropic-ai/sdk": "^0.10.0",
36
- "@langchain/core": "~0.0.1"
39
+ "@langchain/core": "~0.1.2"
37
40
  },
38
41
  "devDependencies": {
39
42
  "@jest/globals": "^29.5.0",
40
- "@langchain/core": "workspace:*",
41
43
  "@swc/core": "^1.3.90",
42
44
  "@swc/jest": "^0.2.29",
43
45
  "dpdm": "^3.12.0",
@@ -45,6 +47,7 @@
45
47
  "eslint-config-airbnb-base": "^15.0.0",
46
48
  "eslint-config-prettier": "^8.6.0",
47
49
  "eslint-plugin-import": "^2.27.5",
50
+ "eslint-plugin-jest": "^27.6.0",
48
51
  "eslint-plugin-no-instanceof": "^1.0.1",
49
52
  "eslint-plugin-prettier": "^4.2.1",
50
53
  "jest": "^29.5.0",
@@ -52,7 +55,7 @@
52
55
  "prettier": "^2.8.3",
53
56
  "release-it": "^15.10.1",
54
57
  "rimraf": "^5.0.1",
55
- "typescript": "^5.0.0"
58
+ "typescript": "~5.1.6"
56
59
  },
57
60
  "publishConfig": {
58
61
  "access": "public"