Skip to content

Commit

Permalink
fix(docs): imports and call (#7636)
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Lee <[email protected]>
  • Loading branch information
crishoj and jacoblee93 authored Feb 1, 2025
1 parent 05eedae commit 7b67d43
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions libs/langchain-anthropic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,30 @@ export ANTHROPIC_API_KEY=your-api-key
Then initialize

```typescript
import { ChatAnthropicMessages } from "@langchain/anthropic";
import { ChatAnthropic } from "@langchain/anthropic";

const model = new ChatAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const response = await model.invoke(new HumanMessage("Hello world!"));
const response = await model.invoke({
role: "user",
content: "Hello world!",
});
```

### Streaming

```typescript
import { ChatAnthropicMessages } from "@langchain/anthropic";
import { ChatAnthropic } from "@langchain/anthropic";

const model = new ChatAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
model: "claude-3-sonnet-20240229",
});
const response = await model.stream(new HumanMessage("Hello world!"));
const response = await model.stream({
role: "user",
content: "Hello world!",
});
```

## Development
Expand Down Expand Up @@ -119,4 +125,4 @@ After running `yarn build`, publish a new version with:

```bash
$ npm publish
```
```

0 comments on commit 7b67d43

Please sign in to comment.