Skip to content

Commit

Permalink
docs: update examples to show claude-2.1 (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Dec 19, 2023
1 parent 94a4fda commit 975b4d4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const anthropic = new Anthropic({

async function main() {
const completion = await anthropic.completions.create({
model: 'claude-2',
model: 'claude-2.1',
max_tokens_to_sample: 300,
prompt: `${Anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court?${Anthropic.AI_PROMPT}`,
});
Expand All @@ -123,7 +123,7 @@ const anthropic = new Anthropic();

const stream = await anthropic.completions.create({
prompt: `${Anthropic.HUMAN_PROMPT} Your prompt here${Anthropic.AI_PROMPT}`,
model: 'claude-2',
model: 'claude-2.1',
stream: true,
max_tokens_to_sample: 300,
});
Expand All @@ -150,7 +150,7 @@ async function main() {
const params: Anthropic.CompletionCreateParams = {
prompt: `${Anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court?${Anthropic.AI_PROMPT}`,
max_tokens_to_sample: 300,
model: 'claude-2',
model: 'claude-2.1',
};
const completion: Anthropic.Completion = await anthropic.completions.create(params);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ async function main() {
.create({
prompt: `${Anthropic.HUMAN_PROMPT} Your prompt here${Anthropic.AI_PROMPT}`,
max_tokens_to_sample: 300,
model: 'claude-2',
model: 'claude-2.1',
})
.catch((err) => {
if (err instanceof Anthropic.APIError) {
Expand Down Expand Up @@ -227,7 +227,7 @@ await anthropic.completions.create(
{
prompt: `${Anthropic.HUMAN_PROMPT} Can you help me effectively ask for a raise at work?${Anthropic.AI_PROMPT}`,
max_tokens_to_sample: 300,
model: 'claude-2',
model: 'claude-2.1',
},
{
maxRetries: 5,
Expand All @@ -251,7 +251,7 @@ await anthropic.completions.create(
{
prompt: `${Anthropic.HUMAN_PROMPT} Where can I get a good coffee in my neighbourhood?${Anthropic.AI_PROMPT}`,
max_tokens_to_sample: 300,
model: 'claude-2',
model: 'claude-2.1',
},
{
timeout: 5 * 1000,
Expand Down Expand Up @@ -279,7 +279,7 @@ const anthropic = new Anthropic();
const completion = await anthropic.completions.create(
{
max_tokens_to_sample: 300,
model: 'claude-2',
model: 'claude-2.1',
prompt: `${Anthropic.HUMAN_PROMPT} Where can I get a good coffee in my neighbourhood?${Anthropic.AI_PROMPT}`,
},
{ headers: { 'anthropic-version': 'My-Custom-Value' } },
Expand All @@ -301,7 +301,7 @@ const response = await anthropic.completions
.create({
prompt: `${Anthropic.HUMAN_PROMPT} Can you help me effectively ask for a raise at work?${Anthropic.AI_PROMPT}`,
max_tokens_to_sample: 300,
model: 'claude-2',
model: 'claude-2.1',
})
.asResponse();
console.log(response.headers.get('X-My-Header'));
Expand Down Expand Up @@ -373,7 +373,7 @@ await anthropic.completions.create(
{
prompt: `${Anthropic.HUMAN_PROMPT} How does a court case get to the Supreme Court?${Anthropic.AI_PROMPT}`,
max_tokens_to_sample: 300,
model: 'claude-2',
model: 'claude-2.1',
},
{
baseURL: 'http://localhost:8080/test-api',
Expand Down
2 changes: 1 addition & 1 deletion examples/cancellation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function main() {

const stream = await client.completions.create({
prompt: `${Anthropic.HUMAN_PROMPT}${question}${Anthropic.AI_PROMPT}:`,
model: 'claude-2',
model: 'claude-2.1',
stream: true,
max_tokens_to_sample: 500,
});
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const client = new Anthropic(); // gets API Key from environment variable ANTHRO
async function main() {
const result = await client.completions.create({
prompt: `${Anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court? ${Anthropic.AI_PROMPT}`,
model: 'claude-2',
model: 'claude-2.1',
max_tokens_to_sample: 300,
});
console.log(result.completion);
Expand Down
2 changes: 1 addition & 1 deletion examples/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function main() {

const stream = await client.completions.create({
prompt: `${Anthropic.HUMAN_PROMPT}${question}${Anthropic.AI_PROMPT}:`,
model: 'claude-2',
model: 'claude-2.1',
stream: true,
max_tokens_to_sample: 500,
});
Expand Down
4 changes: 2 additions & 2 deletions src/resources/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export interface CompletionCreateParamsBase {
* As we improve Claude, we develop new versions of it that you can query. This
* parameter controls which version of Claude answers your request. Right now we
* are offering two model families: Claude, and Claude Instant. You can use them by
* setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
* setting `model` to `"claude-2.1"` or `"claude-instant-1"`, respectively. See
* [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
* additional details.
*/
model: (string & {}) | 'claude-2' | 'claude-instant-1';
model: (string & {}) | 'claude-2.1' | 'claude-instant-1';

/**
* The prompt that you want Claude to complete.
Expand Down
4 changes: 2 additions & 2 deletions tests/api-resources/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('resource completions', () => {
test('create: only required params', async () => {
const responsePromise = anthropic.completions.create({
max_tokens_to_sample: 256,
model: 'claude-2',
model: 'claude-2.1',
prompt: '\n\nHuman: Hello, world!\n\nAssistant:',
});
const rawResponse = await responsePromise.asResponse();
Expand All @@ -27,7 +27,7 @@ describe('resource completions', () => {
test('create: required and optional params', async () => {
const response = await anthropic.completions.create({
max_tokens_to_sample: 256,
model: 'claude-2',
model: 'claude-2.1',
prompt: '\n\nHuman: Hello, world!\n\nAssistant:',
metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
stop_sequences: ['string', 'string', 'string'],
Expand Down

0 comments on commit 975b4d4

Please sign in to comment.