Skip to content
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

chore(docs): fix incorrect client var names #479

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
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
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const client = new Anthropic({
});

async function main() {
const message = await anthropic.messages.create({
const message = await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-3-opus-20240229',
Expand All @@ -46,7 +46,7 @@ import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();

const stream = await anthropic.messages.create({
const stream = await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-3-opus-20240229',
Expand Down Expand Up @@ -78,7 +78,7 @@ async function main() {
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-3-opus-20240229',
};
const message: Anthropic.Message = await anthropic.messages.create(params);
const message: Anthropic.Message = await client.messages.create(params);
}

main();
Expand All @@ -95,7 +95,7 @@ a subclass of `APIError` will be thrown:
<!-- prettier-ignore -->
```ts
async function main() {
const message = await anthropic.messages
const message = await client.messages
.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand Down Expand Up @@ -144,7 +144,7 @@ const client = new Anthropic({
});

// Or, configure per-request:
await anthropic.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-opus-20240229' }, {
maxRetries: 5,
});
```
Expand All @@ -161,7 +161,7 @@ const client = new Anthropic({
});

// Override per-request:
await anthropic.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-opus-20240229' }, {
timeout: 5 * 1000,
});
```
Expand All @@ -183,7 +183,7 @@ import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();

const message = await anthropic.messages.create(
const message = await client.messages.create(
{
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand All @@ -205,7 +205,7 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
```ts
const client = new Anthropic();

const response = await anthropic.messages
const response = await client.messages
.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand All @@ -215,7 +215,7 @@ const response = await anthropic.messages
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: message, response: raw } = await anthropic.messages
const { data: message, response: raw } = await client.messages
.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand Down Expand Up @@ -327,7 +327,7 @@ const client = new Anthropic({
});

// Override per-request:
await anthropic.messages.create(
await client.messages.create(
{
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import Anthropic from '@anthropic-ai/sdk';
import { Response } from 'node-fetch';

const anthropic = new Anthropic({
const client = new Anthropic({
apiKey: 'my-anthropic-api-key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource completions', () => {
test('create: only required params', async () => {
const responsePromise = anthropic.completions.create({
const responsePromise = client.completions.create({
max_tokens_to_sample: 256,
model: 'string',
prompt: '\n\nHuman: Hello, world!\n\nAssistant:',
Expand All @@ -25,7 +25,7 @@ describe('resource completions', () => {
});

test('create: required and optional params', async () => {
const response = await anthropic.completions.create({
const response = await client.completions.create({
max_tokens_to_sample: 256,
model: 'string',
prompt: '\n\nHuman: Hello, world!\n\nAssistant:',
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import Anthropic from '@anthropic-ai/sdk';
import { Response } from 'node-fetch';

const anthropic = new Anthropic({
const client = new Anthropic({
apiKey: 'my-anthropic-api-key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource messages', () => {
test('create: only required params', async () => {
const responsePromise = anthropic.messages.create({
const responsePromise = client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, world' }],
model: 'claude-3-5-sonnet-20240620',
Expand All @@ -25,7 +25,7 @@ describe('resource messages', () => {
});

test('create: required and optional params', async () => {
const response = await anthropic.messages.create({
const response = await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, world' }],
model: 'claude-3-5-sonnet-20240620',
Expand Down