From e8cd1aa2b35195cd407b76ca855c79e703ec9a90 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 19:31:33 +0000 Subject: [PATCH] docs: use latest sonnet in example snippets (#625) --- README.md | 24 ++++++++++++------------ examples/cancellation.ts | 2 +- examples/demo.ts | 2 +- examples/raw-streaming.ts | 2 +- examples/streaming.ts | 2 +- examples/tools.ts | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 714e8d16..6dfc86fd 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ async function main() { const message = await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', }); console.log(message.content); @@ -49,7 +49,7 @@ const client = new Anthropic(); const stream = await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', stream: true, }); for await (const messageStreamEvent of stream) { @@ -76,7 +76,7 @@ async function main() { const params: Anthropic.MessageCreateParams = { max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', }; const message: Anthropic.Message = await client.messages.create(params); } @@ -108,7 +108,7 @@ const anthropic = new Anthropic(); async function main() { const stream = anthropic.messages .stream({ - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', max_tokens: 1024, messages: [ { @@ -198,7 +198,7 @@ async function main() { .create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', }) .catch(async (err) => { if (err instanceof Anthropic.APIError) { @@ -234,7 +234,7 @@ Error codes are as followed: All object responses in the SDK provide a `_request_id` property which is added from the `request-id` response header so that you can quickly log failing requests and report them back to Anthropic. ```ts -const message = await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-opus-20240229' }); +const message = await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-5-sonnet-latest' }); console.log(completion._request_id) // req_018EeWyXxfu5pfWkrYcMdjWG ``` @@ -255,7 +255,7 @@ const client = new Anthropic({ }); // Or, configure per-request: -await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-opus-20240229' }, { +await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-5-sonnet-latest' }, { maxRetries: 5, }); ``` @@ -272,7 +272,7 @@ const client = new Anthropic({ }); // Override per-request: -await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-opus-20240229' }, { +await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-5-sonnet-latest' }, { timeout: 5 * 1000, }); ``` @@ -329,7 +329,7 @@ const message = await client.messages.create( { max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', }, { headers: { 'anthropic-version': 'My-Custom-Value' } }, ); @@ -351,7 +351,7 @@ const response = await client.messages .create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', }) .asResponse(); console.log(response.headers.get('X-My-Header')); @@ -361,7 +361,7 @@ const { data: message, response: raw } = await client.messages .create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', }) .withResponse(); console.log(raw.headers.get('X-My-Header')); @@ -473,7 +473,7 @@ await client.messages.create( { max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', }, { httpAgent: new http.Agent({ keepAlive: false }), diff --git a/examples/cancellation.ts b/examples/cancellation.ts index 23fb7ec9..fc8bb0c7 100755 --- a/examples/cancellation.ts +++ b/examples/cancellation.ts @@ -16,7 +16,7 @@ async function main() { const question = 'Hey Claude! How can I recursively list all files in a directory in Rust?'; const stream = await client.messages.create({ - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', stream: true, max_tokens: 500, messages: [{ role: 'user', content: question }], diff --git a/examples/demo.ts b/examples/demo.ts index 609e63ef..33fc2d87 100755 --- a/examples/demo.ts +++ b/examples/demo.ts @@ -12,7 +12,7 @@ async function main() { content: 'Hey Claude!?', }, ], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', max_tokens: 1024, }); console.dir(result); diff --git a/examples/raw-streaming.ts b/examples/raw-streaming.ts index 559a6cac..916f2a4d 100755 --- a/examples/raw-streaming.ts +++ b/examples/raw-streaming.ts @@ -6,7 +6,7 @@ const client = new Anthropic(); // gets API Key from environment variable ANTHRO async function main() { const stream = await client.messages.create({ - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', stream: true, max_tokens: 500, messages: [ diff --git a/examples/streaming.ts b/examples/streaming.ts index 9ac2da60..bc2c74bd 100755 --- a/examples/streaming.ts +++ b/examples/streaming.ts @@ -13,7 +13,7 @@ async function main() { content: `Hey Claude! How can I recursively list all files in a directory in Rust?`, }, ], - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', max_tokens: 1024, }) // Once a content block is fully streamed, this event will fire diff --git a/examples/tools.ts b/examples/tools.ts index b237043b..1a696bc0 100644 --- a/examples/tools.ts +++ b/examples/tools.ts @@ -22,7 +22,7 @@ async function main() { ]; const message = await client.messages.create({ - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', max_tokens: 1024, messages: [userMessage], tools, @@ -38,7 +38,7 @@ async function main() { assert(tool); const result = await client.messages.create({ - model: 'claude-3-opus-20240229', + model: 'claude-3-5-sonnet-latest', max_tokens: 1024, messages: [ userMessage,