Skip to content

docs[patch]: Update Anthropic model example #5826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions examples/src/models/chat/integration_anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChatAnthropic } from "@langchain/anthropic";

const model = new ChatAnthropic({
temperature: 0.9,
model: "claude-3-sonnet-20240229",
model: "claude-3-5-sonnet-20240620",
// In Node.js defaults to process.env.ANTHROPIC_API_KEY,
// apiKey: "YOUR-API-KEY",
maxTokens: 1024,
Expand All @@ -14,16 +14,30 @@ console.log(res);

/*
AIMessage {
content: "The sky appears blue because of how air in Earth's atmosphere interacts with sunlight. As sunlight passes through the atmosphere, light waves get scattered by gas molecules and airborne particles. Blue light waves scatter more easily than other color light waves. Since blue light gets scattered across the sky, we perceive the sky as having a blue color.",
name: undefined,
additional_kwargs: {
id: 'msg_01JuukTnjoXHuzQaPiSVvZQ1',
type: 'message',
role: 'assistant',
model: 'claude-3-sonnet-20240229',
content: "The sky appears blue due to a phenomenon called Rayleigh scattering. Here's a brief explanation:\n" +
'\n' +
'1. Sunlight contains all colors of the visible spectrum.\n' +
'\n' +
"2. As sunlight enters Earth's atmosphere, it collides with gas molecules and other particles.\n" +
'\n' +
'3. These collisions cause the light to scatter in all directions.\n' +
'\n' +
'4. Blue light has a shorter wavelength and higher frequency than other colors in the visible spectrum, so it scatters more easily than other colors.\n' +
'\n' +
'5. This scattered blue light reaches our eyes from all directions, making the sky appear blue.\n' +
'\n' +
'6. Other colors, like red and yellow, have longer wavelengths and pass through the atmosphere more directly, which is why we see them primarily during sunrise and sunset when sunlight travels through more of the atmosphere to reach our eyes.\n' +
'\n' +
'This effect is more pronounced during the day when the sun is high in the sky. At sunrise and sunset, when sunlight travels through more of the atmosphere, we see more red and orange colors because the blue light has been scattered away by the time it reaches our eyes.',
response_metadata: {
id: 'msg_013zKN9RXhpyCeHNsgwHjHsi',
model: 'claude-3-5-sonnet-20240620',
stop_reason: 'end_turn',
stop_sequence: null,
usage: { input_tokens: 15, output_tokens: 70 }
}
usage: { input_tokens: 13, output_tokens: 233 }
},
tool_calls: [],
invalid_tool_calls: [],
usage_metadata: { input_tokens: 13, output_tokens: 233, total_tokens: 246 }
}
*/
Loading