diff --git a/src/core.ts b/src/core.ts index deea9aae..e0b05bc0 100644 --- a/src/core.ts +++ b/src/core.ts @@ -564,27 +564,6 @@ export abstract class APIClient { } } -export class APIResource { - protected client: APIClient; - constructor(client: APIClient) { - this.client = client; - - this.get = client.get.bind(client); - this.post = client.post.bind(client); - this.patch = client.patch.bind(client); - this.put = client.put.bind(client); - this.delete = client.delete.bind(client); - this.getAPIList = client.getAPIList.bind(client); - } - - protected get: APIClient['get']; - protected post: APIClient['post']; - protected patch: APIClient['patch']; - protected put: APIClient['put']; - protected delete: APIClient['delete']; - protected getAPIList: APIClient['getAPIList']; -} - export type PageInfo = { url: URL } | { params: Record<string, unknown> | null }; export abstract class AbstractPage<Item> implements AsyncIterable<Item> { diff --git a/src/resource.ts b/src/resource.ts index 420a1305..a9322ff1 100644 --- a/src/resource.ts +++ b/src/resource.ts @@ -3,22 +3,9 @@ import type { Anthropic } from './index'; export class APIResource { - protected client: Anthropic; - constructor(client: Anthropic) { - this.client = client; + protected _client: Anthropic; - this.get = client.get.bind(client); - this.post = client.post.bind(client); - this.patch = client.patch.bind(client); - this.put = client.put.bind(client); - this.delete = client.delete.bind(client); - this.getAPIList = client.getAPIList.bind(client); + constructor(client: Anthropic) { + this._client = client; } - - protected get: Anthropic['get']; - protected post: Anthropic['post']; - protected patch: Anthropic['patch']; - protected put: Anthropic['put']; - protected delete: Anthropic['delete']; - protected getAPIList: Anthropic['getAPIList']; } diff --git a/src/resources/completions.ts b/src/resources/completions.ts index dfc6d563..e10c4155 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -23,9 +23,12 @@ export class Completions extends APIResource { body: CompletionCreateParams, options?: Core.RequestOptions, ): APIPromise<Completion> | APIPromise<Stream<Completion>> { - return this.post('/v1/complete', { body, timeout: 600000, ...options, stream: body.stream ?? false }) as - | APIPromise<Completion> - | APIPromise<Stream<Completion>>; + return this._client.post('/v1/complete', { + body, + timeout: 600000, + ...options, + stream: body.stream ?? false, + }) as APIPromise<Completion> | APIPromise<Stream<Completion>>; } }