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(tests): limit array example length #611

Merged
merged 1 commit into from
Nov 18, 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
196 changes: 6 additions & 190 deletions tests/api-resources/beta/messages/batches.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@ describe('resource batches', () => {
model: 'claude-3-5-sonnet-20241022',
},
},
{
custom_id: 'my-custom-id-1',
params: {
max_tokens: 1024,
messages: [{ content: 'Hello, world', role: 'user' }],
model: 'claude-3-5-sonnet-20241022',
},
},
{
custom_id: 'my-custom-id-1',
params: {
max_tokens: 1024,
messages: [{ content: 'Hello, world', role: 'user' }],
model: 'claude-3-5-sonnet-20241022',
},
},
],
});
const rawResponse = await responsePromise.asResponse();
Expand All @@ -57,143 +41,7 @@ describe('resource batches', () => {
messages: [{ content: 'Hello, world', role: 'user' }],
model: 'claude-3-5-sonnet-20241022',
metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
stop_sequences: ['string', 'string', 'string'],
stream: true,
system: [
{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } },
],
temperature: 1,
tool_choice: { type: 'auto', disable_parallel_tool_use: true },
tools: [
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: {
description: 'Unit for the output - one of (celsius, fahrenheit)',
type: 'string',
},
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: {
description: 'Unit for the output - one of (celsius, fahrenheit)',
type: 'string',
},
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: {
description: 'Unit for the output - one of (celsius, fahrenheit)',
type: 'string',
},
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
],
top_k: 5,
top_p: 0.7,
},
},
{
custom_id: 'my-custom-id-1',
params: {
max_tokens: 1024,
messages: [{ content: 'Hello, world', role: 'user' }],
model: 'claude-3-5-sonnet-20241022',
metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
stop_sequences: ['string', 'string', 'string'],
stream: true,
system: [
{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } },
],
temperature: 1,
tool_choice: { type: 'auto', disable_parallel_tool_use: true },
tools: [
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: {
description: 'Unit for the output - one of (celsius, fahrenheit)',
type: 'string',
},
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: {
description: 'Unit for the output - one of (celsius, fahrenheit)',
type: 'string',
},
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: {
description: 'Unit for the output - one of (celsius, fahrenheit)',
type: 'string',
},
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
],
top_k: 5,
top_p: 0.7,
},
},
{
custom_id: 'my-custom-id-1',
params: {
max_tokens: 1024,
messages: [{ content: 'Hello, world', role: 'user' }],
model: 'claude-3-5-sonnet-20241022',
metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
stop_sequences: ['string', 'string', 'string'],
stop_sequences: ['string'],
stream: true,
system: [
{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } },
Expand All @@ -217,45 +65,13 @@ describe('resource batches', () => {
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: {
description: 'Unit for the output - one of (celsius, fahrenheit)',
type: 'string',
},
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: {
description: 'Unit for the output - one of (celsius, fahrenheit)',
type: 'string',
},
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
],
top_k: 5,
top_p: 0.7,
},
},
],
betas: ['string', 'string', 'string'],
betas: ['string'],
});
});

Expand All @@ -282,7 +98,7 @@ describe('resource batches', () => {
await expect(
client.beta.messages.batches.retrieve(
'message_batch_id',
{ betas: ['string', 'string', 'string'] },
{ betas: ['string'] },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Anthropic.NotFoundError);
Expand Down Expand Up @@ -310,7 +126,7 @@ describe('resource batches', () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
client.beta.messages.batches.list(
{ after_id: 'after_id', before_id: 'before_id', limit: 1, betas: ['string', 'string', 'string'] },
{ after_id: 'after_id', before_id: 'before_id', limit: 1, betas: ['string'] },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Anthropic.NotFoundError);
Expand Down Expand Up @@ -339,7 +155,7 @@ describe('resource batches', () => {
await expect(
client.beta.messages.batches.cancel(
'message_batch_id',
{ betas: ['string', 'string', 'string'] },
{ betas: ['string'] },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Anthropic.NotFoundError);
Expand All @@ -357,7 +173,7 @@ describe('resource batches', () => {
await expect(
client.beta.messages.batches.results(
'message_batch_id',
{ betas: ['string', 'string', 'string'] },
{ betas: ['string'] },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Anthropic.NotFoundError);
Expand Down
70 changes: 5 additions & 65 deletions tests/api-resources/beta/messages/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('resource messages', () => {
messages: [{ content: 'Hello, world', role: 'user' }],
model: 'claude-3-5-sonnet-20241022',
metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
stop_sequences: ['string', 'string', 'string'],
stop_sequences: ['string'],
stream: false,
system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
temperature: 1,
Expand All @@ -49,46 +49,16 @@ describe('resource messages', () => {
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: { description: 'Unit for the output - one of (celsius, fahrenheit)', type: 'string' },
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: { description: 'Unit for the output - one of (celsius, fahrenheit)', type: 'string' },
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
],
top_k: 5,
top_p: 0.7,
betas: ['string', 'string', 'string'],
betas: ['string'],
});
});

test('countTokens: only required params', async () => {
const responsePromise = client.beta.messages.countTokens({
messages: [
{ content: 'string', role: 'user' },
{ content: 'string', role: 'user' },
{ content: 'string', role: 'user' },
],
messages: [{ content: 'string', role: 'user' }],
model: 'string',
});
const rawResponse = await responsePromise.asResponse();
Expand All @@ -102,11 +72,7 @@ describe('resource messages', () => {

test('countTokens: required and optional params', async () => {
const response = await client.beta.messages.countTokens({
messages: [
{ content: 'string', role: 'user' },
{ content: 'string', role: 'user' },
{ content: 'string', role: 'user' },
],
messages: [{ content: 'string', role: 'user' }],
model: 'string',
system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
tool_choice: { type: 'auto', disable_parallel_tool_use: true },
Expand All @@ -124,34 +90,8 @@ describe('resource messages', () => {
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: { description: 'Unit for the output - one of (celsius, fahrenheit)', type: 'string' },
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
{
input_schema: {
type: 'object',
properties: {
location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
unit: { description: 'Unit for the output - one of (celsius, fahrenheit)', type: 'string' },
},
},
name: 'x',
cache_control: { type: 'ephemeral' },
description: 'Get the current weather in a given location',
type: 'custom',
},
],
betas: ['string', 'string', 'string'],
betas: ['string'],
});
});
});
Loading