From 29c08f6c4126aa2a576aea5cbc0d16b033a9a04e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 15:47:51 +0000 Subject: [PATCH 01/49] docs(readme): fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 202f7bc2..681426e0 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ async function main() { main(); ``` -Error codes are as followed: +Error codes are as follows: | Status Code | Error Type | | ----------- | -------------------------- | From 328ac079658f878a74a28c3683e340bed6f15876 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 19:21:14 +0000 Subject: [PATCH 02/49] chore(ci): bump node version for release workflows --- .github/workflows/ci.yml | 2 +- .github/workflows/publish-npm.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3210fc7..f48e532c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: - name: Set up Node uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '20' - name: Bootstrap run: ./scripts/bootstrap diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 905d21e6..397cf896 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Node uses: actions/setup-node@v3 with: - node-version: '18' + node-version: '20' - name: Install dependencies run: | From e3bdd286bdca4d56cae2b106f15283f594b05200 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 22:25:06 +0000 Subject: [PATCH 03/49] docs: add examples to tsdocs --- src/index.ts | 14 ++++++++ src/resources/audio.ts | 12 +++++++ src/resources/chat/completions.ts | 10 ++++++ .../code-interpreter/code-interpreter.ts | 9 +++++ src/resources/code-interpreter/sessions.ts | 6 ++++ src/resources/completions.ts | 9 +++++ src/resources/embeddings.ts | 9 +++++ src/resources/endpoints.ts | 35 +++++++++++++++++++ src/resources/images.ts | 8 +++++ src/resources/jobs.ts | 12 +++++++ src/resources/models.ts | 13 +++++++ 11 files changed, 137 insertions(+) diff --git a/src/index.ts b/src/index.ts index 8613bac0..a62cf689 100644 --- a/src/index.ts +++ b/src/index.ts @@ -184,6 +184,20 @@ export class Together extends Core.APIClient { /** * Query a reranker model + * + * @example + * ```ts + * const response = await client.rerank({ + * documents: [ + * { title: 'bar', text: 'bar' }, + * { title: 'bar', text: 'bar' }, + * { title: 'bar', text: 'bar' }, + * { title: 'bar', text: 'bar' }, + * ], + * model: 'Salesforce/Llama-Rank-V1', + * query: 'What animals can I find near Peru?', + * }); + * ``` */ rerank( body: TopLevelAPI.RerankParams, diff --git a/src/resources/audio.ts b/src/resources/audio.ts index fe4081d0..c6e02890 100644 --- a/src/resources/audio.ts +++ b/src/resources/audio.ts @@ -7,6 +7,18 @@ import { type Response } from '../_shims/index'; export class Audio extends APIResource { /** * Generate audio from input text + * + * @example + * ```ts + * const audio = await client.audio.create({ + * input: 'input', + * model: 'cartesia/sonic', + * voice: 'laidback woman', + * }); + * + * const content = await audio.blob(); + * console.log(content); + * ``` */ create(body: AudioCreateParams, options?: Core.RequestOptions): Core.APIPromise { return this._client.post('/audio/speech', { diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 97706839..520981a1 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -11,6 +11,16 @@ import { ChatCompletionStream, ChatCompletionStreamParams } from 'together-ai/li export class Completions extends APIResource { /** * Query a chat model. + * + * @example + * ```ts + * const chatCompletion = await client.chat.completions.create( + * { + * messages: [{ content: 'string', role: 'system' }], + * model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo', + * }, + * ); + * ``` */ create(body: CompletionCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise; create( diff --git a/src/resources/code-interpreter/code-interpreter.ts b/src/resources/code-interpreter/code-interpreter.ts index 98892eba..21c924f1 100644 --- a/src/resources/code-interpreter/code-interpreter.ts +++ b/src/resources/code-interpreter/code-interpreter.ts @@ -14,6 +14,15 @@ export class CodeInterpreter extends APIResource { * session_id, the code will be run in that session. This is useful for running * multiple code snippets in the same environment, because dependencies and similar * things are persisted between calls to the same session. + * + * @example + * ```ts + * const executeResponse = + * await client.codeInterpreter.execute({ + * code: "print('Hello, world!')", + * language: 'python', + * }); + * ``` */ execute( body: CodeInterpreterExecuteParams, diff --git a/src/resources/code-interpreter/sessions.ts b/src/resources/code-interpreter/sessions.ts index 2da55eb2..ea891a8c 100644 --- a/src/resources/code-interpreter/sessions.ts +++ b/src/resources/code-interpreter/sessions.ts @@ -6,6 +6,12 @@ import * as Core from '../../core'; export class Sessions extends APIResource { /** * Lists all your currently active sessions. + * + * @example + * ```ts + * const sessionListResponse = + * await client.codeInterpreter.sessions.list(); + * ``` */ list(options?: Core.RequestOptions): Core.APIPromise { return this._client.get('/tci/sessions', options); diff --git a/src/resources/completions.ts b/src/resources/completions.ts index 5fa01f1e..d48df359 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -10,6 +10,15 @@ import { Stream } from '../streaming'; export class Completions extends APIResource { /** * Query a language, code, or image model. + * + * @example + * ```ts + * const completion = await client.completions.create({ + * model: 'mistralai/Mixtral-8x7B-Instruct-v0.1', + * prompt: + * '[INST] What is the capital of France? [/INST]', + * }); + * ``` */ create(body: CompletionCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise; create( diff --git a/src/resources/embeddings.ts b/src/resources/embeddings.ts index 5dfeba14..1d7a05d1 100644 --- a/src/resources/embeddings.ts +++ b/src/resources/embeddings.ts @@ -6,6 +6,15 @@ import * as Core from '../core'; export class Embeddings extends APIResource { /** * Query an embedding model for a given string of text. + * + * @example + * ```ts + * const embedding = await client.embeddings.create({ + * input: + * 'Our solar system orbits the Milky Way galaxy at about 515,000 mph', + * model: 'togethercomputer/m2-bert-80M-8k-retrieval', + * }); + * ``` */ create(body: EmbeddingCreateParams, options?: Core.RequestOptions): Core.APIPromise { return this._client.post('/embeddings', { body, ...options }); diff --git a/src/resources/endpoints.ts b/src/resources/endpoints.ts index 1d34cb25..a75a5007 100644 --- a/src/resources/endpoints.ts +++ b/src/resources/endpoints.ts @@ -9,6 +9,15 @@ export class Endpoints extends APIResource { * Creates a new dedicated endpoint for serving models. The endpoint will * automatically start after creation. You can deploy any supported model on * hardware configurations that meet the model's requirements. + * + * @example + * ```ts + * const endpoint = await client.endpoints.create({ + * autoscaling: { max_replicas: 5, min_replicas: 2 }, + * hardware: '1x_nvidia_a100_80gb_sxm', + * model: 'meta-llama/Llama-3-8b-chat-hf', + * }); + * ``` */ create(body: EndpointCreateParams, options?: Core.RequestOptions): Core.APIPromise { return this._client.post('/endpoints', { body, ...options }); @@ -17,6 +26,13 @@ export class Endpoints extends APIResource { /** * Retrieves details about a specific endpoint, including its current state, * configuration, and scaling settings. + * + * @example + * ```ts + * const endpoint = await client.endpoints.retrieve( + * 'endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7', + * ); + * ``` */ retrieve(endpointId: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.get(`/endpoints/${endpointId}`, options); @@ -25,6 +41,13 @@ export class Endpoints extends APIResource { /** * Updates an existing endpoint's configuration. You can modify the display name, * autoscaling settings, or change the endpoint's state (start/stop). + * + * @example + * ```ts + * const endpoint = await client.endpoints.update( + * 'endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7', + * ); + * ``` */ update( endpointId: string, @@ -37,6 +60,11 @@ export class Endpoints extends APIResource { /** * Returns a list of all endpoints associated with your account. You can filter the * results by type (dedicated or serverless). + * + * @example + * ```ts + * const endpoints = await client.endpoints.list(); + * ``` */ list(query?: EndpointListParams, options?: Core.RequestOptions): Core.APIPromise; list(options?: Core.RequestOptions): Core.APIPromise; @@ -52,6 +80,13 @@ export class Endpoints extends APIResource { /** * Permanently deletes an endpoint. This action cannot be undone. + * + * @example + * ```ts + * await client.endpoints.delete( + * 'endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7', + * ); + * ``` */ delete(endpointId: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.delete(`/endpoints/${endpointId}`, { diff --git a/src/resources/images.ts b/src/resources/images.ts index fec1f5db..10156bbc 100644 --- a/src/resources/images.ts +++ b/src/resources/images.ts @@ -6,6 +6,14 @@ import * as Core from '../core'; export class Images extends APIResource { /** * Use an image model to generate an image for a given prompt. + * + * @example + * ```ts + * const imageFile = await client.images.create({ + * model: 'black-forest-labs/FLUX.1-schnell', + * prompt: 'cat floating in space, cinematic', + * }); + * ``` */ create(body: ImageCreateParams, options?: Core.RequestOptions): Core.APIPromise { return this._client.post('/images/generations', { body, ...options }); diff --git a/src/resources/jobs.ts b/src/resources/jobs.ts index 089afa0d..59041ecd 100644 --- a/src/resources/jobs.ts +++ b/src/resources/jobs.ts @@ -6,6 +6,13 @@ import * as Core from '../core'; export class Jobs extends APIResource { /** * Get the status of a specific job + * + * @example + * ```ts + * const job = await client.jobs.retrieve( + * 'job-a15dad11-8d8e-4007-97c5-a211304de284', + * ); + * ``` */ retrieve(jobId: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.get(`/jobs/${jobId}`, options); @@ -13,6 +20,11 @@ export class Jobs extends APIResource { /** * List all jobs and their statuses + * + * @example + * ```ts + * const jobs = await client.jobs.list(); + * ``` */ list(options?: Core.RequestOptions): Core.APIPromise { return this._client.get('/jobs', options); diff --git a/src/resources/models.ts b/src/resources/models.ts index 22cddb00..d5b072b7 100644 --- a/src/resources/models.ts +++ b/src/resources/models.ts @@ -6,6 +6,11 @@ import * as Core from '../core'; export class Models extends APIResource { /** * Lists all of Together's open-source models + * + * @example + * ```ts + * const models = await client.models.list(); + * ``` */ list(options?: Core.RequestOptions): Core.APIPromise { return this._client.get('/models', options); @@ -13,6 +18,14 @@ export class Models extends APIResource { /** * Upload a custom model from Hugging Face or S3 + * + * @example + * ```ts + * const response = await client.models.upload({ + * model_name: 'Qwen2.5-72B-Instruct', + * model_source: 'unsloth/Qwen2.5-72B-Instruct', + * }); + * ``` */ upload(body: ModelUploadParams, options?: Core.RequestOptions): Core.APIPromise { return this._client.post('/models', { body, ...options }); From a9c3c25d03a04be8511fc19675ebfb5411b2caa0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 15:57:28 +0000 Subject: [PATCH 04/49] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d9d1b62f..2e28bdeb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-c949fc43297a5155ea4c433179ee6f0822e25a351f180a5539871687daead7ad.yml -openapi_spec_hash: ca24d10b37e987becfd16b30ea342459 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-a394c35a9793ff79ae86d19a45d61f0f8c9610a2af53cc52c278f0e2de1b0d98.yml +openapi_spec_hash: 0c6e548bcaa02bc3d8061967ef21ddfd config_hash: a60b100624e80dc8d9144e7bc306f5ce From 51be0d085ad52f80bc16fa8c9cbdefb74d5364ad Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 13 May 2025 10:29:28 +0000 Subject: [PATCH 05/49] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2e28bdeb..48c8a183 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-a394c35a9793ff79ae86d19a45d61f0f8c9610a2af53cc52c278f0e2de1b0d98.yml -openapi_spec_hash: 0c6e548bcaa02bc3d8061967ef21ddfd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-df8486ebc1de1915a1611890eb571e387e1dac284df20962d10be37aa8855ce6.yml +openapi_spec_hash: 499837ed4588ccbb5426ea3c1f0a4179 config_hash: a60b100624e80dc8d9144e7bc306f5ce From 418cdbf1c267c33e2f01e4b3d48aa21c6a618268 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 13 May 2025 19:33:00 +0000 Subject: [PATCH 06/49] feat(api): api update --- .stats.yml | 4 ++-- src/resources/models.ts | 19 ++++++++++++++++++- tests/api-resources/models.test.ts | 3 +++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 48c8a183..03c953a6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-df8486ebc1de1915a1611890eb571e387e1dac284df20962d10be37aa8855ce6.yml -openapi_spec_hash: 499837ed4588ccbb5426ea3c1f0a4179 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-8f50cb3e342f2fd67f1f2cfda195b3d78c0740344f55f37cf1c99c66a0f7c2c5.yml +openapi_spec_hash: b9907745f73f337395ffd5cef1e8a2d5 config_hash: a60b100624e80dc8d9144e7bc306f5ce diff --git a/src/resources/models.ts b/src/resources/models.ts index d5b072b7..33747007 100644 --- a/src/resources/models.ts +++ b/src/resources/models.ts @@ -17,7 +17,7 @@ export class Models extends APIResource { } /** - * Upload a custom model from Hugging Face or S3 + * Upload a custom model or adapter from Hugging Face or S3 * * @example * ```ts @@ -101,6 +101,12 @@ export interface ModelUploadParams { */ model_source: string; + /** + * The base model to use for an adapter if setting it to run against a serverless + * pool. Only used for model_type `adapter`. + */ + base_model?: string; + /** * A description of your model */ @@ -110,6 +116,17 @@ export interface ModelUploadParams { * Hugging Face token (if uploading from Hugging Face) */ hf_token?: string; + + /** + * The lora pool to use for an adapter if setting it to run against, say, a + * dedicated pool. Only used for model_type `adapter`. + */ + lora_model?: string; + + /** + * Whether the model is a full model or an adapter + */ + model_type?: 'model' | 'adapter'; } export declare namespace Models { diff --git a/tests/api-resources/models.test.ts b/tests/api-resources/models.test.ts index 6ab7002e..0d31114c 100644 --- a/tests/api-resources/models.test.ts +++ b/tests/api-resources/models.test.ts @@ -45,8 +45,11 @@ describe('resource models', () => { const response = await client.models.upload({ model_name: 'Qwen2.5-72B-Instruct', model_source: 'unsloth/Qwen2.5-72B-Instruct', + base_model: 'Qwen/Qwen2.5-72B-Instruct', description: 'Finetuned Qwen2.5-72B-Instruct by Unsloth', hf_token: 'hf_examplehuggingfacetoken', + lora_model: 'my_username/Qwen2.5-72B-Instruct-lora', + model_type: 'model', }); }); }); From 5c9c32aefb20cb5af7b2a97acf1608832acf3c01 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 14 May 2025 02:27:03 +0000 Subject: [PATCH 07/49] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 03c953a6..a0678870 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-8f50cb3e342f2fd67f1f2cfda195b3d78c0740344f55f37cf1c99c66a0f7c2c5.yml -openapi_spec_hash: b9907745f73f337395ffd5cef1e8a2d5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-ce2216bb1eec9b836bb36c4b6a700b824c7e409b9188b6575ea8a3254b49bf25.yml +openapi_spec_hash: 5eb004279bd48b34e32192d83fd92214 config_hash: a60b100624e80dc8d9144e7bc306f5ce From dac80cc60458d89fced596b22a3700be3d7a6c04 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 14 May 2025 21:36:36 +0000 Subject: [PATCH 08/49] feat(api): api update --- .stats.yml | 4 ++-- src/resources/fine-tune.ts | 16 ++++++++++++++-- tests/api-resources/fine-tune.test.ts | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index a0678870..57b6a185 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-ce2216bb1eec9b836bb36c4b6a700b824c7e409b9188b6575ea8a3254b49bf25.yml -openapi_spec_hash: 5eb004279bd48b34e32192d83fd92214 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-3d6ba63951e80bd93c271b1803dc529a8e4e8d8872a0f597cabc1551a90c2e44.yml +openapi_spec_hash: 87058bf8524b40e430c14ddbc1a7d94f config_hash: a60b100624e80dc8d9144e7bc306f5ce diff --git a/src/resources/fine-tune.ts b/src/resources/fine-tune.ts index af75a091..6fac409d 100644 --- a/src/resources/fine-tune.ts +++ b/src/resources/fine-tune.ts @@ -214,6 +214,12 @@ export namespace FineTune { export interface TrainingMethodSft { method: 'sft'; + + /** + * Whether to mask the user messages in conversational data or prompts in + * instruction data. + */ + train_on_inputs: boolean | 'auto'; } export interface TrainingMethodDpo { @@ -381,8 +387,8 @@ export interface FineTuneCreateParams { suffix?: string; /** - * Whether to mask the user messages in conversational data or prompts in - * instruction data. + * @deprecated Whether to mask the user messages in conversational data or prompts + * in instruction data. */ train_on_inputs?: boolean | 'auto'; @@ -466,6 +472,12 @@ export namespace FineTuneCreateParams { export interface TrainingMethodSft { method: 'sft'; + + /** + * Whether to mask the user messages in conversational data or prompts in + * instruction data. + */ + train_on_inputs: boolean | 'auto'; } export interface TrainingMethodDpo { diff --git a/tests/api-resources/fine-tune.test.ts b/tests/api-resources/fine-tune.test.ts index 3b44953b..cf3c0ce5 100644 --- a/tests/api-resources/fine-tune.test.ts +++ b/tests/api-resources/fine-tune.test.ts @@ -36,7 +36,7 @@ describe('resource fineTune', () => { n_evals: 0, suffix: 'suffix', train_on_inputs: true, - training_method: { method: 'sft' }, + training_method: { method: 'sft', train_on_inputs: true }, training_type: { type: 'Full' }, validation_file: 'validation_file', wandb_api_key: 'wandb_api_key', From a149f12a4ed7d852aef5448c827d86bbebe2ebf4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:12:11 +0000 Subject: [PATCH 09/49] feat(api): api update --- .stats.yml | 4 +- src/resources/chat/completions.ts | 86 +++++++++++++------- src/resources/chat/index.ts | 2 - tests/api-resources/chat/completions.test.ts | 4 +- 4 files changed, 62 insertions(+), 34 deletions(-) diff --git a/.stats.yml b/.stats.yml index 57b6a185..77e5c5ce 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-3d6ba63951e80bd93c271b1803dc529a8e4e8d8872a0f597cabc1551a90c2e44.yml -openapi_spec_hash: 87058bf8524b40e430c14ddbc1a7d94f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-c6e6dcd8ce01b0a968c343e0e3ec4d2aed526942ddc7c4f579044da6fdf460ec.yml +openapi_spec_hash: 1ddbbad47d9cf85715279efbefd54199 config_hash: a60b100624e80dc8d9144e7bc306f5ce diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 520981a1..f72adbf8 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -16,7 +16,7 @@ export class Completions extends APIResource { * ```ts * const chatCompletion = await client.chat.completions.create( * { - * messages: [{ content: 'string', role: 'system' }], + * messages: [{ content: 'content', role: 'system' }], * model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo', * }, * ); @@ -277,7 +277,13 @@ export interface CompletionCreateParamsBase { /** * A list of messages comprising the conversation so far. */ - messages: Array; + messages: Array< + | CompletionCreateParams.ChatCompletionSystemMessageParam + | CompletionCreateParams.ChatCompletionUserMessageParam + | CompletionCreateParams.ChatCompletionAssistantMessageParam + | CompletionCreateParams.ChatCompletionToolMessageParam + | CompletionCreateParams.ChatCompletionFunctionMessageParam + >; /** * The name of the model to query. @@ -424,41 +430,65 @@ export interface CompletionCreateParamsBase { } export namespace CompletionCreateParams { - export interface Message { + export interface ChatCompletionSystemMessageParam { + content: string; + + role: 'system'; + + name?: string; + } + + export interface ChatCompletionUserMessageParam { + content: string; + + role: 'user'; + + name?: string; + } + + export interface ChatCompletionAssistantMessageParam { + role: 'assistant'; + + content?: string | null; + /** - * The content of the message, which can either be a simple string or a structured - * format. + * @deprecated */ - content: - | string - | Array< - | ChatCompletionsAPI.ChatCompletionStructuredMessageText - | ChatCompletionsAPI.ChatCompletionStructuredMessageImageURL - | Message.Video - >; + function_call?: ChatCompletionAssistantMessageParam.FunctionCall; + + name?: string; + + tool_calls?: Array; + } + export namespace ChatCompletionAssistantMessageParam { /** - * The role of the messages author. Choice between: system, user, assistant, or - * tool. + * @deprecated */ - role: 'system' | 'user' | 'assistant' | 'tool'; + export interface FunctionCall { + arguments: string; + + name: string; + } } - export namespace Message { - export interface Video { - type: 'video_url'; + export interface ChatCompletionToolMessageParam { + content: string; - video_url: Video.VideoURL; - } + role: 'tool'; - export namespace Video { - export interface VideoURL { - /** - * The URL of the video - */ - url: string; - } - } + tool_call_id: string; + } + + /** + * @deprecated + */ + export interface ChatCompletionFunctionMessageParam { + content: string; + + name: string; + + role: 'function'; } export interface Name { diff --git a/src/resources/chat/index.ts b/src/resources/chat/index.ts index 2f80d745..7746499e 100644 --- a/src/resources/chat/index.ts +++ b/src/resources/chat/index.ts @@ -13,8 +13,6 @@ export { Completions, type ChatCompletion, type ChatCompletionChunk, - type ChatCompletionStructuredMessageImageURL, - type ChatCompletionStructuredMessageText, type ChatCompletionUsage, type CompletionCreateParams, type CompletionCreateParamsNonStreaming, diff --git a/tests/api-resources/chat/completions.test.ts b/tests/api-resources/chat/completions.test.ts index 9fa755e4..becf93c7 100644 --- a/tests/api-resources/chat/completions.test.ts +++ b/tests/api-resources/chat/completions.test.ts @@ -11,7 +11,7 @@ const client = new Together({ describe('resource completions', () => { test('create: only required params', async () => { const responsePromise = client.chat.completions.create({ - messages: [{ content: 'string', role: 'system' }], + messages: [{ content: 'content', role: 'system' }], model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo', }); const rawResponse = await responsePromise.asResponse(); @@ -25,7 +25,7 @@ describe('resource completions', () => { test('create: required and optional params', async () => { const response = await client.chat.completions.create({ - messages: [{ content: 'string', role: 'system' }], + messages: [{ content: 'content', role: 'system', name: 'name' }], model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo', context_length_exceeded_behavior: 'truncate', echo: true, From ac5a26e7a65e66e3e7cdb3e83dbe75016c1f785f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:14:53 +0000 Subject: [PATCH 10/49] feat(api): Update spec and config to get all tests except code-interpolation an fine_tune unit tests working. --- .stats.yml | 6 +-- api.md | 3 ++ src/index.ts | 4 ++ src/resources/chat/chat.ts | 2 + src/resources/chat/completions.ts | 28 ++++++++++- src/resources/chat/index.ts | 3 ++ src/resources/completions.ts | 84 +++++++++++++++++++++++++++++-- src/resources/index.ts | 2 + 8 files changed, 124 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index 77e5c5ce..6ca35621 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-c6e6dcd8ce01b0a968c343e0e3ec4d2aed526942ddc7c4f579044da6fdf460ec.yml -openapi_spec_hash: 1ddbbad47d9cf85715279efbefd54199 -config_hash: a60b100624e80dc8d9144e7bc306f5ce +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-de05e6f42a3a47a4991fc9da45d0b5a6278f2a71035eccd7b153f1794f41ed4d.yml +openapi_spec_hash: 4c0171b827a94d18324992c13f988301 +config_hash: d4bca46fb622ce40d4644c6e95669fbe diff --git a/api.md b/api.md index 154059df..b28524a8 100644 --- a/api.md +++ b/api.md @@ -25,6 +25,7 @@ Types: - ChatCompletionToolMessageParam - ChatCompletionStructuredMessageImageURL - ChatCompletionStructuredMessageText +- ChatCompletionStructuredMessageVideoURL - ChatCompletionUsage - ChatCompletionUserMessageParam @@ -37,6 +38,8 @@ Methods: Types: - Completion +- CompletionChunk +- CompletionUsage - LogProbs - ToolChoice - Tools diff --git a/src/index.ts b/src/index.ts index a62cf689..584c6472 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,9 +10,11 @@ import { RerankParams, RerankResponse } from './resources/top-level'; import { Audio, AudioCreateParams, AudioFile } from './resources/audio'; import { Completion, + CompletionChunk, CompletionCreateParams, CompletionCreateParamsNonStreaming, CompletionCreateParamsStreaming, + CompletionUsage, Completions, LogProbs, ToolChoice, @@ -264,6 +266,8 @@ export declare namespace Together { export { Completions as Completions, type Completion as Completion, + type CompletionChunk as CompletionChunk, + type CompletionUsage as CompletionUsage, type LogProbs as LogProbs, type ToolChoice as ToolChoice, type Tools as Tools, diff --git a/src/resources/chat/chat.ts b/src/resources/chat/chat.ts index 0dd8f8d3..9f6c30f4 100644 --- a/src/resources/chat/chat.ts +++ b/src/resources/chat/chat.ts @@ -14,6 +14,7 @@ import { ChatCompletionToolMessageParam, ChatCompletionStructuredMessageImageURL, ChatCompletionStructuredMessageText, + ChatCompletionStructuredMessageVideoURL, ChatCompletionUsage, ChatCompletionUserMessageParam, CompletionCreateParams, @@ -42,6 +43,7 @@ export declare namespace Chat { type ChatCompletionToolMessageParam as ChatCompletionToolMessageParam, type ChatCompletionStructuredMessageImageURL as ChatCompletionStructuredMessageImageURL, type ChatCompletionStructuredMessageText as ChatCompletionStructuredMessageText, + type ChatCompletionStructuredMessageVideoURL as ChatCompletionStructuredMessageVideoURL, type ChatCompletionUsage as ChatCompletionUsage, type ChatCompletionUserMessageParam as ChatCompletionUserMessageParam, type CompletionCreateParams as CompletionCreateParams, diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index f72adbf8..4491b91b 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -255,6 +255,21 @@ export interface ChatCompletionStructuredMessageText { type: 'text'; } +export interface ChatCompletionStructuredMessageVideoURL { + type: 'video_url'; + + video_url: ChatCompletionStructuredMessageVideoURL.VideoURL; +} + +export namespace ChatCompletionStructuredMessageVideoURL { + export interface VideoURL { + /** + * The URL of the video + */ + url: string; + } +} + export interface ChatCompletionUsage { completion_tokens: number; @@ -439,7 +454,17 @@ export namespace CompletionCreateParams { } export interface ChatCompletionUserMessageParam { - content: string; + /** + * The content of the message, which can either be a simple string or a structured + * format. + */ + content: + | string + | Array< + | ChatCompletionsAPI.ChatCompletionStructuredMessageText + | ChatCompletionsAPI.ChatCompletionStructuredMessageImageURL + | ChatCompletionsAPI.ChatCompletionStructuredMessageVideoURL + >; role: 'user'; @@ -545,6 +570,7 @@ export declare namespace Completions { type ChatCompletionToolMessageParam as ChatCompletionToolMessageParam, type ChatCompletionStructuredMessageImageURL as ChatCompletionStructuredMessageImageURL, type ChatCompletionStructuredMessageText as ChatCompletionStructuredMessageText, + type ChatCompletionStructuredMessageVideoURL as ChatCompletionStructuredMessageVideoURL, type ChatCompletionUsage as ChatCompletionUsage, type ChatCompletionUserMessageParam as ChatCompletionUserMessageParam, type CompletionCreateParams as CompletionCreateParams, diff --git a/src/resources/chat/index.ts b/src/resources/chat/index.ts index 7746499e..5d1ec3bd 100644 --- a/src/resources/chat/index.ts +++ b/src/resources/chat/index.ts @@ -13,6 +13,9 @@ export { Completions, type ChatCompletion, type ChatCompletionChunk, + type ChatCompletionStructuredMessageImageURL, + type ChatCompletionStructuredMessageText, + type ChatCompletionStructuredMessageVideoURL, type ChatCompletionUsage, type CompletionCreateParams, type CompletionCreateParamsNonStreaming, diff --git a/src/resources/completions.ts b/src/resources/completions.ts index d48df359..33bd0e6f 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -24,18 +24,18 @@ export class Completions extends APIResource { create( body: CompletionCreateParamsStreaming, options?: Core.RequestOptions, - ): APIPromise>; + ): APIPromise>; create( body: CompletionCreateParamsBase, options?: Core.RequestOptions, - ): APIPromise | Completion>; + ): APIPromise | Completion>; create( body: CompletionCreateParams, options?: Core.RequestOptions, - ): APIPromise | APIPromise> { + ): APIPromise | APIPromise> { return this._client.post('/completions', { body, ...options, stream: body.stream ?? false }) as | APIPromise - | APIPromise>; + | APIPromise>; } } @@ -73,6 +73,80 @@ export namespace Completion { } } +export interface CompletionChunk { + id: string; + + token: CompletionChunk.Token; + + choices: Array; + + finish_reason: 'stop' | 'eos' | 'length' | 'tool_calls' | 'function_call' | null; + + usage: ChatCompletionsAPI.ChatCompletionUsage | null; + + created?: number; + + object?: 'completion.chunk'; + + seed?: number; +} + +export namespace CompletionChunk { + export interface Token { + id: number; + + logprob: number; + + special: boolean; + + text: string; + } + + export interface Choice { + index: number; + + delta?: Choice.Delta; + + text?: string; + } + + export namespace Choice { + export interface Delta { + role: 'system' | 'user' | 'assistant' | 'function' | 'tool'; + + content?: string | null; + + /** + * @deprecated + */ + function_call?: Delta.FunctionCall | null; + + token_id?: number; + + tool_calls?: Array; + } + + export namespace Delta { + /** + * @deprecated + */ + export interface FunctionCall { + arguments: string; + + name: string; + } + } + } +} + +export interface CompletionUsage { + completion_tokens: number; + + prompt_tokens: number; + + total_tokens: number; +} + export interface LogProbs { /** * List of token IDs corresponding to the logprobs @@ -276,6 +350,8 @@ export interface CompletionCreateParamsStreaming extends CompletionCreateParamsB export declare namespace Completions { export { type Completion as Completion, + type CompletionChunk as CompletionChunk, + type CompletionUsage as CompletionUsage, type LogProbs as LogProbs, type ToolChoice as ToolChoice, type Tools as Tools, diff --git a/src/resources/index.ts b/src/resources/index.ts index a790daf5..503db9e5 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -10,6 +10,8 @@ export { export { Completions, type Completion, + type CompletionChunk, + type CompletionUsage, type LogProbs, type ToolChoice, type Tools, From 45cf024fd0348672e36d6053c259211afdc78e35 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 19:56:38 +0000 Subject: [PATCH 11/49] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6ca35621..8631ba00 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-de05e6f42a3a47a4991fc9da45d0b5a6278f2a71035eccd7b153f1794f41ed4d.yml -openapi_spec_hash: 4c0171b827a94d18324992c13f988301 +openapi_spec_hash: a3f02f213e595028458de144e0d6b613 config_hash: d4bca46fb622ce40d4644c6e95669fbe From d7b7e65ffab825567353d021f8ea1715a0e3b578 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 19:58:00 +0000 Subject: [PATCH 12/49] feat(api): api update --- .stats.yml | 4 ++-- src/resources/completions.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8631ba00..ce60c04d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-de05e6f42a3a47a4991fc9da45d0b5a6278f2a71035eccd7b153f1794f41ed4d.yml -openapi_spec_hash: a3f02f213e595028458de144e0d6b613 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-3a63c122f06568e998e910399377e7b8612f76e0723ab7b80984aed7121dffac.yml +openapi_spec_hash: 1cf4ffd590c946e5dd81819e672e7e16 config_hash: d4bca46fb622ce40d4644c6e95669fbe diff --git a/src/resources/completions.ts b/src/resources/completions.ts index 33bd0e6f..c6582f82 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -48,7 +48,7 @@ export interface Completion { model: string; - object: 'text_completion'; + object: 'text.completion'; usage: ChatCompletionsAPI.ChatCompletionUsage | null; From aaa785d85ed0c86c35ef110e5bc626234dd7fea9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 00:48:38 +0000 Subject: [PATCH 13/49] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ce60c04d..babd2eee 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-3a63c122f06568e998e910399377e7b8612f76e0723ab7b80984aed7121dffac.yml -openapi_spec_hash: 1cf4ffd590c946e5dd81819e672e7e16 +openapi_spec_hash: cc7a85cd4376d4e6d5fdd8f27bbf830c config_hash: d4bca46fb622ce40d4644c6e95669fbe From 426d647fa45c2220f7293f26c1b79336c0e948df Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 05:04:23 +0000 Subject: [PATCH 14/49] feat(api): get test_code_interpreter passing --- .stats.yml | 4 ++-- src/resources/code-interpreter/code-interpreter.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index babd2eee..bf4db7fe 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-3a63c122f06568e998e910399377e7b8612f76e0723ab7b80984aed7121dffac.yml -openapi_spec_hash: cc7a85cd4376d4e6d5fdd8f27bbf830c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-8f16354f22565f645bec7594335a85be0d24aa7c994d62274bbcfef837a01e6a.yml +openapi_spec_hash: c0834c1fcaf6cfaf505abbcc510a1fe5 config_hash: d4bca46fb622ce40d4644c6e95669fbe diff --git a/src/resources/code-interpreter/code-interpreter.ts b/src/resources/code-interpreter/code-interpreter.ts index 21c924f1..b346e220 100644 --- a/src/resources/code-interpreter/code-interpreter.ts +++ b/src/resources/code-interpreter/code-interpreter.ts @@ -54,6 +54,11 @@ export namespace ExecuteResponse { * Identifier of the current session. Used to make follow-up calls. */ session_id: string; + + /** + * Status of the execution. Currently only supports success. + */ + status?: 'success'; } export namespace Data { From d7d7c686ca1a2c665d58323bbc5498671c4ee5ef Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 11:08:38 +0000 Subject: [PATCH 15/49] feat(api): api update --- .stats.yml | 4 +- api.md | 6 +- src/index.ts | 4 + .../code-interpreter/code-interpreter.ts | 5 - src/resources/fine-tune.ts | 853 +++++++++++++++++- src/resources/index.ts | 2 + 6 files changed, 859 insertions(+), 15 deletions(-) diff --git a/.stats.yml b/.stats.yml index bf4db7fe..d9fadcdf 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-8f16354f22565f645bec7594335a85be0d24aa7c994d62274bbcfef837a01e6a.yml -openapi_spec_hash: c0834c1fcaf6cfaf505abbcc510a1fe5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-4423de93b4b42dd6538aeb5e75c2c2fb325cf12828494481f14893e90aba91df.yml +openapi_spec_hash: e5a5ebb14062ca04fead0952669fc07d config_hash: d4bca46fb622ce40d4644c6e95669fbe diff --git a/api.md b/api.md index b28524a8..4d375f56 100644 --- a/api.md +++ b/api.md @@ -80,15 +80,17 @@ Types: - FineTune - FineTuneEvent +- FineTuneCreateResponse - FineTuneListResponse +- FineTuneCancelResponse - FineTuneDownloadResponse Methods: -- client.fineTune.create({ ...params }) -> FineTune +- client.fineTune.create({ ...params }) -> FineTuneCreateResponse - client.fineTune.retrieve(id) -> FineTune - client.fineTune.list() -> FineTuneListResponse -- client.fineTune.cancel(id) -> FineTune +- client.fineTune.cancel(id) -> FineTuneCancelResponse - client.fineTune.download({ ...params }) -> FineTuneDownloadResponse - client.fineTune.listEvents(id) -> FineTuneEvent diff --git a/src/index.ts b/src/index.ts index 584c6472..ef88a90b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,7 +40,9 @@ import { } from './resources/files'; import { FineTune, + FineTuneCancelResponse, FineTuneCreateParams, + FineTuneCreateResponse, FineTuneDownloadParams, FineTuneDownloadResponse, FineTuneEvent, @@ -294,7 +296,9 @@ export declare namespace Together { FineTuneResource as FineTuneResource, type FineTune as FineTune, type FineTuneEvent as FineTuneEvent, + type FineTuneCreateResponse as FineTuneCreateResponse, type FineTuneListResponse as FineTuneListResponse, + type FineTuneCancelResponse as FineTuneCancelResponse, type FineTuneDownloadResponse as FineTuneDownloadResponse, type FineTuneCreateParams as FineTuneCreateParams, type FineTuneDownloadParams as FineTuneDownloadParams, diff --git a/src/resources/code-interpreter/code-interpreter.ts b/src/resources/code-interpreter/code-interpreter.ts index b346e220..21c924f1 100644 --- a/src/resources/code-interpreter/code-interpreter.ts +++ b/src/resources/code-interpreter/code-interpreter.ts @@ -54,11 +54,6 @@ export namespace ExecuteResponse { * Identifier of the current session. Used to make follow-up calls. */ session_id: string; - - /** - * Status of the execution. Currently only supports success. - */ - status?: 'success'; } export namespace Data { diff --git a/src/resources/fine-tune.ts b/src/resources/fine-tune.ts index 6fac409d..22f0f9ec 100644 --- a/src/resources/fine-tune.ts +++ b/src/resources/fine-tune.ts @@ -5,35 +5,67 @@ import * as Core from '../core'; export class FineTuneResource extends APIResource { /** - * Use a model to create a fine-tuning job. + * Create a fine-tuning job with the provided model and training data. + * + * @example + * ```ts + * const fineTune = await client.fineTune.create({ + * model: 'model', + * training_file: 'training_file', + * }); + * ``` */ - create(body: FineTuneCreateParams, options?: Core.RequestOptions): Core.APIPromise { + create(body: FineTuneCreateParams, options?: Core.RequestOptions): Core.APIPromise { return this._client.post('/fine-tunes', { body, ...options }); } /** * List the metadata for a single fine-tuning job. + * + * @example + * ```ts + * const fineTune = await client.fineTune.retrieve('id'); + * ``` */ retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.get(`/fine-tunes/${id}`, options); } /** - * List the metadata for all fine-tuning jobs. + * List the metadata for all fine-tuning jobs. Returns a list of + * FinetuneResponseTruncated objects. + * + * @example + * ```ts + * const fineTunes = await client.fineTune.list(); + * ``` */ list(options?: Core.RequestOptions): Core.APIPromise { return this._client.get('/fine-tunes', options); } /** - * Cancel a currently running fine-tuning job. + * Cancel a currently running fine-tuning job. Returns a FinetuneResponseTruncated + * object. + * + * @example + * ```ts + * const response = await client.fineTune.cancel('id'); + * ``` */ - cancel(id: string, options?: Core.RequestOptions): Core.APIPromise { + cancel(id: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.post(`/fine-tunes/${id}/cancel`, options); } /** * Download a compressed fine-tuned model or checkpoint to local disk. + * + * @example + * ```ts + * const response = await client.fineTune.download({ + * ft_id: 'ft_id', + * }); + * ``` */ download( query: FineTuneDownloadParams, @@ -44,6 +76,13 @@ export class FineTuneResource extends APIResource { /** * List the events for a single fine-tuning job. + * + * @example + * ```ts + * const fineTuneEvent = await client.fineTune.listEvents( + * 'id', + * ); + * ``` */ listEvents(id: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.get(`/fine-tunes/${id}/events`, options); @@ -306,8 +345,808 @@ export namespace FineTuneEvent { } } +/** + * A truncated version of the fine-tune response, used for POST /fine-tunes, GET + * /fine-tunes and POST /fine-tunes/{id}/cancel endpoints + */ +export interface FineTuneCreateResponse { + /** + * Unique identifier for the fine-tune job + */ + id: string; + + /** + * Creation timestamp of the fine-tune job + */ + created_at: string; + + status: + | 'pending' + | 'queued' + | 'running' + | 'compressing' + | 'uploading' + | 'cancel_requested' + | 'cancelled' + | 'error' + | 'completed'; + + /** + * Last update timestamp of the fine-tune job + */ + updated_at: string; + + /** + * Batch size used for training + */ + batch_size?: number; + + /** + * Events related to this fine-tune job + */ + events?: Array; + + /** + * Checkpoint used to continue training + */ + from_checkpoint?: string; + + /** + * Learning rate used for training + */ + learning_rate?: number; + + /** + * Learning rate scheduler configuration + */ + lr_scheduler?: FineTuneCreateResponse.LrScheduler; + + /** + * Maximum gradient norm for clipping + */ + max_grad_norm?: number; + + /** + * Base model used for fine-tuning + */ + model?: string; + + /** + * Number of checkpoints saved during training + */ + n_checkpoints?: number; + + /** + * Number of training epochs + */ + n_epochs?: number; + + /** + * Number of evaluations during training + */ + n_evals?: number; + + /** + * Owner address information + */ + owner_address?: string; + + /** + * Suffix added to the fine-tuned model name + */ + suffix?: string; + + /** + * Count of tokens processed + */ + token_count?: number; + + /** + * Total price for the fine-tuning job + */ + total_price?: number; + + /** + * File-ID of the training file + */ + training_file?: string; + + /** + * Method of training used + */ + training_method?: FineTuneCreateResponse.TrainingMethodSft | FineTuneCreateResponse.TrainingMethodDpo; + + /** + * Type of training used (full or LoRA) + */ + training_type?: FineTuneCreateResponse.FullTrainingType | FineTuneCreateResponse.LoRaTrainingType; + + /** + * Identifier for the user who created the job + */ + user_id?: string; + + /** + * File-ID of the validation file + */ + validation_file?: string; + + /** + * Weights & Biases run name + */ + wandb_name?: string; + + /** + * Weights & Biases project name + */ + wandb_project_name?: string; + + /** + * Ratio of warmup steps + */ + warmup_ratio?: number; + + /** + * Weight decay value used + */ + weight_decay?: number; +} + +export namespace FineTuneCreateResponse { + export interface Event { + checkpoint_path: string; + + created_at: string; + + hash: string; + + message: string; + + model_path: string; + + object: 'fine-tune-event'; + + param_count: number; + + step: number; + + token_count: number; + + total_steps: number; + + training_offset: number; + + type: + | 'job_pending' + | 'job_start' + | 'job_stopped' + | 'model_downloading' + | 'model_download_complete' + | 'training_data_downloading' + | 'training_data_download_complete' + | 'validation_data_downloading' + | 'validation_data_download_complete' + | 'wandb_init' + | 'training_start' + | 'checkpoint_save' + | 'billing_limit' + | 'epoch_complete' + | 'training_complete' + | 'model_compressing' + | 'model_compression_complete' + | 'model_uploading' + | 'model_upload_complete' + | 'job_complete' + | 'job_error' + | 'cancel_requested' + | 'job_restarted' + | 'refund' + | 'warning'; + + wandb_url: string; + + level?: 'info' | 'warning' | 'error' | 'legacy_info' | 'legacy_iwarning' | 'legacy_ierror' | null; + } + + /** + * Learning rate scheduler configuration + */ + export interface LrScheduler { + lr_scheduler_type: 'linear' | 'cosine'; + + lr_scheduler_args?: LrScheduler.LinearLrSchedulerArgs | LrScheduler.CosineLrSchedulerArgs; + } + + export namespace LrScheduler { + export interface LinearLrSchedulerArgs { + /** + * The ratio of the final learning rate to the peak learning rate + */ + min_lr_ratio?: number; + } + + export interface CosineLrSchedulerArgs { + /** + * The ratio of the final learning rate to the peak learning rate + */ + min_lr_ratio?: number; + + /** + * Number or fraction of cycles for the cosine learning rate scheduler + */ + num_cycles?: number; + } + } + + export interface TrainingMethodSft { + method: 'sft'; + + /** + * Whether to mask the user messages in conversational data or prompts in + * instruction data. + */ + train_on_inputs: boolean | 'auto'; + } + + export interface TrainingMethodDpo { + method: 'dpo'; + + dpo_beta?: number; + } + + export interface FullTrainingType { + type: 'Full'; + } + + export interface LoRaTrainingType { + lora_alpha: number; + + lora_r: number; + + type: 'Lora'; + + lora_dropout?: number; + + lora_trainable_modules?: string; + } +} + export interface FineTuneListResponse { - data: Array; + data: Array; +} + +export namespace FineTuneListResponse { + /** + * A truncated version of the fine-tune response, used for POST /fine-tunes, GET + * /fine-tunes and POST /fine-tunes/{id}/cancel endpoints + */ + export interface Data { + /** + * Unique identifier for the fine-tune job + */ + id: string; + + /** + * Creation timestamp of the fine-tune job + */ + created_at: string; + + status: + | 'pending' + | 'queued' + | 'running' + | 'compressing' + | 'uploading' + | 'cancel_requested' + | 'cancelled' + | 'error' + | 'completed'; + + /** + * Last update timestamp of the fine-tune job + */ + updated_at: string; + + /** + * Batch size used for training + */ + batch_size?: number; + + /** + * Events related to this fine-tune job + */ + events?: Array; + + /** + * Checkpoint used to continue training + */ + from_checkpoint?: string; + + /** + * Learning rate used for training + */ + learning_rate?: number; + + /** + * Learning rate scheduler configuration + */ + lr_scheduler?: Data.LrScheduler; + + /** + * Maximum gradient norm for clipping + */ + max_grad_norm?: number; + + /** + * Base model used for fine-tuning + */ + model?: string; + + /** + * Number of checkpoints saved during training + */ + n_checkpoints?: number; + + /** + * Number of training epochs + */ + n_epochs?: number; + + /** + * Number of evaluations during training + */ + n_evals?: number; + + /** + * Owner address information + */ + owner_address?: string; + + /** + * Suffix added to the fine-tuned model name + */ + suffix?: string; + + /** + * Count of tokens processed + */ + token_count?: number; + + /** + * Total price for the fine-tuning job + */ + total_price?: number; + + /** + * File-ID of the training file + */ + training_file?: string; + + /** + * Method of training used + */ + training_method?: Data.TrainingMethodSft | Data.TrainingMethodDpo; + + /** + * Type of training used (full or LoRA) + */ + training_type?: Data.FullTrainingType | Data.LoRaTrainingType; + + /** + * Identifier for the user who created the job + */ + user_id?: string; + + /** + * File-ID of the validation file + */ + validation_file?: string; + + /** + * Weights & Biases run name + */ + wandb_name?: string; + + /** + * Weights & Biases project name + */ + wandb_project_name?: string; + + /** + * Ratio of warmup steps + */ + warmup_ratio?: number; + + /** + * Weight decay value used + */ + weight_decay?: number; + } + + export namespace Data { + export interface Event { + checkpoint_path: string; + + created_at: string; + + hash: string; + + message: string; + + model_path: string; + + object: 'fine-tune-event'; + + param_count: number; + + step: number; + + token_count: number; + + total_steps: number; + + training_offset: number; + + type: + | 'job_pending' + | 'job_start' + | 'job_stopped' + | 'model_downloading' + | 'model_download_complete' + | 'training_data_downloading' + | 'training_data_download_complete' + | 'validation_data_downloading' + | 'validation_data_download_complete' + | 'wandb_init' + | 'training_start' + | 'checkpoint_save' + | 'billing_limit' + | 'epoch_complete' + | 'training_complete' + | 'model_compressing' + | 'model_compression_complete' + | 'model_uploading' + | 'model_upload_complete' + | 'job_complete' + | 'job_error' + | 'cancel_requested' + | 'job_restarted' + | 'refund' + | 'warning'; + + wandb_url: string; + + level?: 'info' | 'warning' | 'error' | 'legacy_info' | 'legacy_iwarning' | 'legacy_ierror' | null; + } + + /** + * Learning rate scheduler configuration + */ + export interface LrScheduler { + lr_scheduler_type: 'linear' | 'cosine'; + + lr_scheduler_args?: LrScheduler.LinearLrSchedulerArgs | LrScheduler.CosineLrSchedulerArgs; + } + + export namespace LrScheduler { + export interface LinearLrSchedulerArgs { + /** + * The ratio of the final learning rate to the peak learning rate + */ + min_lr_ratio?: number; + } + + export interface CosineLrSchedulerArgs { + /** + * The ratio of the final learning rate to the peak learning rate + */ + min_lr_ratio?: number; + + /** + * Number or fraction of cycles for the cosine learning rate scheduler + */ + num_cycles?: number; + } + } + + export interface TrainingMethodSft { + method: 'sft'; + + /** + * Whether to mask the user messages in conversational data or prompts in + * instruction data. + */ + train_on_inputs: boolean | 'auto'; + } + + export interface TrainingMethodDpo { + method: 'dpo'; + + dpo_beta?: number; + } + + export interface FullTrainingType { + type: 'Full'; + } + + export interface LoRaTrainingType { + lora_alpha: number; + + lora_r: number; + + type: 'Lora'; + + lora_dropout?: number; + + lora_trainable_modules?: string; + } + } +} + +/** + * A truncated version of the fine-tune response, used for POST /fine-tunes, GET + * /fine-tunes and POST /fine-tunes/{id}/cancel endpoints + */ +export interface FineTuneCancelResponse { + /** + * Unique identifier for the fine-tune job + */ + id: string; + + /** + * Creation timestamp of the fine-tune job + */ + created_at: string; + + status: + | 'pending' + | 'queued' + | 'running' + | 'compressing' + | 'uploading' + | 'cancel_requested' + | 'cancelled' + | 'error' + | 'completed'; + + /** + * Last update timestamp of the fine-tune job + */ + updated_at: string; + + /** + * Batch size used for training + */ + batch_size?: number; + + /** + * Events related to this fine-tune job + */ + events?: Array; + + /** + * Checkpoint used to continue training + */ + from_checkpoint?: string; + + /** + * Learning rate used for training + */ + learning_rate?: number; + + /** + * Learning rate scheduler configuration + */ + lr_scheduler?: FineTuneCancelResponse.LrScheduler; + + /** + * Maximum gradient norm for clipping + */ + max_grad_norm?: number; + + /** + * Base model used for fine-tuning + */ + model?: string; + + /** + * Number of checkpoints saved during training + */ + n_checkpoints?: number; + + /** + * Number of training epochs + */ + n_epochs?: number; + + /** + * Number of evaluations during training + */ + n_evals?: number; + + /** + * Owner address information + */ + owner_address?: string; + + /** + * Suffix added to the fine-tuned model name + */ + suffix?: string; + + /** + * Count of tokens processed + */ + token_count?: number; + + /** + * Total price for the fine-tuning job + */ + total_price?: number; + + /** + * File-ID of the training file + */ + training_file?: string; + + /** + * Method of training used + */ + training_method?: FineTuneCancelResponse.TrainingMethodSft | FineTuneCancelResponse.TrainingMethodDpo; + + /** + * Type of training used (full or LoRA) + */ + training_type?: FineTuneCancelResponse.FullTrainingType | FineTuneCancelResponse.LoRaTrainingType; + + /** + * Identifier for the user who created the job + */ + user_id?: string; + + /** + * File-ID of the validation file + */ + validation_file?: string; + + /** + * Weights & Biases run name + */ + wandb_name?: string; + + /** + * Weights & Biases project name + */ + wandb_project_name?: string; + + /** + * Ratio of warmup steps + */ + warmup_ratio?: number; + + /** + * Weight decay value used + */ + weight_decay?: number; +} + +export namespace FineTuneCancelResponse { + export interface Event { + checkpoint_path: string; + + created_at: string; + + hash: string; + + message: string; + + model_path: string; + + object: 'fine-tune-event'; + + param_count: number; + + step: number; + + token_count: number; + + total_steps: number; + + training_offset: number; + + type: + | 'job_pending' + | 'job_start' + | 'job_stopped' + | 'model_downloading' + | 'model_download_complete' + | 'training_data_downloading' + | 'training_data_download_complete' + | 'validation_data_downloading' + | 'validation_data_download_complete' + | 'wandb_init' + | 'training_start' + | 'checkpoint_save' + | 'billing_limit' + | 'epoch_complete' + | 'training_complete' + | 'model_compressing' + | 'model_compression_complete' + | 'model_uploading' + | 'model_upload_complete' + | 'job_complete' + | 'job_error' + | 'cancel_requested' + | 'job_restarted' + | 'refund' + | 'warning'; + + wandb_url: string; + + level?: 'info' | 'warning' | 'error' | 'legacy_info' | 'legacy_iwarning' | 'legacy_ierror' | null; + } + + /** + * Learning rate scheduler configuration + */ + export interface LrScheduler { + lr_scheduler_type: 'linear' | 'cosine'; + + lr_scheduler_args?: LrScheduler.LinearLrSchedulerArgs | LrScheduler.CosineLrSchedulerArgs; + } + + export namespace LrScheduler { + export interface LinearLrSchedulerArgs { + /** + * The ratio of the final learning rate to the peak learning rate + */ + min_lr_ratio?: number; + } + + export interface CosineLrSchedulerArgs { + /** + * The ratio of the final learning rate to the peak learning rate + */ + min_lr_ratio?: number; + + /** + * Number or fraction of cycles for the cosine learning rate scheduler + */ + num_cycles?: number; + } + } + + export interface TrainingMethodSft { + method: 'sft'; + + /** + * Whether to mask the user messages in conversational data or prompts in + * instruction data. + */ + train_on_inputs: boolean | 'auto'; + } + + export interface TrainingMethodDpo { + method: 'dpo'; + + dpo_beta?: number; + } + + export interface FullTrainingType { + type: 'Full'; + } + + export interface LoRaTrainingType { + lora_alpha: number; + + lora_r: number; + + type: 'Lora'; + + lora_dropout?: number; + + lora_trainable_modules?: string; + } } export interface FineTuneDownloadResponse { @@ -532,7 +1371,9 @@ export declare namespace FineTuneResource { export { type FineTune as FineTune, type FineTuneEvent as FineTuneEvent, + type FineTuneCreateResponse as FineTuneCreateResponse, type FineTuneListResponse as FineTuneListResponse, + type FineTuneCancelResponse as FineTuneCancelResponse, type FineTuneDownloadResponse as FineTuneDownloadResponse, type FineTuneCreateParams as FineTuneCreateParams, type FineTuneDownloadParams as FineTuneDownloadParams, diff --git a/src/resources/index.ts b/src/resources/index.ts index 503db9e5..ee35adcc 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -41,7 +41,9 @@ export { FineTuneResource, type FineTune, type FineTuneEvent, + type FineTuneCreateResponse, type FineTuneListResponse, + type FineTuneCancelResponse, type FineTuneDownloadResponse, type FineTuneCreateParams, type FineTuneDownloadParams, From fcc89b0d13f7907fdb33ab23398ebae0003ec96e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 15:12:44 +0000 Subject: [PATCH 16/49] chore(docs): grammar improvements --- SECURITY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index c39aa7c8..5f4fe0ec 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -16,11 +16,11 @@ before making any information public. ## Reporting Non-SDK Related Security Issues If you encounter security issues that are not directly related to SDKs but pertain to the services -or products provided by Together please follow the respective company's security reporting guidelines. +or products provided by Together, please follow the respective company's security reporting guidelines. ### Together Terms and Policies -Please contact dev-feedback@TogetherAI.com for any questions or concerns regarding security of our services. +Please contact dev-feedback@TogetherAI.com for any questions or concerns regarding the security of our services. --- From 8de23078f5b12ace4df74173a0e5fa0c86528d2d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 18:22:19 +0000 Subject: [PATCH 17/49] feat(api): api update --- .stats.yml | 4 ++-- src/resources/code-interpreter/code-interpreter.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d9fadcdf..6b4718f5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-4423de93b4b42dd6538aeb5e75c2c2fb325cf12828494481f14893e90aba91df.yml -openapi_spec_hash: e5a5ebb14062ca04fead0952669fc07d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-8030aee8f9e213136e65e682cdff4ef8eacde5d1f03ab53f0f7290a9e45d95fa.yml +openapi_spec_hash: d949c29021bd1761eb4843f3773a89aa config_hash: d4bca46fb622ce40d4644c6e95669fbe diff --git a/src/resources/code-interpreter/code-interpreter.ts b/src/resources/code-interpreter/code-interpreter.ts index 21c924f1..b346e220 100644 --- a/src/resources/code-interpreter/code-interpreter.ts +++ b/src/resources/code-interpreter/code-interpreter.ts @@ -54,6 +54,11 @@ export namespace ExecuteResponse { * Identifier of the current session. Used to make follow-up calls. */ session_id: string; + + /** + * Status of the execution. Currently only supports success. + */ + status?: 'success'; } export namespace Data { From ba11056c22c6ce4ab829356d35a4c31540a2d5e1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 22:20:34 +0000 Subject: [PATCH 18/49] feat(api): Formatting fixes, some lint fixes --- .stats.yml | 6 +++--- src/resources/fine-tune.ts | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6b4718f5..a85e59e6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-8030aee8f9e213136e65e682cdff4ef8eacde5d1f03ab53f0f7290a9e45d95fa.yml -openapi_spec_hash: d949c29021bd1761eb4843f3773a89aa -config_hash: d4bca46fb622ce40d4644c6e95669fbe +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-488a32f6aacaed6f167950f2d6a678605cbf832cec24fa3f598e2de5675f885c.yml +openapi_spec_hash: 8045b2752f48aec9e18c1a30b1ad406e +config_hash: 6d6cbaca4113204abb7bde40d56a9155 diff --git a/src/resources/fine-tune.ts b/src/resources/fine-tune.ts index 22f0f9ec..52ac4545 100644 --- a/src/resources/fine-tune.ts +++ b/src/resources/fine-tune.ts @@ -411,6 +411,8 @@ export interface FineTuneCreateResponse { */ model?: string; + model_output_name?: string; + /** * Number of checkpoints saved during training */ @@ -682,6 +684,8 @@ export namespace FineTuneListResponse { */ model?: string; + model_output_name?: string; + /** * Number of checkpoints saved during training */ @@ -949,6 +953,8 @@ export interface FineTuneCancelResponse { */ model?: string; + model_output_name?: string; + /** * Number of checkpoints saved during training */ From 7419813733dfa46ef66d2c188e1c724b2b3caf73 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 22:32:54 +0000 Subject: [PATCH 19/49] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a85e59e6..738e3ebc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-488a32f6aacaed6f167950f2d6a678605cbf832cec24fa3f598e2de5675f885c.yml -openapi_spec_hash: 8045b2752f48aec9e18c1a30b1ad406e +openapi_spec_hash: a8a569c942dcaa9c3bbe620791a0e16f config_hash: 6d6cbaca4113204abb7bde40d56a9155 From ac1b626c9cfc9a419b121bd57a5c95afa57d6258 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 23:35:04 +0000 Subject: [PATCH 20/49] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 738e3ebc..39a62271 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-488a32f6aacaed6f167950f2d6a678605cbf832cec24fa3f598e2de5675f885c.yml -openapi_spec_hash: a8a569c942dcaa9c3bbe620791a0e16f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-18f6cfb8388e8ce0fc55a2b9cdff6d31996583c2e3dc4117e0731c540892f73c.yml +openapi_spec_hash: 0454263eea690fdc111c29a8f3271fff config_hash: 6d6cbaca4113204abb7bde40d56a9155 From ad49d5a8c2db1f4eb05a9fa288dfa1abc596bfed Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 23:42:25 +0000 Subject: [PATCH 21/49] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 39a62271..82ec4145 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-18f6cfb8388e8ce0fc55a2b9cdff6d31996583c2e3dc4117e0731c540892f73c.yml -openapi_spec_hash: 0454263eea690fdc111c29a8f3271fff +openapi_spec_hash: 79fa142537aa64a649ad4fa3fefb6a05 config_hash: 6d6cbaca4113204abb7bde40d56a9155 From c48b452006a360c32dc4c270740b3e7c8e5ea5b8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 24 May 2025 01:50:03 +0000 Subject: [PATCH 22/49] feat(api): Add file_type and file_purpose --- .stats.yml | 2 +- api.md | 2 ++ src/index.ts | 4 ++++ src/resources/files.ts | 15 +++++++++++---- src/resources/index.ts | 2 ++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index 82ec4145..277eb287 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-18f6cfb8388e8ce0fc55a2b9cdff6d31996583c2e3dc4117e0731c540892f73c.yml openapi_spec_hash: 79fa142537aa64a649ad4fa3fefb6a05 -config_hash: 6d6cbaca4113204abb7bde40d56a9155 +config_hash: aa5a206a5ce8c6ca0df597781076791e diff --git a/api.md b/api.md index 4d375f56..ff4da628 100644 --- a/api.md +++ b/api.md @@ -63,6 +63,8 @@ Methods: Types: - FileObject +- FilePurpose +- FileType - FileRetrieveResponse - FileListResponse - FileDeleteResponse diff --git a/src/index.ts b/src/index.ts index ef88a90b..1cae97d0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,7 +35,9 @@ import { FileDeleteResponse, FileListResponse, FileObject, + FilePurpose, FileRetrieveResponse, + FileType, Files, } from './resources/files'; import { @@ -287,6 +289,8 @@ export declare namespace Together { export { Files as Files, type FileObject as FileObject, + type FilePurpose as FilePurpose, + type FileType as FileType, type FileRetrieveResponse as FileRetrieveResponse, type FileListResponse as FileListResponse, type FileDeleteResponse as FileDeleteResponse, diff --git a/src/resources/files.ts b/src/resources/files.ts index f189dcbf..390f5013 100644 --- a/src/resources/files.ts +++ b/src/resources/files.ts @@ -2,6 +2,7 @@ import { APIResource } from '../resource'; import * as Core from '../core'; +import * as FilesAPI from './files'; import { type Response } from '../_shims/index'; export class Files extends APIResource { @@ -55,6 +56,10 @@ export interface FileObject { size?: number; } +export type FilePurpose = 'fine-tune'; + +export type FileType = 'jsonl' | 'parquet'; + export interface FileRetrieveResponse { id: string; @@ -64,7 +69,7 @@ export interface FileRetrieveResponse { filename: string; - FileType: 'jsonl' | 'parquet'; + FileType: FileType; LineCount: number; @@ -72,7 +77,7 @@ export interface FileRetrieveResponse { Processed: boolean; - purpose: 'fine-tune'; + purpose: FilePurpose; } export interface FileListResponse { @@ -89,7 +94,7 @@ export namespace FileListResponse { filename: string; - FileType: 'jsonl' | 'parquet'; + FileType: FilesAPI.FileType; LineCount: number; @@ -97,7 +102,7 @@ export namespace FileListResponse { Processed: boolean; - purpose: 'fine-tune'; + purpose: FilesAPI.FilePurpose; } } @@ -110,6 +115,8 @@ export interface FileDeleteResponse { export declare namespace Files { export { type FileObject as FileObject, + type FilePurpose as FilePurpose, + type FileType as FileType, type FileRetrieveResponse as FileRetrieveResponse, type FileListResponse as FileListResponse, type FileDeleteResponse as FileDeleteResponse, diff --git a/src/resources/index.ts b/src/resources/index.ts index ee35adcc..835517f8 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -33,6 +33,8 @@ export { export { Files, type FileObject, + type FilePurpose, + type FileType, type FileRetrieveResponse, type FileListResponse, type FileDeleteResponse, From 6efef6c02fb2160f1b1a0ac33d128e4b45bf7ef3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 27 May 2025 22:22:37 +0000 Subject: [PATCH 23/49] chore: improve publish-npm script --latest tag logic --- bin/publish-npm | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/bin/publish-npm b/bin/publish-npm index 4c21181b..2505deca 100644 --- a/bin/publish-npm +++ b/bin/publish-npm @@ -4,19 +4,35 @@ set -eux npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN" -# Build the project yarn build - -# Navigate to the dist directory cd dist -# Get the version from package.json +# Get latest version from npm +# +# If the package doesn't exist, yarn will return +# {"type":"error","data":"Received invalid response from npm."} +# where .data.version doesn't exist so LAST_VERSION will be an empty string. +LAST_VERSION="$(yarn info --json 2> /dev/null | jq -r '.data.version')" + +# Get current version from package.json VERSION="$(node -p "require('./package.json').version")" -# Extract the pre-release tag if it exists +# Check if current version is pre-release (e.g. alpha / beta / rc) +CURRENT_IS_PRERELEASE=false if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then - # Extract the part before any dot in the pre-release identifier - TAG="${BASH_REMATCH[1]}" + CURRENT_IS_PRERELEASE=true + CURRENT_TAG="${BASH_REMATCH[1]}" +fi + +# Check if last version is a stable release +LAST_IS_STABLE_RELEASE=true +if [[ -z "$LAST_VERSION" || "$LAST_VERSION" =~ -([a-zA-Z]+) ]]; then + LAST_IS_STABLE_RELEASE=false +fi + +# Use a corresponding alpha/beta tag if there already is a stable release and we're publishing a prerelease. +if $CURRENT_IS_PRERELEASE && $LAST_IS_STABLE_RELEASE; then + TAG="$CURRENT_TAG" else TAG="latest" fi From f06baab288f7f54d73ad803550b9f3ce55ab6756 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 17:27:00 +0000 Subject: [PATCH 24/49] feat(api): api update --- .stats.yml | 4 ++-- src/resources/files.ts | 31 ++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index 277eb287..df270006 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-18f6cfb8388e8ce0fc55a2b9cdff6d31996583c2e3dc4117e0731c540892f73c.yml -openapi_spec_hash: 79fa142537aa64a649ad4fa3fefb6a05 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-1f9f08d53431133ec18d6a143dc148cd9707b4481d434ea72268b85fa09ace96.yml +openapi_spec_hash: a81077b7c2b5e64a861efc0606e38c97 config_hash: aa5a206a5ce8c6ca0df597781076791e diff --git a/src/resources/files.ts b/src/resources/files.ts index 390f5013..44a56445 100644 --- a/src/resources/files.ts +++ b/src/resources/files.ts @@ -56,9 +56,22 @@ export interface FileObject { size?: number; } -export type FilePurpose = 'fine-tune'; - -export type FileType = 'jsonl' | 'parquet'; +/** + * The purpose of the file + */ +export type FilePurpose = + | 'fine-tune' + | 'eval' + | 'eval-sample' + | 'eval-output' + | 'eval-summary' + | 'batch-generated' + | 'batch-api'; + +/** + * The type of the file + */ +export type FileType = 'csv' | 'jsonl' | 'parquet'; export interface FileRetrieveResponse { id: string; @@ -69,6 +82,9 @@ export interface FileRetrieveResponse { filename: string; + /** + * The type of the file + */ FileType: FileType; LineCount: number; @@ -77,6 +93,9 @@ export interface FileRetrieveResponse { Processed: boolean; + /** + * The purpose of the file + */ purpose: FilePurpose; } @@ -94,6 +113,9 @@ export namespace FileListResponse { filename: string; + /** + * The type of the file + */ FileType: FilesAPI.FileType; LineCount: number; @@ -102,6 +124,9 @@ export namespace FileListResponse { Processed: boolean; + /** + * The purpose of the file + */ purpose: FilesAPI.FilePurpose; } } From c365c86033d20ef677e95707ccd4b3fe43c679a2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:16:57 +0000 Subject: [PATCH 25/49] feat(api): add files/upload apu support and switch upload_file method over to use it. --- .stats.yml | 6 +-- README.md | 50 +++++++++++++++++++++ api.md | 2 + src/index.ts | 4 ++ src/resources/files.ts | 73 +++++++++++++++++++++++++++++++ src/resources/index.ts | 2 + tests/api-resources/files.test.ts | 26 ++++++++++- 7 files changed, 159 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index df270006..7994808e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 28 +configured_endpoints: 29 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-1f9f08d53431133ec18d6a143dc148cd9707b4481d434ea72268b85fa09ace96.yml -openapi_spec_hash: a81077b7c2b5e64a861efc0606e38c97 -config_hash: aa5a206a5ce8c6ca0df597781076791e +openapi_spec_hash: 6d66a86c8d4ec97cb4d98b57a4238bc5 +config_hash: 9c8f0f59a53f8837c6406b493a0c3db7 diff --git a/README.md b/README.md index 681426e0..50e70e09 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,56 @@ main(); Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors. +## File uploads + +Request parameters that correspond to file uploads can be passed in many different forms: + +- `File` (or an object with the same structure) +- a `fetch` `Response` (or an object with the same structure) +- an `fs.ReadStream` +- the return value of our `toFile` helper + +```ts +import fs from 'fs'; +import fetch from 'node-fetch'; +import Together, { toFile } from 'together-ai'; + +const client = new Together(); + +// If you have access to Node `fs` we recommend using `fs.createReadStream()`: +await client.files.upload({ + file: fs.createReadStream('/path/to/file'), + file_name: 'dataset.csv', + purpose: 'fine-tune', +}); + +// Or if you have the web `File` API you can pass a `File` instance: +await client.files.upload({ + file: new File(['my bytes'], 'file'), + file_name: 'dataset.csv', + purpose: 'fine-tune', +}); + +// You can also pass a `fetch` `Response`: +await client.files.upload({ + file: await fetch('https://somesite/file'), + file_name: 'dataset.csv', + purpose: 'fine-tune', +}); + +// Finally, if none of the above are convenient, you can use our `toFile` helper: +await client.files.upload({ + file: await toFile(Buffer.from('my bytes'), 'file'), + file_name: 'dataset.csv', + purpose: 'fine-tune', +}); +await client.files.upload({ + file: await toFile(new Uint8Array([0, 1, 2]), 'file'), + file_name: 'dataset.csv', + purpose: 'fine-tune', +}); +``` + ## Handling errors When the library is unable to connect to the API, diff --git a/api.md b/api.md index ff4da628..17f12b4d 100644 --- a/api.md +++ b/api.md @@ -68,6 +68,7 @@ Types: - FileRetrieveResponse - FileListResponse - FileDeleteResponse +- FileUploadResponse Methods: @@ -75,6 +76,7 @@ Methods: - client.files.list() -> FileListResponse - client.files.delete(id) -> FileDeleteResponse - client.files.content(id) -> Response +- client.files.upload({ ...params }) -> FileUploadResponse # FineTune diff --git a/src/index.ts b/src/index.ts index 1cae97d0..f5515514 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,6 +38,8 @@ import { FilePurpose, FileRetrieveResponse, FileType, + FileUploadParams, + FileUploadResponse, Files, } from './resources/files'; import { @@ -294,6 +296,8 @@ export declare namespace Together { type FileRetrieveResponse as FileRetrieveResponse, type FileListResponse as FileListResponse, type FileDeleteResponse as FileDeleteResponse, + type FileUploadResponse as FileUploadResponse, + type FileUploadParams as FileUploadParams, }; export { diff --git a/src/resources/files.ts b/src/resources/files.ts index 44a56445..28a7357b 100644 --- a/src/resources/files.ts +++ b/src/resources/files.ts @@ -8,6 +8,11 @@ import { type Response } from '../_shims/index'; export class Files extends APIResource { /** * List the metadata for a single uploaded data file. + * + * @example + * ```ts + * const file = await client.files.retrieve('id'); + * ``` */ retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.get(`/files/${id}`, options); @@ -15,6 +20,11 @@ export class Files extends APIResource { /** * List the metadata for all uploaded data files. + * + * @example + * ```ts + * const files = await client.files.list(); + * ``` */ list(options?: Core.RequestOptions): Core.APIPromise { return this._client.get('/files', options); @@ -22,6 +32,11 @@ export class Files extends APIResource { /** * Delete a previously uploaded data file. + * + * @example + * ```ts + * const file = await client.files.delete('id'); + * ``` */ delete(id: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.delete(`/files/${id}`, options); @@ -29,6 +44,14 @@ export class Files extends APIResource { /** * Get the contents of a single uploaded data file. + * + * @example + * ```ts + * const response = await client.files.content('id'); + * + * const content = await response.blob(); + * console.log(content); + * ``` */ content(id: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.get(`/files/${id}/content`, { @@ -137,6 +160,54 @@ export interface FileDeleteResponse { deleted?: boolean; } +export interface FileUploadResponse { + id: string; + + bytes: number; + + created_at: number; + + filename: string; + + /** + * The type of the file + */ + FileType: FileType; + + LineCount: number; + + object: string; + + Processed: boolean; + + /** + * The purpose of the file + */ + purpose: FilePurpose; +} + +export interface FileUploadParams { + /** + * The content of the file being uploaded + */ + file: Core.Uploadable; + + /** + * The name of the file being uploaded + */ + file_name: string; + + /** + * The purpose of the file + */ + purpose: FilePurpose; + + /** + * The type of the file + */ + file_type?: FileType; +} + export declare namespace Files { export { type FileObject as FileObject, @@ -145,5 +216,7 @@ export declare namespace Files { type FileRetrieveResponse as FileRetrieveResponse, type FileListResponse as FileListResponse, type FileDeleteResponse as FileDeleteResponse, + type FileUploadResponse as FileUploadResponse, + type FileUploadParams as FileUploadParams, }; } diff --git a/src/resources/index.ts b/src/resources/index.ts index 835517f8..4366ebb3 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -38,6 +38,8 @@ export { type FileRetrieveResponse, type FileListResponse, type FileDeleteResponse, + type FileUploadResponse, + type FileUploadParams, } from './files'; export { FineTuneResource, diff --git a/tests/api-resources/files.test.ts b/tests/api-resources/files.test.ts index bfc9cf73..f1dade74 100644 --- a/tests/api-resources/files.test.ts +++ b/tests/api-resources/files.test.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import Together from 'together-ai'; +import Together, { toFile } from 'together-ai'; import { Response } from 'node-fetch'; const client = new Together({ @@ -69,4 +69,28 @@ describe('resource files', () => { Together.NotFoundError, ); }); + + test('upload: only required params', async () => { + const responsePromise = client.files.upload({ + file: await toFile(Buffer.from('# my file contents'), 'README.md'), + file_name: 'dataset.csv', + purpose: 'fine-tune', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('upload: required and optional params', async () => { + const response = await client.files.upload({ + file: await toFile(Buffer.from('# my file contents'), 'README.md'), + file_name: 'dataset.csv', + purpose: 'fine-tune', + file_type: 'jsonl', + }); + }); }); From 24e68333612469dcd5ec1bbd30993cb1d46ed61d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 20:06:53 +0000 Subject: [PATCH 26/49] chore(docs): use top-level-await in example snippets --- README.md | 60 ++++++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 50e70e09..16be6839 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,12 @@ const client = new Together({ apiKey: process.env['TOGETHER_API_KEY'], // This is the default and can be omitted }); -async function main() { - const chatCompletion = await client.chat.completions.create({ - messages: [{ role: 'user', content: 'Say this is a test!' }], - model: 'mistralai/Mixtral-8x7B-Instruct-v0.1', - }); - - console.log(chatCompletion.choices); -} +const chatCompletion = await client.chat.completions.create({ + messages: [{ role: 'user', content: 'Say this is a test!' }], + model: 'mistralai/Mixtral-8x7B-Instruct-v0.1', +}); -main(); +console.log(chatCompletion.choices); ``` ## Streaming responses @@ -72,15 +68,11 @@ const client = new Together({ apiKey: process.env['TOGETHER_API_KEY'], // This is the default and can be omitted }); -async function main() { - const params: Together.Chat.CompletionCreateParams = { - messages: [{ role: 'user', content: 'Say this is a test' }], - model: 'mistralai/Mixtral-8x7B-Instruct-v0.1', - }; - const chatCompletion: Together.Chat.ChatCompletion = await client.chat.completions.create(params); -} - -main(); +const params: Together.Chat.CompletionCreateParams = { + messages: [{ role: 'user', content: 'Say this is a test' }], + model: 'mistralai/Mixtral-8x7B-Instruct-v0.1', +}; +const chatCompletion: Together.Chat.ChatCompletion = await client.chat.completions.create(params); ``` Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors. @@ -143,24 +135,20 @@ a subclass of `APIError` will be thrown: ```ts -async function main() { - const chatCompletion = await client.chat.completions - .create({ - messages: [{ role: 'user', content: 'Say this is a test' }], - model: 'mistralai/Mixtral-8x7B-Instruct-v0.1', - }) - .catch(async (err) => { - if (err instanceof Together.APIError) { - console.log(err.status); // 400 - console.log(err.name); // BadRequestError - console.log(err.headers); // {server: 'nginx', ...} - } else { - throw err; - } - }); -} - -main(); +const chatCompletion = await client.chat.completions + .create({ + messages: [{ role: 'user', content: 'Say this is a test' }], + model: 'mistralai/Mixtral-8x7B-Instruct-v0.1', + }) + .catch(async (err) => { + if (err instanceof Together.APIError) { + console.log(err.status); // 400 + console.log(err.name); // BadRequestError + console.log(err.headers); // {server: 'nginx', ...} + } else { + throw err; + } + }); ``` Error codes are as follows: From 5d0865add14b040531018e85e59a38ee805a5a41 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:18:21 +0000 Subject: [PATCH 27/49] feat(api): api update --- .stats.yml | 4 +-- src/resources/chat/completions.ts | 44 ++++++++++++++++++++++++++++--- src/resources/chat/index.ts | 3 --- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7994808e..58cc1b50 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 29 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-1f9f08d53431133ec18d6a143dc148cd9707b4481d434ea72268b85fa09ace96.yml -openapi_spec_hash: 6d66a86c8d4ec97cb4d98b57a4238bc5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-2cc1d49fa13b7d4a5cd42cc7440c1d3ef74763891b077d2cc28a872a41abd61f.yml +openapi_spec_hash: fa4a4788ab2d4438ef691c4b9f32a914 config_hash: 9c8f0f59a53f8837c6406b493a0c3db7 diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 4491b91b..2c08a3d6 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -461,9 +461,9 @@ export namespace CompletionCreateParams { content: | string | Array< - | ChatCompletionsAPI.ChatCompletionStructuredMessageText - | ChatCompletionsAPI.ChatCompletionStructuredMessageImageURL - | ChatCompletionsAPI.ChatCompletionStructuredMessageVideoURL + | ChatCompletionUserMessageParam.UnionMember0 + | ChatCompletionUserMessageParam.UnionMember1 + | ChatCompletionUserMessageParam.Video >; role: 'user'; @@ -471,6 +471,44 @@ export namespace CompletionCreateParams { name?: string; } + export namespace ChatCompletionUserMessageParam { + export interface UnionMember0 { + text: string; + + type: 'text'; + } + + export interface UnionMember1 { + image_url?: UnionMember1.ImageURL; + + type?: 'image_url'; + } + + export namespace UnionMember1 { + export interface ImageURL { + /** + * The URL of the image + */ + url: string; + } + } + + export interface Video { + type: 'video_url'; + + video_url: Video.VideoURL; + } + + export namespace Video { + export interface VideoURL { + /** + * The URL of the video + */ + url: string; + } + } + } + export interface ChatCompletionAssistantMessageParam { role: 'assistant'; diff --git a/src/resources/chat/index.ts b/src/resources/chat/index.ts index 5d1ec3bd..7746499e 100644 --- a/src/resources/chat/index.ts +++ b/src/resources/chat/index.ts @@ -13,9 +13,6 @@ export { Completions, type ChatCompletion, type ChatCompletionChunk, - type ChatCompletionStructuredMessageImageURL, - type ChatCompletionStructuredMessageText, - type ChatCompletionStructuredMessageVideoURL, type ChatCompletionUsage, type CompletionCreateParams, type CompletionCreateParamsNonStreaming, From c7c3a914e2b0bb866b01ba48a04add83bbb387cd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:19:14 +0000 Subject: [PATCH 28/49] feat(api): update spec / config to remove remaining codegen warnings --- .stats.yml | 8 ++--- api.md | 3 +- src/index.ts | 4 +-- src/resources/chat/completions.ts | 44 ++------------------------- src/resources/chat/index.ts | 3 ++ src/resources/completions.ts | 9 ------ src/resources/fine-tune.ts | 34 +++++++++++++++++++++ src/resources/index.ts | 2 +- tests/api-resources/fine-tune.test.ts | 18 +++++++++++ 9 files changed, 67 insertions(+), 58 deletions(-) diff --git a/.stats.yml b/.stats.yml index 58cc1b50..82bdaf10 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 29 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-2cc1d49fa13b7d4a5cd42cc7440c1d3ef74763891b077d2cc28a872a41abd61f.yml -openapi_spec_hash: fa4a4788ab2d4438ef691c4b9f32a914 -config_hash: 9c8f0f59a53f8837c6406b493a0c3db7 +configured_endpoints: 30 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-48f3206278cd93af20d7d74aed1fd8e1513a04a60468505a40b0a15fbdab31a3.yml +openapi_spec_hash: 69c1236ff3815089881984840aa4d3f6 +config_hash: f39be209cf332e8d80f34099b178970a diff --git a/api.md b/api.md index 17f12b4d..4352dad3 100644 --- a/api.md +++ b/api.md @@ -39,7 +39,6 @@ Types: - Completion - CompletionChunk -- CompletionUsage - LogProbs - ToolChoice - Tools @@ -88,6 +87,7 @@ Types: - FineTuneListResponse - FineTuneCancelResponse - FineTuneDownloadResponse +- FineTuneRetrieveCheckpointsResponse Methods: @@ -97,6 +97,7 @@ Methods: - client.fineTune.cancel(id) -> FineTuneCancelResponse - client.fineTune.download({ ...params }) -> FineTuneDownloadResponse - client.fineTune.listEvents(id) -> FineTuneEvent +- client.fineTune.retrieveCheckpoints(id) -> FineTuneRetrieveCheckpointsResponse # CodeInterpreter diff --git a/src/index.ts b/src/index.ts index f5515514..5a63676e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,6 @@ import { CompletionCreateParams, CompletionCreateParamsNonStreaming, CompletionCreateParamsStreaming, - CompletionUsage, Completions, LogProbs, ToolChoice, @@ -52,6 +51,7 @@ import { FineTuneEvent, FineTuneListResponse, FineTuneResource, + FineTuneRetrieveCheckpointsResponse, } from './resources/fine-tune'; import { Hardware, HardwareListParams, HardwareListResponse } from './resources/hardware'; import { ImageCreateParams, ImageFile, Images } from './resources/images'; @@ -273,7 +273,6 @@ export declare namespace Together { Completions as Completions, type Completion as Completion, type CompletionChunk as CompletionChunk, - type CompletionUsage as CompletionUsage, type LogProbs as LogProbs, type ToolChoice as ToolChoice, type Tools as Tools, @@ -308,6 +307,7 @@ export declare namespace Together { type FineTuneListResponse as FineTuneListResponse, type FineTuneCancelResponse as FineTuneCancelResponse, type FineTuneDownloadResponse as FineTuneDownloadResponse, + type FineTuneRetrieveCheckpointsResponse as FineTuneRetrieveCheckpointsResponse, type FineTuneCreateParams as FineTuneCreateParams, type FineTuneDownloadParams as FineTuneDownloadParams, }; diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 2c08a3d6..4491b91b 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -461,9 +461,9 @@ export namespace CompletionCreateParams { content: | string | Array< - | ChatCompletionUserMessageParam.UnionMember0 - | ChatCompletionUserMessageParam.UnionMember1 - | ChatCompletionUserMessageParam.Video + | ChatCompletionsAPI.ChatCompletionStructuredMessageText + | ChatCompletionsAPI.ChatCompletionStructuredMessageImageURL + | ChatCompletionsAPI.ChatCompletionStructuredMessageVideoURL >; role: 'user'; @@ -471,44 +471,6 @@ export namespace CompletionCreateParams { name?: string; } - export namespace ChatCompletionUserMessageParam { - export interface UnionMember0 { - text: string; - - type: 'text'; - } - - export interface UnionMember1 { - image_url?: UnionMember1.ImageURL; - - type?: 'image_url'; - } - - export namespace UnionMember1 { - export interface ImageURL { - /** - * The URL of the image - */ - url: string; - } - } - - export interface Video { - type: 'video_url'; - - video_url: Video.VideoURL; - } - - export namespace Video { - export interface VideoURL { - /** - * The URL of the video - */ - url: string; - } - } - } - export interface ChatCompletionAssistantMessageParam { role: 'assistant'; diff --git a/src/resources/chat/index.ts b/src/resources/chat/index.ts index 7746499e..5d1ec3bd 100644 --- a/src/resources/chat/index.ts +++ b/src/resources/chat/index.ts @@ -13,6 +13,9 @@ export { Completions, type ChatCompletion, type ChatCompletionChunk, + type ChatCompletionStructuredMessageImageURL, + type ChatCompletionStructuredMessageText, + type ChatCompletionStructuredMessageVideoURL, type ChatCompletionUsage, type CompletionCreateParams, type CompletionCreateParamsNonStreaming, diff --git a/src/resources/completions.ts b/src/resources/completions.ts index c6582f82..d9ce23ec 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -139,14 +139,6 @@ export namespace CompletionChunk { } } -export interface CompletionUsage { - completion_tokens: number; - - prompt_tokens: number; - - total_tokens: number; -} - export interface LogProbs { /** * List of token IDs corresponding to the logprobs @@ -351,7 +343,6 @@ export declare namespace Completions { export { type Completion as Completion, type CompletionChunk as CompletionChunk, - type CompletionUsage as CompletionUsage, type LogProbs as LogProbs, type ToolChoice as ToolChoice, type Tools as Tools, diff --git a/src/resources/fine-tune.ts b/src/resources/fine-tune.ts index 52ac4545..6bf6cd48 100644 --- a/src/resources/fine-tune.ts +++ b/src/resources/fine-tune.ts @@ -87,6 +87,23 @@ export class FineTuneResource extends APIResource { listEvents(id: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.get(`/fine-tunes/${id}/events`, options); } + + /** + * List the checkpoints for a single fine-tuning job. + * + * @example + * ```ts + * const response = await client.fineTune.retrieveCheckpoints( + * 'id', + * ); + * ``` + */ + retrieveCheckpoints( + id: string, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.get(`/fine-tunes/${id}/checkpoints`, options); + } } export interface FineTune { @@ -1167,6 +1184,22 @@ export interface FineTuneDownloadResponse { size?: number; } +export interface FineTuneRetrieveCheckpointsResponse { + data: Array; +} + +export namespace FineTuneRetrieveCheckpointsResponse { + export interface Data { + checkpoint_type: string; + + created_at: string; + + path: string; + + step: number; + } +} + export interface FineTuneCreateParams { /** * Name of the base model to run fine-tune job on @@ -1381,6 +1414,7 @@ export declare namespace FineTuneResource { type FineTuneListResponse as FineTuneListResponse, type FineTuneCancelResponse as FineTuneCancelResponse, type FineTuneDownloadResponse as FineTuneDownloadResponse, + type FineTuneRetrieveCheckpointsResponse as FineTuneRetrieveCheckpointsResponse, type FineTuneCreateParams as FineTuneCreateParams, type FineTuneDownloadParams as FineTuneDownloadParams, }; diff --git a/src/resources/index.ts b/src/resources/index.ts index 4366ebb3..ed6d28ab 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -11,7 +11,6 @@ export { Completions, type Completion, type CompletionChunk, - type CompletionUsage, type LogProbs, type ToolChoice, type Tools, @@ -49,6 +48,7 @@ export { type FineTuneListResponse, type FineTuneCancelResponse, type FineTuneDownloadResponse, + type FineTuneRetrieveCheckpointsResponse, type FineTuneCreateParams, type FineTuneDownloadParams, } from './fine-tune'; diff --git a/tests/api-resources/fine-tune.test.ts b/tests/api-resources/fine-tune.test.ts index cf3c0ce5..85aae275 100644 --- a/tests/api-resources/fine-tune.test.ts +++ b/tests/api-resources/fine-tune.test.ts @@ -139,4 +139,22 @@ describe('resource fineTune', () => { Together.NotFoundError, ); }); + + test('retrieveCheckpoints', async () => { + const responsePromise = client.fineTune.retrieveCheckpoints('id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieveCheckpoints: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.fineTune.retrieveCheckpoints('id', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Together.NotFoundError); + }); }); From 26a5b65b48b4a20ac75cdc92b27c55e26b686382 Mon Sep 17 00:00:00 2001 From: David Meadows Date: Wed, 4 Jun 2025 10:22:27 -0400 Subject: [PATCH 29/49] fix(tests): remove unused tests --- tests/api-resources/files.test.ts | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/tests/api-resources/files.test.ts b/tests/api-resources/files.test.ts index f1dade74..26ada8af 100644 --- a/tests/api-resources/files.test.ts +++ b/tests/api-resources/files.test.ts @@ -69,28 +69,4 @@ describe('resource files', () => { Together.NotFoundError, ); }); - - test('upload: only required params', async () => { - const responsePromise = client.files.upload({ - file: await toFile(Buffer.from('# my file contents'), 'README.md'), - file_name: 'dataset.csv', - purpose: 'fine-tune', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('upload: required and optional params', async () => { - const response = await client.files.upload({ - file: await toFile(Buffer.from('# my file contents'), 'README.md'), - file_name: 'dataset.csv', - purpose: 'fine-tune', - file_type: 'jsonl', - }); - }); }); From 0ad22a67f73dce1d4d596c353a31be5abbd1e092 Mon Sep 17 00:00:00 2001 From: David Meadows Date: Wed, 4 Jun 2025 10:23:13 -0400 Subject: [PATCH 30/49] fix(tests): format --- tests/api-resources/files.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/api-resources/files.test.ts b/tests/api-resources/files.test.ts index 26ada8af..7bee1e8e 100644 --- a/tests/api-resources/files.test.ts +++ b/tests/api-resources/files.test.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import Together, { toFile } from 'together-ai'; import { Response } from 'node-fetch'; +import Together from 'together-ai'; const client = new Together({ apiKey: 'My API Key', From 9ab1b661c4d830b982e1e2a5a184564c9c16e815 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 00:29:32 +0000 Subject: [PATCH 31/49] feat(api): address diagnostic issues in audio api, correct openapi issue in images api, disambiguate a response in finetune api, enable automated testing on finetune and images --- .stats.yml | 6 +- api.md | 14 +- src/index.ts | 46 +- src/resources/audio.ts | 81 ++- src/resources/endpoints.ts | 111 +--- src/resources/fine-tune.ts | 708 +++++--------------------- src/resources/images.ts | 31 +- src/resources/index.ts | 26 +- tests/api-resources/audio.test.ts | 5 +- tests/api-resources/fine-tune.test.ts | 6 +- tests/api-resources/images.test.ts | 6 +- 11 files changed, 308 insertions(+), 732 deletions(-) diff --git a/.stats.yml b/.stats.yml index 82bdaf10..62fb35ad 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-48f3206278cd93af20d7d74aed1fd8e1513a04a60468505a40b0a15fbdab31a3.yml -openapi_spec_hash: 69c1236ff3815089881984840aa4d3f6 -config_hash: f39be209cf332e8d80f34099b178970a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-653a4aa26fdd2b335d1ead9c2ea0672cbe48a7616b76bf350a2421a8def4e08d.yml +openapi_spec_hash: b8a97aaff787274a4616d97a05b3a616 +config_hash: d15dd709dd3f87b0a8b83b00b4abc881 diff --git a/api.md b/api.md index 4352dad3..f5cb1e9d 100644 --- a/api.md +++ b/api.md @@ -81,12 +81,20 @@ Methods: Types: +- CosineLrSchedulerArgs - FineTune - FineTuneEvent +- FullTrainingType +- LinearLrSchedulerArgs +- LoRaTrainingType +- LrScheduler +- TrainingMethodDpo +- TrainingMethodSft - FineTuneCreateResponse - FineTuneListResponse - FineTuneCancelResponse - FineTuneDownloadResponse +- FineTuneListEventsResponse - FineTuneRetrieveCheckpointsResponse Methods: @@ -96,7 +104,7 @@ Methods: - client.fineTune.list() -> FineTuneListResponse - client.fineTune.cancel(id) -> FineTuneCancelResponse - client.fineTune.download({ ...params }) -> FineTuneDownloadResponse -- client.fineTune.listEvents(id) -> FineTuneEvent +- client.fineTune.listEvents(id) -> FineTuneListEventsResponse - client.fineTune.retrieveCheckpoints(id) -> FineTuneRetrieveCheckpointsResponse # CodeInterpreter @@ -123,6 +131,8 @@ Methods: Types: +- ImageDataB64 +- ImageDataURL - ImageFile Methods: @@ -134,6 +144,7 @@ Methods: Types: - AudioFile +- AudioSpeechStreamChunk Methods: @@ -167,6 +178,7 @@ Methods: Types: +- Autoscaling - EndpointCreateResponse - EndpointRetrieveResponse - EndpointUpdateResponse diff --git a/src/index.ts b/src/index.ts index 5a63676e..f5efc702 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,14 @@ import * as Uploads from './uploads'; import * as API from './resources/index'; import * as TopLevelAPI from './resources/top-level'; import { RerankParams, RerankResponse } from './resources/top-level'; -import { Audio, AudioCreateParams, AudioFile } from './resources/audio'; +import { + Audio, + AudioCreateParams, + AudioCreateParamsNonStreaming, + AudioCreateParamsStreaming, + AudioFile, + AudioSpeechStreamChunk, +} from './resources/audio'; import { Completion, CompletionChunk, @@ -21,6 +28,7 @@ import { } from './resources/completions'; import { Embedding, EmbeddingCreateParams, Embeddings } from './resources/embeddings'; import { + Autoscaling, EndpointCreateParams, EndpointCreateResponse, EndpointListParams, @@ -42,6 +50,7 @@ import { Files, } from './resources/files'; import { + CosineLrSchedulerArgs, FineTune, FineTuneCancelResponse, FineTuneCreateParams, @@ -49,12 +58,19 @@ import { FineTuneDownloadParams, FineTuneDownloadResponse, FineTuneEvent, + FineTuneListEventsResponse, FineTuneListResponse, FineTuneResource, FineTuneRetrieveCheckpointsResponse, + FullTrainingType, + LinearLrSchedulerArgs, + LoRaTrainingType, + LrScheduler, + TrainingMethodDpo, + TrainingMethodSft, } from './resources/fine-tune'; import { Hardware, HardwareListParams, HardwareListResponse } from './resources/hardware'; -import { ImageCreateParams, ImageFile, Images } from './resources/images'; +import { ImageCreateParams, ImageDataB64, ImageDataURL, ImageFile, Images } from './resources/images'; import { JobListResponse, JobRetrieveResponse, Jobs } from './resources/jobs'; import { ModelListResponse, ModelUploadParams, ModelUploadResponse, Models } from './resources/models'; import { Chat } from './resources/chat/chat'; @@ -301,12 +317,20 @@ export declare namespace Together { export { FineTuneResource as FineTuneResource, + type CosineLrSchedulerArgs as CosineLrSchedulerArgs, type FineTune as FineTune, type FineTuneEvent as FineTuneEvent, + type FullTrainingType as FullTrainingType, + type LinearLrSchedulerArgs as LinearLrSchedulerArgs, + type LoRaTrainingType as LoRaTrainingType, + type LrScheduler as LrScheduler, + type TrainingMethodDpo as TrainingMethodDpo, + type TrainingMethodSft as TrainingMethodSft, type FineTuneCreateResponse as FineTuneCreateResponse, type FineTuneListResponse as FineTuneListResponse, type FineTuneCancelResponse as FineTuneCancelResponse, type FineTuneDownloadResponse as FineTuneDownloadResponse, + type FineTuneListEventsResponse as FineTuneListEventsResponse, type FineTuneRetrieveCheckpointsResponse as FineTuneRetrieveCheckpointsResponse, type FineTuneCreateParams as FineTuneCreateParams, type FineTuneDownloadParams as FineTuneDownloadParams, @@ -318,9 +342,22 @@ export declare namespace Together { type CodeInterpreterExecuteParams as CodeInterpreterExecuteParams, }; - export { Images as Images, type ImageFile as ImageFile, type ImageCreateParams as ImageCreateParams }; + export { + Images as Images, + type ImageDataB64 as ImageDataB64, + type ImageDataURL as ImageDataURL, + type ImageFile as ImageFile, + type ImageCreateParams as ImageCreateParams, + }; - export { Audio as Audio, type AudioFile as AudioFile, type AudioCreateParams as AudioCreateParams }; + export { + Audio as Audio, + type AudioFile as AudioFile, + type AudioSpeechStreamChunk as AudioSpeechStreamChunk, + type AudioCreateParams as AudioCreateParams, + type AudioCreateParamsNonStreaming as AudioCreateParamsNonStreaming, + type AudioCreateParamsStreaming as AudioCreateParamsStreaming, + }; export { Models as Models, @@ -337,6 +374,7 @@ export declare namespace Together { export { Endpoints as Endpoints, + type Autoscaling as Autoscaling, type EndpointCreateResponse as EndpointCreateResponse, type EndpointRetrieveResponse as EndpointRetrieveResponse, type EndpointUpdateResponse as EndpointUpdateResponse, diff --git a/src/resources/audio.ts b/src/resources/audio.ts index c6e02890..d6e8b24b 100644 --- a/src/resources/audio.ts +++ b/src/resources/audio.ts @@ -1,7 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../resource'; +import { APIPromise } from '../core'; import * as Core from '../core'; +import * as AudioAPI from './audio'; +import { Stream } from '../streaming'; import { type Response } from '../_shims/index'; export class Audio extends APIResource { @@ -20,13 +23,26 @@ export class Audio extends APIResource { * console.log(content); * ``` */ - create(body: AudioCreateParams, options?: Core.RequestOptions): Core.APIPromise { + create(body: AudioCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise; + create( + body: AudioCreateParamsStreaming, + options?: Core.RequestOptions, + ): APIPromise>; + create( + body: AudioCreateParamsBase, + options?: Core.RequestOptions, + ): APIPromise | Response>; + create( + body: AudioCreateParams, + options?: Core.RequestOptions, + ): APIPromise | APIPromise> { return this._client.post('/audio/speech', { body, ...options, headers: { Accept: 'application/octet-stream', ...options?.headers }, + stream: body.stream ?? false, __binaryResponse: true, - }); + }) as APIPromise | APIPromise>; } } @@ -34,20 +50,7 @@ export type AudioFile = AudioFile.AudioSpeechStreamEvent | AudioFile.StreamSenti export namespace AudioFile { export interface AudioSpeechStreamEvent { - data: AudioSpeechStreamEvent.Data; - } - - export namespace AudioSpeechStreamEvent { - export interface Data { - /** - * base64 encoded audio stream - */ - b64: string; - - model: string; - - object: 'audio.tts.chunk'; - } + data: AudioAPI.AudioSpeechStreamChunk; } export interface StreamSentinel { @@ -55,7 +58,20 @@ export namespace AudioFile { } } -export interface AudioCreateParams { +export interface AudioSpeechStreamChunk { + /** + * base64 encoded audio stream + */ + b64: string; + + model: string; + + object: 'audio.tts.chunk'; +} + +export type AudioCreateParams = AudioCreateParamsNonStreaming | AudioCreateParamsStreaming; + +export interface AudioCreateParamsBase { /** * Input text to generate the audio for */ @@ -117,6 +133,35 @@ export interface AudioCreateParams { stream?: boolean; } +export namespace AudioCreateParams { + export type AudioCreateParamsNonStreaming = AudioAPI.AudioCreateParamsNonStreaming; + export type AudioCreateParamsStreaming = AudioAPI.AudioCreateParamsStreaming; +} + +export interface AudioCreateParamsNonStreaming extends AudioCreateParamsBase { + /** + * If true, output is streamed for several characters at a time instead of waiting + * for the full response. The stream terminates with `data: [DONE]`. If false, + * return the encoded audio as octet stream + */ + stream?: false; +} + +export interface AudioCreateParamsStreaming extends AudioCreateParamsBase { + /** + * If true, output is streamed for several characters at a time instead of waiting + * for the full response. The stream terminates with `data: [DONE]`. If false, + * return the encoded audio as octet stream + */ + stream: true; +} + export declare namespace Audio { - export { type AudioFile as AudioFile, type AudioCreateParams as AudioCreateParams }; + export { + type AudioFile as AudioFile, + type AudioSpeechStreamChunk as AudioSpeechStreamChunk, + type AudioCreateParams as AudioCreateParams, + type AudioCreateParamsNonStreaming as AudioCreateParamsNonStreaming, + type AudioCreateParamsStreaming as AudioCreateParamsStreaming, + }; } diff --git a/src/resources/endpoints.ts b/src/resources/endpoints.ts index a75a5007..1dee9bf1 100644 --- a/src/resources/endpoints.ts +++ b/src/resources/endpoints.ts @@ -96,6 +96,21 @@ export class Endpoints extends APIResource { } } +/** + * Configuration for automatic scaling of replicas based on demand. + */ +export interface Autoscaling { + /** + * The maximum number of replicas to scale up to under load + */ + max_replicas: number; + + /** + * The minimum number of replicas to maintain, even when there is no load + */ + min_replicas: number; +} + /** * Details about a dedicated endpoint deployment */ @@ -108,7 +123,7 @@ export interface EndpointCreateResponse { /** * Configuration for automatic scaling of the endpoint */ - autoscaling: EndpointCreateResponse.Autoscaling; + autoscaling: Autoscaling; /** * Timestamp when the endpoint was created @@ -156,23 +171,6 @@ export interface EndpointCreateResponse { type: 'dedicated'; } -export namespace EndpointCreateResponse { - /** - * Configuration for automatic scaling of the endpoint - */ - export interface Autoscaling { - /** - * The maximum number of replicas to scale up to under load - */ - max_replicas: number; - - /** - * The minimum number of replicas to maintain, even when there is no load - */ - min_replicas: number; - } -} - /** * Details about a dedicated endpoint deployment */ @@ -185,7 +183,7 @@ export interface EndpointRetrieveResponse { /** * Configuration for automatic scaling of the endpoint */ - autoscaling: EndpointRetrieveResponse.Autoscaling; + autoscaling: Autoscaling; /** * Timestamp when the endpoint was created @@ -233,23 +231,6 @@ export interface EndpointRetrieveResponse { type: 'dedicated'; } -export namespace EndpointRetrieveResponse { - /** - * Configuration for automatic scaling of the endpoint - */ - export interface Autoscaling { - /** - * The maximum number of replicas to scale up to under load - */ - max_replicas: number; - - /** - * The minimum number of replicas to maintain, even when there is no load - */ - min_replicas: number; - } -} - /** * Details about a dedicated endpoint deployment */ @@ -262,7 +243,7 @@ export interface EndpointUpdateResponse { /** * Configuration for automatic scaling of the endpoint */ - autoscaling: EndpointUpdateResponse.Autoscaling; + autoscaling: Autoscaling; /** * Timestamp when the endpoint was created @@ -310,23 +291,6 @@ export interface EndpointUpdateResponse { type: 'dedicated'; } -export namespace EndpointUpdateResponse { - /** - * Configuration for automatic scaling of the endpoint - */ - export interface Autoscaling { - /** - * The maximum number of replicas to scale up to under load - */ - max_replicas: number; - - /** - * The minimum number of replicas to maintain, even when there is no load - */ - min_replicas: number; - } -} - export interface EndpointListResponse { data: Array; @@ -384,7 +348,7 @@ export interface EndpointCreateParams { /** * Configuration for automatic scaling of the endpoint */ - autoscaling: EndpointCreateParams.Autoscaling; + autoscaling: Autoscaling; /** * The hardware configuration to use for this endpoint @@ -424,28 +388,11 @@ export interface EndpointCreateParams { state?: 'STARTED' | 'STOPPED'; } -export namespace EndpointCreateParams { - /** - * Configuration for automatic scaling of the endpoint - */ - export interface Autoscaling { - /** - * The maximum number of replicas to scale up to under load - */ - max_replicas: number; - - /** - * The minimum number of replicas to maintain, even when there is no load - */ - min_replicas: number; - } -} - export interface EndpointUpdateParams { /** * New autoscaling configuration for the endpoint */ - autoscaling?: EndpointUpdateParams.Autoscaling; + autoscaling?: Autoscaling; /** * A human-readable name for the endpoint @@ -464,23 +411,6 @@ export interface EndpointUpdateParams { state?: 'STARTED' | 'STOPPED'; } -export namespace EndpointUpdateParams { - /** - * New autoscaling configuration for the endpoint - */ - export interface Autoscaling { - /** - * The maximum number of replicas to scale up to under load - */ - max_replicas: number; - - /** - * The minimum number of replicas to maintain, even when there is no load - */ - min_replicas: number; - } -} - export interface EndpointListParams { /** * Filter endpoints by type @@ -490,6 +420,7 @@ export interface EndpointListParams { export declare namespace Endpoints { export { + type Autoscaling as Autoscaling, type EndpointCreateResponse as EndpointCreateResponse, type EndpointRetrieveResponse as EndpointRetrieveResponse, type EndpointUpdateResponse as EndpointUpdateResponse, diff --git a/src/resources/fine-tune.ts b/src/resources/fine-tune.ts index 6bf6cd48..15515ea8 100644 --- a/src/resources/fine-tune.ts +++ b/src/resources/fine-tune.ts @@ -2,6 +2,7 @@ import { APIResource } from '../resource'; import * as Core from '../core'; +import * as FineTuneAPI from './fine-tune'; export class FineTuneResource extends APIResource { /** @@ -79,12 +80,10 @@ export class FineTuneResource extends APIResource { * * @example * ```ts - * const fineTuneEvent = await client.fineTune.listEvents( - * 'id', - * ); + * const response = await client.fineTune.listEvents('id'); * ``` */ - listEvents(id: string, options?: Core.RequestOptions): Core.APIPromise { + listEvents(id: string, options?: Core.RequestOptions): Core.APIPromise { return this._client.get(`/fine-tunes/${id}/events`, options); } @@ -106,6 +105,18 @@ export class FineTuneResource extends APIResource { } } +export interface CosineLrSchedulerArgs { + /** + * The ratio of the final learning rate to the peak learning rate + */ + min_lr_ratio: number; + + /** + * Number or fraction of cycles for the cosine learning rate scheduler + */ + num_cycles: number; +} + export interface FineTune { id: string; @@ -128,7 +139,7 @@ export interface FineTune { eval_steps?: number; - events?: Array; + events?: Array; from_checkpoint?: string; @@ -136,7 +147,7 @@ export interface FineTune { learning_rate?: number; - lr_scheduler?: FineTune.LrScheduler; + lr_scheduler?: LrScheduler; max_grad_norm?: number; @@ -164,9 +175,9 @@ export interface FineTune { training_file?: string; - training_method?: FineTune.TrainingMethodSft | FineTune.TrainingMethodDpo; + training_method?: TrainingMethodSft | TrainingMethodDpo; - training_type?: FineTune.FullTrainingType | FineTune.LoRaTrainingType; + training_type?: FullTrainingType | LoRaTrainingType; trainingfile_numlines?: number; @@ -185,181 +196,104 @@ export interface FineTune { weight_decay?: number; } -export namespace FineTune { - export interface Event { - checkpoint_path: string; - - created_at: string; - - hash: string; - - message: string; - - model_path: string; +export interface FineTuneEvent { + checkpoint_path: string; - object: 'fine-tune-event'; + created_at: string; - param_count: number; + hash: string; - step: number; + message: string; - token_count: number; - - total_steps: number; - - training_offset: number; - - type: - | 'job_pending' - | 'job_start' - | 'job_stopped' - | 'model_downloading' - | 'model_download_complete' - | 'training_data_downloading' - | 'training_data_download_complete' - | 'validation_data_downloading' - | 'validation_data_download_complete' - | 'wandb_init' - | 'training_start' - | 'checkpoint_save' - | 'billing_limit' - | 'epoch_complete' - | 'training_complete' - | 'model_compressing' - | 'model_compression_complete' - | 'model_uploading' - | 'model_upload_complete' - | 'job_complete' - | 'job_error' - | 'cancel_requested' - | 'job_restarted' - | 'refund' - | 'warning'; + model_path: string; - wandb_url: string; + object: 'fine-tune-event'; - level?: 'info' | 'warning' | 'error' | 'legacy_info' | 'legacy_iwarning' | 'legacy_ierror' | null; - } + param_count: number; - export interface LrScheduler { - lr_scheduler_type: 'linear' | 'cosine'; + step: number; - lr_scheduler_args?: LrScheduler.LinearLrSchedulerArgs | LrScheduler.CosineLrSchedulerArgs; - } + token_count: number; - export namespace LrScheduler { - export interface LinearLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - } - - export interface CosineLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - - /** - * Number or fraction of cycles for the cosine learning rate scheduler - */ - num_cycles?: number; - } - } + total_steps: number; - export interface TrainingMethodSft { - method: 'sft'; + training_offset: number; - /** - * Whether to mask the user messages in conversational data or prompts in - * instruction data. - */ - train_on_inputs: boolean | 'auto'; - } - - export interface TrainingMethodDpo { - method: 'dpo'; - - dpo_beta?: number; - } - - export interface FullTrainingType { - type: 'Full'; - } - - export interface LoRaTrainingType { - lora_alpha: number; - - lora_r: number; + type: + | 'job_pending' + | 'job_start' + | 'job_stopped' + | 'model_downloading' + | 'model_download_complete' + | 'training_data_downloading' + | 'training_data_download_complete' + | 'validation_data_downloading' + | 'validation_data_download_complete' + | 'wandb_init' + | 'training_start' + | 'checkpoint_save' + | 'billing_limit' + | 'epoch_complete' + | 'training_complete' + | 'model_compressing' + | 'model_compression_complete' + | 'model_uploading' + | 'model_upload_complete' + | 'job_complete' + | 'job_error' + | 'cancel_requested' + | 'job_restarted' + | 'refund' + | 'warning'; - type: 'Lora'; + wandb_url: string; - lora_dropout?: number; + level?: 'info' | 'warning' | 'error' | 'legacy_info' | 'legacy_iwarning' | 'legacy_ierror' | null; +} - lora_trainable_modules?: string; - } +export interface FullTrainingType { + type: 'Full'; } -export interface FineTuneEvent { - data: Array; +export interface LinearLrSchedulerArgs { + /** + * The ratio of the final learning rate to the peak learning rate + */ + min_lr_ratio?: number; } -export namespace FineTuneEvent { - export interface Data { - checkpoint_path: string; +export interface LoRaTrainingType { + lora_alpha: number; - created_at: string; + lora_r: number; - hash: string; + type: 'Lora'; - message: string; + lora_dropout?: number; - model_path: string; + lora_trainable_modules?: string; +} - object: 'fine-tune-event'; +export interface LrScheduler { + lr_scheduler_type: 'linear' | 'cosine'; - param_count: number; + lr_scheduler_args?: LinearLrSchedulerArgs | CosineLrSchedulerArgs; +} - step: number; +export interface TrainingMethodDpo { + method: 'dpo'; - token_count: number; - - total_steps: number; - - training_offset: number; - - type: - | 'job_pending' - | 'job_start' - | 'job_stopped' - | 'model_downloading' - | 'model_download_complete' - | 'training_data_downloading' - | 'training_data_download_complete' - | 'validation_data_downloading' - | 'validation_data_download_complete' - | 'wandb_init' - | 'training_start' - | 'checkpoint_save' - | 'billing_limit' - | 'epoch_complete' - | 'training_complete' - | 'model_compressing' - | 'model_compression_complete' - | 'model_uploading' - | 'model_upload_complete' - | 'job_complete' - | 'job_error' - | 'cancel_requested' - | 'job_restarted' - | 'refund' - | 'warning'; + dpo_beta?: number; +} - wandb_url: string; +export interface TrainingMethodSft { + method: 'sft'; - level?: 'info' | 'warning' | 'error' | 'legacy_info' | 'legacy_iwarning' | 'legacy_ierror' | null; - } + /** + * Whether to mask the user messages in conversational data or prompts in + * instruction data. + */ + train_on_inputs: boolean | 'auto'; } /** @@ -401,7 +335,7 @@ export interface FineTuneCreateResponse { /** * Events related to this fine-tune job */ - events?: Array; + events?: Array; /** * Checkpoint used to continue training @@ -416,7 +350,7 @@ export interface FineTuneCreateResponse { /** * Learning rate scheduler configuration */ - lr_scheduler?: FineTuneCreateResponse.LrScheduler; + lr_scheduler?: LrScheduler; /** * Maximum gradient norm for clipping @@ -473,12 +407,12 @@ export interface FineTuneCreateResponse { /** * Method of training used */ - training_method?: FineTuneCreateResponse.TrainingMethodSft | FineTuneCreateResponse.TrainingMethodDpo; + training_method?: TrainingMethodSft | TrainingMethodDpo; /** * Type of training used (full or LoRA) */ - training_type?: FineTuneCreateResponse.FullTrainingType | FineTuneCreateResponse.LoRaTrainingType; + training_type?: FullTrainingType | LoRaTrainingType; /** * Identifier for the user who created the job @@ -511,125 +445,6 @@ export interface FineTuneCreateResponse { weight_decay?: number; } -export namespace FineTuneCreateResponse { - export interface Event { - checkpoint_path: string; - - created_at: string; - - hash: string; - - message: string; - - model_path: string; - - object: 'fine-tune-event'; - - param_count: number; - - step: number; - - token_count: number; - - total_steps: number; - - training_offset: number; - - type: - | 'job_pending' - | 'job_start' - | 'job_stopped' - | 'model_downloading' - | 'model_download_complete' - | 'training_data_downloading' - | 'training_data_download_complete' - | 'validation_data_downloading' - | 'validation_data_download_complete' - | 'wandb_init' - | 'training_start' - | 'checkpoint_save' - | 'billing_limit' - | 'epoch_complete' - | 'training_complete' - | 'model_compressing' - | 'model_compression_complete' - | 'model_uploading' - | 'model_upload_complete' - | 'job_complete' - | 'job_error' - | 'cancel_requested' - | 'job_restarted' - | 'refund' - | 'warning'; - - wandb_url: string; - - level?: 'info' | 'warning' | 'error' | 'legacy_info' | 'legacy_iwarning' | 'legacy_ierror' | null; - } - - /** - * Learning rate scheduler configuration - */ - export interface LrScheduler { - lr_scheduler_type: 'linear' | 'cosine'; - - lr_scheduler_args?: LrScheduler.LinearLrSchedulerArgs | LrScheduler.CosineLrSchedulerArgs; - } - - export namespace LrScheduler { - export interface LinearLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - } - - export interface CosineLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - - /** - * Number or fraction of cycles for the cosine learning rate scheduler - */ - num_cycles?: number; - } - } - - export interface TrainingMethodSft { - method: 'sft'; - - /** - * Whether to mask the user messages in conversational data or prompts in - * instruction data. - */ - train_on_inputs: boolean | 'auto'; - } - - export interface TrainingMethodDpo { - method: 'dpo'; - - dpo_beta?: number; - } - - export interface FullTrainingType { - type: 'Full'; - } - - export interface LoRaTrainingType { - lora_alpha: number; - - lora_r: number; - - type: 'Lora'; - - lora_dropout?: number; - - lora_trainable_modules?: string; - } -} - export interface FineTuneListResponse { data: Array; } @@ -674,7 +489,7 @@ export namespace FineTuneListResponse { /** * Events related to this fine-tune job */ - events?: Array; + events?: Array; /** * Checkpoint used to continue training @@ -689,7 +504,7 @@ export namespace FineTuneListResponse { /** * Learning rate scheduler configuration */ - lr_scheduler?: Data.LrScheduler; + lr_scheduler?: FineTuneAPI.LrScheduler; /** * Maximum gradient norm for clipping @@ -746,12 +561,12 @@ export namespace FineTuneListResponse { /** * Method of training used */ - training_method?: Data.TrainingMethodSft | Data.TrainingMethodDpo; + training_method?: FineTuneAPI.TrainingMethodSft | FineTuneAPI.TrainingMethodDpo; /** * Type of training used (full or LoRA) */ - training_type?: Data.FullTrainingType | Data.LoRaTrainingType; + training_type?: FineTuneAPI.FullTrainingType | FineTuneAPI.LoRaTrainingType; /** * Identifier for the user who created the job @@ -783,125 +598,6 @@ export namespace FineTuneListResponse { */ weight_decay?: number; } - - export namespace Data { - export interface Event { - checkpoint_path: string; - - created_at: string; - - hash: string; - - message: string; - - model_path: string; - - object: 'fine-tune-event'; - - param_count: number; - - step: number; - - token_count: number; - - total_steps: number; - - training_offset: number; - - type: - | 'job_pending' - | 'job_start' - | 'job_stopped' - | 'model_downloading' - | 'model_download_complete' - | 'training_data_downloading' - | 'training_data_download_complete' - | 'validation_data_downloading' - | 'validation_data_download_complete' - | 'wandb_init' - | 'training_start' - | 'checkpoint_save' - | 'billing_limit' - | 'epoch_complete' - | 'training_complete' - | 'model_compressing' - | 'model_compression_complete' - | 'model_uploading' - | 'model_upload_complete' - | 'job_complete' - | 'job_error' - | 'cancel_requested' - | 'job_restarted' - | 'refund' - | 'warning'; - - wandb_url: string; - - level?: 'info' | 'warning' | 'error' | 'legacy_info' | 'legacy_iwarning' | 'legacy_ierror' | null; - } - - /** - * Learning rate scheduler configuration - */ - export interface LrScheduler { - lr_scheduler_type: 'linear' | 'cosine'; - - lr_scheduler_args?: LrScheduler.LinearLrSchedulerArgs | LrScheduler.CosineLrSchedulerArgs; - } - - export namespace LrScheduler { - export interface LinearLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - } - - export interface CosineLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - - /** - * Number or fraction of cycles for the cosine learning rate scheduler - */ - num_cycles?: number; - } - } - - export interface TrainingMethodSft { - method: 'sft'; - - /** - * Whether to mask the user messages in conversational data or prompts in - * instruction data. - */ - train_on_inputs: boolean | 'auto'; - } - - export interface TrainingMethodDpo { - method: 'dpo'; - - dpo_beta?: number; - } - - export interface FullTrainingType { - type: 'Full'; - } - - export interface LoRaTrainingType { - lora_alpha: number; - - lora_r: number; - - type: 'Lora'; - - lora_dropout?: number; - - lora_trainable_modules?: string; - } - } } /** @@ -943,7 +639,7 @@ export interface FineTuneCancelResponse { /** * Events related to this fine-tune job */ - events?: Array; + events?: Array; /** * Checkpoint used to continue training @@ -958,7 +654,7 @@ export interface FineTuneCancelResponse { /** * Learning rate scheduler configuration */ - lr_scheduler?: FineTuneCancelResponse.LrScheduler; + lr_scheduler?: LrScheduler; /** * Maximum gradient norm for clipping @@ -1015,12 +711,12 @@ export interface FineTuneCancelResponse { /** * Method of training used */ - training_method?: FineTuneCancelResponse.TrainingMethodSft | FineTuneCancelResponse.TrainingMethodDpo; + training_method?: TrainingMethodSft | TrainingMethodDpo; /** * Type of training used (full or LoRA) */ - training_type?: FineTuneCancelResponse.FullTrainingType | FineTuneCancelResponse.LoRaTrainingType; + training_type?: FullTrainingType | LoRaTrainingType; /** * Identifier for the user who created the job @@ -1053,125 +749,6 @@ export interface FineTuneCancelResponse { weight_decay?: number; } -export namespace FineTuneCancelResponse { - export interface Event { - checkpoint_path: string; - - created_at: string; - - hash: string; - - message: string; - - model_path: string; - - object: 'fine-tune-event'; - - param_count: number; - - step: number; - - token_count: number; - - total_steps: number; - - training_offset: number; - - type: - | 'job_pending' - | 'job_start' - | 'job_stopped' - | 'model_downloading' - | 'model_download_complete' - | 'training_data_downloading' - | 'training_data_download_complete' - | 'validation_data_downloading' - | 'validation_data_download_complete' - | 'wandb_init' - | 'training_start' - | 'checkpoint_save' - | 'billing_limit' - | 'epoch_complete' - | 'training_complete' - | 'model_compressing' - | 'model_compression_complete' - | 'model_uploading' - | 'model_upload_complete' - | 'job_complete' - | 'job_error' - | 'cancel_requested' - | 'job_restarted' - | 'refund' - | 'warning'; - - wandb_url: string; - - level?: 'info' | 'warning' | 'error' | 'legacy_info' | 'legacy_iwarning' | 'legacy_ierror' | null; - } - - /** - * Learning rate scheduler configuration - */ - export interface LrScheduler { - lr_scheduler_type: 'linear' | 'cosine'; - - lr_scheduler_args?: LrScheduler.LinearLrSchedulerArgs | LrScheduler.CosineLrSchedulerArgs; - } - - export namespace LrScheduler { - export interface LinearLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - } - - export interface CosineLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - - /** - * Number or fraction of cycles for the cosine learning rate scheduler - */ - num_cycles?: number; - } - } - - export interface TrainingMethodSft { - method: 'sft'; - - /** - * Whether to mask the user messages in conversational data or prompts in - * instruction data. - */ - train_on_inputs: boolean | 'auto'; - } - - export interface TrainingMethodDpo { - method: 'dpo'; - - dpo_beta?: number; - } - - export interface FullTrainingType { - type: 'Full'; - } - - export interface LoRaTrainingType { - lora_alpha: number; - - lora_r: number; - - type: 'Lora'; - - lora_dropout?: number; - - lora_trainable_modules?: string; - } -} - export interface FineTuneDownloadResponse { id?: string; @@ -1184,6 +761,10 @@ export interface FineTuneDownloadResponse { size?: number; } +export interface FineTuneListEventsResponse { + data: Array; +} + export interface FineTuneRetrieveCheckpointsResponse { data: Array; } @@ -1236,7 +817,7 @@ export interface FineTuneCreateParams { * The learning rate scheduler to use. It specifies how the learning rate is * adjusted during training. */ - lr_scheduler?: FineTuneCreateParams.LrScheduler; + lr_scheduler?: LrScheduler; /** * Max gradient norm to be used for gradient clipping. Set to 0 to disable. @@ -1274,9 +855,9 @@ export interface FineTuneCreateParams { * The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct * Preference Optimization. */ - training_method?: FineTuneCreateParams.TrainingMethodSft | FineTuneCreateParams.TrainingMethodDpo; + training_method?: TrainingMethodSft | TrainingMethodDpo; - training_type?: FineTuneCreateParams.FullTrainingType | FineTuneCreateParams.LoRaTrainingType; + training_type?: FullTrainingType | LoRaTrainingType; /** * File-ID of a validation file uploaded to the Together API @@ -1316,71 +897,6 @@ export interface FineTuneCreateParams { weight_decay?: number; } -export namespace FineTuneCreateParams { - /** - * The learning rate scheduler to use. It specifies how the learning rate is - * adjusted during training. - */ - export interface LrScheduler { - lr_scheduler_type: 'linear' | 'cosine'; - - lr_scheduler_args?: LrScheduler.LinearLrSchedulerArgs | LrScheduler.CosineLrSchedulerArgs; - } - - export namespace LrScheduler { - export interface LinearLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - } - - export interface CosineLrSchedulerArgs { - /** - * The ratio of the final learning rate to the peak learning rate - */ - min_lr_ratio?: number; - - /** - * Number or fraction of cycles for the cosine learning rate scheduler - */ - num_cycles?: number; - } - } - - export interface TrainingMethodSft { - method: 'sft'; - - /** - * Whether to mask the user messages in conversational data or prompts in - * instruction data. - */ - train_on_inputs: boolean | 'auto'; - } - - export interface TrainingMethodDpo { - method: 'dpo'; - - dpo_beta?: number; - } - - export interface FullTrainingType { - type: 'Full'; - } - - export interface LoRaTrainingType { - lora_alpha: number; - - lora_r: number; - - type: 'Lora'; - - lora_dropout?: number; - - lora_trainable_modules?: string; - } -} - export interface FineTuneDownloadParams { /** * Fine-tune ID to download. A string that starts with `ft-`. @@ -1408,12 +924,20 @@ export interface FineTuneDownloadParams { export declare namespace FineTuneResource { export { + type CosineLrSchedulerArgs as CosineLrSchedulerArgs, type FineTune as FineTune, type FineTuneEvent as FineTuneEvent, + type FullTrainingType as FullTrainingType, + type LinearLrSchedulerArgs as LinearLrSchedulerArgs, + type LoRaTrainingType as LoRaTrainingType, + type LrScheduler as LrScheduler, + type TrainingMethodDpo as TrainingMethodDpo, + type TrainingMethodSft as TrainingMethodSft, type FineTuneCreateResponse as FineTuneCreateResponse, type FineTuneListResponse as FineTuneListResponse, type FineTuneCancelResponse as FineTuneCancelResponse, type FineTuneDownloadResponse as FineTuneDownloadResponse, + type FineTuneListEventsResponse as FineTuneListEventsResponse, type FineTuneRetrieveCheckpointsResponse as FineTuneRetrieveCheckpointsResponse, type FineTuneCreateParams as FineTuneCreateParams, type FineTuneDownloadParams as FineTuneDownloadParams, diff --git a/src/resources/images.ts b/src/resources/images.ts index 10156bbc..c68b5116 100644 --- a/src/resources/images.ts +++ b/src/resources/images.ts @@ -20,24 +20,26 @@ export class Images extends APIResource { } } -export interface ImageFile { - id: string; +export interface ImageDataB64 { + b64_json: string; - data: Array; + index: number; +} - model: string; +export interface ImageDataURL { + index: number; - object: 'list'; + url: string; } -export namespace ImageFile { - export interface Data { - index: number; +export interface ImageFile { + id: string; - b64_json?: string; + data: Array; - url?: string; - } + model: string; + + object: 'list'; } export interface ImageCreateParams { @@ -133,5 +135,10 @@ export namespace ImageCreateParams { } export declare namespace Images { - export { type ImageFile as ImageFile, type ImageCreateParams as ImageCreateParams }; + export { + type ImageDataB64 as ImageDataB64, + type ImageDataURL as ImageDataURL, + type ImageFile as ImageFile, + type ImageCreateParams as ImageCreateParams, + }; } diff --git a/src/resources/index.ts b/src/resources/index.ts index ed6d28ab..a52f1a75 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,6 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Audio, type AudioFile, type AudioCreateParams } from './audio'; +export { + Audio, + type AudioFile, + type AudioSpeechStreamChunk, + type AudioCreateParams, + type AudioCreateParamsNonStreaming, + type AudioCreateParamsStreaming, +} from './audio'; export { Chat } from './chat/chat'; export { CodeInterpreter, @@ -21,6 +28,7 @@ export { export { Embeddings, type Embedding, type EmbeddingCreateParams } from './embeddings'; export { Endpoints, + type Autoscaling, type EndpointCreateResponse, type EndpointRetrieveResponse, type EndpointUpdateResponse, @@ -42,18 +50,32 @@ export { } from './files'; export { FineTuneResource, + type CosineLrSchedulerArgs, type FineTune, type FineTuneEvent, + type FullTrainingType, + type LinearLrSchedulerArgs, + type LoRaTrainingType, + type LrScheduler, + type TrainingMethodDpo, + type TrainingMethodSft, type FineTuneCreateResponse, type FineTuneListResponse, type FineTuneCancelResponse, type FineTuneDownloadResponse, + type FineTuneListEventsResponse, type FineTuneRetrieveCheckpointsResponse, type FineTuneCreateParams, type FineTuneDownloadParams, } from './fine-tune'; export { Hardware, type HardwareListResponse, type HardwareListParams } from './hardware'; -export { Images, type ImageFile, type ImageCreateParams } from './images'; +export { + Images, + type ImageDataB64, + type ImageDataURL, + type ImageFile, + type ImageCreateParams, +} from './images'; export { Jobs, type JobRetrieveResponse, type JobListResponse } from './jobs'; export { Models, type ModelListResponse, type ModelUploadResponse, type ModelUploadParams } from './models'; export { type RerankResponse, type RerankParams } from './top-level'; diff --git a/tests/api-resources/audio.test.ts b/tests/api-resources/audio.test.ts index f5e307ff..ac734ffa 100644 --- a/tests/api-resources/audio.test.ts +++ b/tests/api-resources/audio.test.ts @@ -8,7 +8,8 @@ const client = new Together({ }); describe('resource audio', () => { - test('create: required and optional params', async () => { + // AttributeError: BinaryAPIResponse object has no attribute response + test.skip('create: required and optional params', async () => { const response = await client.audio.create({ input: 'input', model: 'cartesia/sonic', @@ -17,7 +18,7 @@ describe('resource audio', () => { response_encoding: 'pcm_f32le', response_format: 'mp3', sample_rate: 0, - stream: true, + stream: false, }); }); }); diff --git a/tests/api-resources/fine-tune.test.ts b/tests/api-resources/fine-tune.test.ts index 85aae275..62be97c9 100644 --- a/tests/api-resources/fine-tune.test.ts +++ b/tests/api-resources/fine-tune.test.ts @@ -9,8 +9,7 @@ const client = new Together({ }); describe('resource fineTune', () => { - // invalid oneOf in required props - test.skip('create: only required params', async () => { + test('create: only required params', async () => { const responsePromise = client.fineTune.create({ model: 'model', training_file: 'training_file' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -21,8 +20,7 @@ describe('resource fineTune', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // invalid oneOf in required props - test.skip('create: required and optional params', async () => { + test('create: required and optional params', async () => { const response = await client.fineTune.create({ model: 'model', training_file: 'training_file', diff --git a/tests/api-resources/images.test.ts b/tests/api-resources/images.test.ts index 13024d4f..6494e9e3 100644 --- a/tests/api-resources/images.test.ts +++ b/tests/api-resources/images.test.ts @@ -9,8 +9,7 @@ const client = new Together({ }); describe('resource images', () => { - // invalid oneOf in required props - test.skip('create: only required params', async () => { + test('create: only required params', async () => { const responsePromise = client.images.create({ model: 'black-forest-labs/FLUX.1-schnell', prompt: 'cat floating in space, cinematic', @@ -24,8 +23,7 @@ describe('resource images', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // invalid oneOf in required props - test.skip('create: required and optional params', async () => { + test('create: required and optional params', async () => { const response = await client.images.create({ model: 'black-forest-labs/FLUX.1-schnell', prompt: 'cat floating in space, cinematic', From ba1fa6c09e368b51c4d868bcf30ac6d1286e5a82 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 01:55:16 +0000 Subject: [PATCH 32/49] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 62fb35ad..144618cc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-653a4aa26fdd2b335d1ead9c2ea0672cbe48a7616b76bf350a2421a8def4e08d.yml -openapi_spec_hash: b8a97aaff787274a4616d97a05b3a616 +openapi_spec_hash: 1d5af8ab9d8c11d7f5225e19ebd1654a config_hash: d15dd709dd3f87b0a8b83b00b4abc881 From 91ffaf3619498f4add78034c050eae7db88c36a0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 17:35:48 +0000 Subject: [PATCH 33/49] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 144618cc..5e465ec1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-653a4aa26fdd2b335d1ead9c2ea0672cbe48a7616b76bf350a2421a8def4e08d.yml -openapi_spec_hash: 1d5af8ab9d8c11d7f5225e19ebd1654a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-4a4319b1903dc2ad6f0f9ff8925ae462ade92eed69e0a08181ced66e094541c7.yml +openapi_spec_hash: 0be27287275454e0ebdbc29c00c69305 config_hash: d15dd709dd3f87b0a8b83b00b4abc881 From 75375d062b0116e4a2f57fd3584a72a05247e2fe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 17:48:25 +0000 Subject: [PATCH 34/49] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5e465ec1..b0eabb03 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-4a4319b1903dc2ad6f0f9ff8925ae462ade92eed69e0a08181ced66e094541c7.yml -openapi_spec_hash: 0be27287275454e0ebdbc29c00c69305 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-29df763b2f7896b4f214e444a58d7aba39a45f90380e5deb3e010ff964f6d14c.yml +openapi_spec_hash: 8706285e2ec0c0b777452a74ae015326 config_hash: d15dd709dd3f87b0a8b83b00b4abc881 From 471c909ff1918076168d6dd221561c94a24bd947 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 16:00:52 +0000 Subject: [PATCH 35/49] =?UTF-8?q?fix:=20publish=20script=20=E2=80=94=20han?= =?UTF-8?q?dle=20NPM=20errors=20correctly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/publish-npm | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/bin/publish-npm b/bin/publish-npm index 2505deca..fa2243d2 100644 --- a/bin/publish-npm +++ b/bin/publish-npm @@ -7,15 +7,35 @@ npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN" yarn build cd dist +# Get package name and version from package.json +PACKAGE_NAME="$(jq -r -e '.name' ./package.json)" +VERSION="$(jq -r -e '.version' ./package.json)" + # Get latest version from npm # -# If the package doesn't exist, yarn will return -# {"type":"error","data":"Received invalid response from npm."} -# where .data.version doesn't exist so LAST_VERSION will be an empty string. -LAST_VERSION="$(yarn info --json 2> /dev/null | jq -r '.data.version')" - -# Get current version from package.json -VERSION="$(node -p "require('./package.json').version")" +# If the package doesn't exist, npm will return: +# { +# "error": { +# "code": "E404", +# "summary": "Unpublished on 2025-06-05T09:54:53.528Z", +# "detail": "'the_package' is not in this registry..." +# } +# } +NPM_INFO="$(npm view "$PACKAGE_NAME" version --json 2>/dev/null || true)" + +# Check if we got an E404 error +if echo "$NPM_INFO" | jq -e '.error.code == "E404"' > /dev/null 2>&1; then + # Package doesn't exist yet, no last version + LAST_VERSION="" +elif echo "$NPM_INFO" | jq -e '.error' > /dev/null 2>&1; then + # Report other errors + echo "ERROR: npm returned unexpected data:" + echo "$NPM_INFO" + exit 1 +else + # Success - get the version + LAST_VERSION=$(echo "$NPM_INFO" | jq -r '.') # strip quotes +fi # Check if current version is pre-release (e.g. alpha / beta / rc) CURRENT_IS_PRERELEASE=false From d64b6790659e223a1e003396d39dcd95fe35ef0e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 17:52:50 +0000 Subject: [PATCH 36/49] chore(internal): make base APIResource abstract --- scripts/build | 2 +- src/resource.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build b/scripts/build index 3d350e76..019e4f72 100755 --- a/scripts/build +++ b/scripts/build @@ -28,7 +28,7 @@ fi node scripts/utils/make-dist-package-json.cjs > dist/package.json # build to .js/.mjs/.d.ts files -npm exec tsc-multi +./node_modules/.bin/tsc-multi # copy over handwritten .js/.mjs/.d.ts files cp src/_shims/*.{d.ts,js,mjs,md} dist/_shims cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto diff --git a/src/resource.ts b/src/resource.ts index b1c3a19d..9e04217f 100644 --- a/src/resource.ts +++ b/src/resource.ts @@ -2,7 +2,7 @@ import type { Together } from './index'; -export class APIResource { +export abstract class APIResource { protected _client: Together; constructor(client: Together) { From 850a7da0fcc711164290db4a88e07e31762e9d1f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 09:22:16 +0000 Subject: [PATCH 37/49] feat(api): api update --- .stats.yml | 4 ++-- src/resources/fine-tune.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index b0eabb03..ef30b3bd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-29df763b2f7896b4f214e444a58d7aba39a45f90380e5deb3e010ff964f6d14c.yml -openapi_spec_hash: 8706285e2ec0c0b777452a74ae015326 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-4951d9964e7f7647cd3f716f3f127706e0a60d3afedb1d339de8b8c41cfc19d4.yml +openapi_spec_hash: 306c08678a0677f1deb1d35def6f8713 config_hash: d15dd709dd3f87b0a8b83b00b4abc881 diff --git a/src/resources/fine-tune.ts b/src/resources/fine-tune.ts index 15515ea8..9b02757e 100644 --- a/src/resources/fine-tune.ts +++ b/src/resources/fine-tune.ts @@ -284,6 +284,14 @@ export interface TrainingMethodDpo { method: 'dpo'; dpo_beta?: number; + + dpo_normalize_logratios_by_length?: boolean; + + dpo_reference_free?: boolean; + + rpo_alpha?: number; + + simpo_gamma?: number; } export interface TrainingMethodSft { From 7d7bb0c308b909713ef0a0fedbe7acea59594946 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:26:53 +0000 Subject: [PATCH 38/49] feat(client): add support for endpoint-specific base URLs --- src/core.ts | 15 +++++++++++---- src/index.ts | 8 ++++++++ tests/index.test.ts | 22 ++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/core.ts b/src/core.ts index fe1e225b..779e349a 100644 --- a/src/core.ts +++ b/src/core.ts @@ -184,6 +184,7 @@ export class APIPromise extends Promise { export abstract class APIClient { baseURL: string; + #baseURLOverridden: boolean; maxRetries: number; timeout: number; httpAgent: Agent | undefined; @@ -193,18 +194,21 @@ export abstract class APIClient { constructor({ baseURL, + baseURLOverridden, maxRetries = 5, timeout = 60000, // 1 minute httpAgent, fetch: overriddenFetch, }: { baseURL: string; + baseURLOverridden: boolean; maxRetries?: number | undefined; timeout: number | undefined; httpAgent: Agent | undefined; fetch: Fetch | undefined; }) { this.baseURL = baseURL; + this.#baseURLOverridden = baseURLOverridden; this.maxRetries = validatePositiveInteger('maxRetries', maxRetries); this.timeout = validatePositiveInteger('timeout', timeout); this.httpAgent = httpAgent; @@ -314,7 +318,7 @@ export abstract class APIClient { { retryCount = 0 }: { retryCount?: number } = {}, ): { req: RequestInit; url: string; timeout: number } { const options = { ...inputOptions }; - const { method, path, query, headers: headers = {} } = options; + const { method, path, query, defaultBaseURL, headers: headers = {} } = options; const body = ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ? @@ -324,7 +328,7 @@ export abstract class APIClient { : null; const contentLength = this.calculateContentLength(body); - const url = this.buildURL(path!, query); + const url = this.buildURL(path!, query, defaultBaseURL); if ('timeout' in options) validatePositiveInteger('timeout', options.timeout); options.timeout = options.timeout ?? this.timeout; const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url); @@ -517,11 +521,12 @@ export abstract class APIClient { return new PagePromise(this, request, Page); } - buildURL(path: string, query: Req | null | undefined): string { + buildURL(path: string, query: Req | null | undefined, defaultBaseURL?: string | undefined): string { + const baseURL = (!this.#baseURLOverridden && defaultBaseURL) || this.baseURL; const url = isAbsoluteURL(path) ? new URL(path) - : new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path)); + : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path)); const defaultQuery = this.defaultQuery(); if (!isEmptyObj(defaultQuery)) { @@ -806,6 +811,7 @@ export type RequestOptions< query?: Req | undefined; body?: Req | null | undefined; headers?: Headers | undefined; + defaultBaseURL?: string | undefined; maxRetries?: number; stream?: boolean | undefined; @@ -828,6 +834,7 @@ const requestOptionsKeys: KeysEnum = { query: true, body: true, headers: true, + defaultBaseURL: true, maxRetries: true, stream: true, diff --git a/src/index.ts b/src/index.ts index f5efc702..49720188 100644 --- a/src/index.ts +++ b/src/index.ts @@ -182,6 +182,7 @@ export class Together extends Core.APIClient { super({ baseURL: options.baseURL!, + baseURLOverridden: baseURL ? baseURL !== 'https://api.together.xyz/v1' : false, timeout: options.timeout ?? 60000 /* 1 minute */, httpAgent: options.httpAgent, maxRetries: options.maxRetries, @@ -206,6 +207,13 @@ export class Together extends Core.APIClient { endpoints: API.Endpoints = new API.Endpoints(this); hardware: API.Hardware = new API.Hardware(this); + /** + * Check whether the base URL is set to its default. + */ + #baseURLOverridden(): boolean { + return this.baseURL !== 'https://api.together.xyz/v1'; + } + /** * Query a reranker model * diff --git a/tests/index.test.ts b/tests/index.test.ts index 710fb68d..bdc9f744 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -185,6 +185,28 @@ describe('instantiate client', () => { const client = new Together({ apiKey: 'My API Key' }); expect(client.baseURL).toEqual('https://api.together.xyz/v1'); }); + + test('in request options', () => { + const client = new Together({ apiKey: 'My API Key' }); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( + 'http://localhost:5000/option/foo', + ); + }); + + test('in request options overridden by client options', () => { + const client = new Together({ apiKey: 'My API Key', baseURL: 'http://localhost:5000/client' }); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( + 'http://localhost:5000/client/foo', + ); + }); + + test('in request options overridden by env variable', () => { + process.env['TOGETHER_BASE_URL'] = 'http://localhost:5000/env'; + const client = new Together({ apiKey: 'My API Key' }); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( + 'http://localhost:5000/env/foo', + ); + }); }); test('maxRetries option is correctly set', () => { From e393ec0952cb571617df474597a8bdbdfbdf86ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 00:10:31 +0000 Subject: [PATCH 39/49] chore(ci): enable for pull requests --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f48e532c..673920b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,10 @@ on: - 'integrated/**' - 'stl-preview-head/**' - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: From d51bc5aef6cdc4d28ece075adaae4e21b3ad9c28 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Jun 2025 21:59:59 +0000 Subject: [PATCH 40/49] feat(api): add batch api to config --- .stats.yml | 6 +- api.md | 14 ++ src/index.ts | 17 +++ src/resources/batches.ts | 221 ++++++++++++++++++++++++++++ src/resources/index.ts | 7 + tests/api-resources/batches.test.ts | 71 +++++++++ 6 files changed, 333 insertions(+), 3 deletions(-) create mode 100644 src/resources/batches.ts create mode 100644 tests/api-resources/batches.test.ts diff --git a/.stats.yml b/.stats.yml index ef30b3bd..fcc638d2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-4951d9964e7f7647cd3f716f3f127706e0a60d3afedb1d339de8b8c41cfc19d4.yml +configured_endpoints: 33 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-9ca24c17ccf9b0b4c2d27c09881dc74bf4cb44efc7a5ccb7d54fa15caee095d1.yml openapi_spec_hash: 306c08678a0677f1deb1d35def6f8713 -config_hash: d15dd709dd3f87b0a8b83b00b4abc881 +config_hash: fa59b4c1ab0a2e74aa855e7227b10c7d diff --git a/api.md b/api.md index f5cb1e9d..db3b88be 100644 --- a/api.md +++ b/api.md @@ -201,3 +201,17 @@ Types: Methods: - client.hardware.list({ ...params }) -> HardwareListResponse + +# Batches + +Types: + +- BatchCreateResponse +- BatchRetrieveResponse +- BatchListResponse + +Methods: + +- client.batches.create({ ...params }) -> BatchCreateResponse +- client.batches.retrieve(id) -> BatchRetrieveResponse +- client.batches.list() -> BatchListResponse diff --git a/src/index.ts b/src/index.ts index 49720188..6a40c245 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,13 @@ import { AudioFile, AudioSpeechStreamChunk, } from './resources/audio'; +import { + BatchCreateParams, + BatchCreateResponse, + BatchListResponse, + BatchRetrieveResponse, + Batches, +} from './resources/batches'; import { Completion, CompletionChunk, @@ -206,6 +213,7 @@ export class Together extends Core.APIClient { jobs: API.Jobs = new API.Jobs(this); endpoints: API.Endpoints = new API.Endpoints(this); hardware: API.Hardware = new API.Hardware(this); + batches: API.Batches = new API.Batches(this); /** * Check whether the base URL is set to its default. @@ -286,6 +294,7 @@ Together.Models = Models; Together.Jobs = Jobs; Together.Endpoints = Endpoints; Together.Hardware = Hardware; +Together.Batches = Batches; export declare namespace Together { export type RequestOptions = Core.RequestOptions; @@ -397,6 +406,14 @@ export declare namespace Together { type HardwareListResponse as HardwareListResponse, type HardwareListParams as HardwareListParams, }; + + export { + Batches as Batches, + type BatchCreateResponse as BatchCreateResponse, + type BatchRetrieveResponse as BatchRetrieveResponse, + type BatchListResponse as BatchListResponse, + type BatchCreateParams as BatchCreateParams, + }; } export { toFile, fileFromPath } from './uploads'; diff --git a/src/resources/batches.ts b/src/resources/batches.ts new file mode 100644 index 00000000..1ebcd49e --- /dev/null +++ b/src/resources/batches.ts @@ -0,0 +1,221 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import * as Core from '../core'; + +export class Batches extends APIResource { + /** + * Create a new batch job with the given input file and endpoint + * + * @example + * ```ts + * const batch = await client.batches.create({ + * endpoint: '/v1/chat/completions', + * input_file_id: 'file-abc123def456ghi789', + * }); + * ``` + */ + create(body: BatchCreateParams, options?: Core.RequestOptions): Core.APIPromise { + return this._client.post('/batches', { body, ...options }); + } + + /** + * Get details of a batch job by ID + * + * @example + * ```ts + * const batch = await client.batches.retrieve( + * 'batch_job_abc123def456', + * ); + * ``` + */ + retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise { + return this._client.get(`/batches/${id}`, options); + } + + /** + * List all batch jobs for the authenticated user + * + * @example + * ```ts + * const batches = await client.batches.list(); + * ``` + */ + list(options?: Core.RequestOptions): Core.APIPromise { + return this._client.get('/batches', options); + } +} + +export interface BatchCreateResponse { + job?: BatchCreateResponse.Job; + + warning?: string; +} + +export namespace BatchCreateResponse { + export interface Job { + id?: string; + + completed_at?: string; + + created_at?: string; + + endpoint?: string; + + error?: string; + + error_file_id?: string; + + /** + * Size of input file in bytes + */ + file_size_bytes?: number; + + input_file_id?: string; + + job_deadline?: string; + + /** + * Model used for processing requests + */ + model_id?: string; + + output_file_id?: string; + + /** + * Completion progress (0.0 to 100) + */ + progress?: number; + + /** + * Current status of the batch job + */ + status?: 'VALIDATING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED' | 'EXPIRED' | 'CANCELLED'; + + user_id?: string; + } +} + +export interface BatchRetrieveResponse { + id?: string; + + completed_at?: string; + + created_at?: string; + + endpoint?: string; + + error?: string; + + error_file_id?: string; + + /** + * Size of input file in bytes + */ + file_size_bytes?: number; + + input_file_id?: string; + + job_deadline?: string; + + /** + * Model used for processing requests + */ + model_id?: string; + + output_file_id?: string; + + /** + * Completion progress (0.0 to 100) + */ + progress?: number; + + /** + * Current status of the batch job + */ + status?: 'VALIDATING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED' | 'EXPIRED' | 'CANCELLED'; + + user_id?: string; +} + +export type BatchListResponse = Array; + +export namespace BatchListResponse { + export interface BatchListResponseItem { + id?: string; + + completed_at?: string; + + created_at?: string; + + endpoint?: string; + + error?: string; + + error_file_id?: string; + + /** + * Size of input file in bytes + */ + file_size_bytes?: number; + + input_file_id?: string; + + job_deadline?: string; + + /** + * Model used for processing requests + */ + model_id?: string; + + output_file_id?: string; + + /** + * Completion progress (0.0 to 100) + */ + progress?: number; + + /** + * Current status of the batch job + */ + status?: 'VALIDATING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED' | 'EXPIRED' | 'CANCELLED'; + + user_id?: string; + } +} + +export interface BatchCreateParams { + /** + * The endpoint to use for batch processing + */ + endpoint: string; + + /** + * ID of the uploaded input file containing batch requests + */ + input_file_id: string; + + /** + * Time window for batch completion (optional) + */ + completion_window?: string; + + /** + * Model to use for processing batch requests + */ + model_id?: string; + + /** + * Priority for batch processing (optional) + */ + priority?: number; +} + +export declare namespace Batches { + export { + type BatchCreateResponse as BatchCreateResponse, + type BatchRetrieveResponse as BatchRetrieveResponse, + type BatchListResponse as BatchListResponse, + type BatchCreateParams as BatchCreateParams, + }; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index a52f1a75..8f993f0b 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -8,6 +8,13 @@ export { type AudioCreateParamsNonStreaming, type AudioCreateParamsStreaming, } from './audio'; +export { + Batches, + type BatchCreateResponse, + type BatchRetrieveResponse, + type BatchListResponse, + type BatchCreateParams, +} from './batches'; export { Chat } from './chat/chat'; export { CodeInterpreter, diff --git a/tests/api-resources/batches.test.ts b/tests/api-resources/batches.test.ts new file mode 100644 index 00000000..8f58d2bc --- /dev/null +++ b/tests/api-resources/batches.test.ts @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Together from 'together-ai'; +import { Response } from 'node-fetch'; + +const client = new Together({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource batches', () => { + test('create: only required params', async () => { + const responsePromise = client.batches.create({ + endpoint: '/v1/chat/completions', + input_file_id: 'file-abc123def456ghi789', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.batches.create({ + endpoint: '/v1/chat/completions', + input_file_id: 'file-abc123def456ghi789', + completion_window: '24h', + model_id: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo', + priority: 1, + }); + }); + + test('retrieve', async () => { + const responsePromise = client.batches.retrieve('batch_job_abc123def456'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.batches.retrieve('batch_job_abc123def456', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Together.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.batches.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.batches.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Together.NotFoundError, + ); + }); +}); From c075e7eb2a447d4dfc6aca0f283f760f80c277a3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 19:20:10 +0000 Subject: [PATCH 41/49] refactor(types): replace Record with mapped types --- src/resources/chat/completions.ts | 4 ++-- src/resources/code-interpreter/code-interpreter.ts | 10 +++++----- src/resources/code-interpreter/sessions.ts | 2 +- src/resources/completions.ts | 4 ++-- src/resources/top-level.ts | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 4491b91b..e0a5bde4 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -338,7 +338,7 @@ export interface CompletionCreateParamsBase { /** * Adjusts the likelihood of specific tokens appearing in the generated output. */ - logit_bias?: Record; + logit_bias?: { [key: string]: number }; /** * Integer (0 or 1) that controls whether log probabilities of generated tokens are @@ -527,7 +527,7 @@ export namespace CompletionCreateParams { /** * The schema of the response format. */ - schema?: Record; + schema?: { [key: string]: unknown }; /** * The type of the response format. diff --git a/src/resources/code-interpreter/code-interpreter.ts b/src/resources/code-interpreter/code-interpreter.ts index b346e220..bf8b4f32 100644 --- a/src/resources/code-interpreter/code-interpreter.ts +++ b/src/resources/code-interpreter/code-interpreter.ts @@ -89,17 +89,17 @@ export namespace ExecuteResponse { export namespace DisplayorExecuteOutput { export interface Data { - 'application/geo+json'?: Record; + 'application/geo+json'?: { [key: string]: unknown }; 'application/javascript'?: string; - 'application/json'?: Record; + 'application/json'?: { [key: string]: unknown }; 'application/pdf'?: string; - 'application/vnd.vega.v5+json'?: Record; + 'application/vnd.vega.v5+json'?: { [key: string]: unknown }; - 'application/vnd.vegalite.v4+json'?: Record; + 'application/vnd.vegalite.v4+json'?: { [key: string]: unknown }; 'image/gif'?: string; @@ -124,7 +124,7 @@ export namespace ExecuteResponse { export interface FailedExecution { data: null; - errors: Array>; + errors: Array; } } diff --git a/src/resources/code-interpreter/sessions.ts b/src/resources/code-interpreter/sessions.ts index ea891a8c..104e92f3 100644 --- a/src/resources/code-interpreter/sessions.ts +++ b/src/resources/code-interpreter/sessions.ts @@ -21,7 +21,7 @@ export class Sessions extends APIResource { export interface SessionListResponse { data?: SessionListResponse.Data; - errors?: Array>; + errors?: Array; } export namespace SessionListResponse { diff --git a/src/resources/completions.ts b/src/resources/completions.ts index d9ce23ec..d6d789c3 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -189,7 +189,7 @@ export namespace Tools { /** * A map of parameter names to their values. */ - parameters?: Record; + parameters?: { [key: string]: unknown }; } } @@ -228,7 +228,7 @@ export interface CompletionCreateParamsBase { /** * Adjusts the likelihood of specific tokens appearing in the generated output. */ - logit_bias?: Record; + logit_bias?: { [key: string]: number }; /** * Integer (0 or 1) that controls whether log probabilities of generated tokens are diff --git a/src/resources/top-level.ts b/src/resources/top-level.ts index a34be94c..cea1b4da 100644 --- a/src/resources/top-level.ts +++ b/src/resources/top-level.ts @@ -43,7 +43,7 @@ export interface RerankParams { /** * List of documents, which can be either strings or objects. */ - documents: Array> | Array; + documents: Array<{ [key: string]: unknown }> | Array; /** * The model to be used for the rerank request. From 9b41a241c1d5a89b610ea76b96955b6896f433f1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 22:20:36 +0000 Subject: [PATCH 42/49] chore(api): re-enable audio unit tests Now that codegen issue is fixed, reenable the audio tests. --- .stats.yml | 2 +- tests/api-resources/audio.test.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index fcc638d2..f801d735 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 33 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-9ca24c17ccf9b0b4c2d27c09881dc74bf4cb44efc7a5ccb7d54fa15caee095d1.yml openapi_spec_hash: 306c08678a0677f1deb1d35def6f8713 -config_hash: fa59b4c1ab0a2e74aa855e7227b10c7d +config_hash: ae07f8cefe84a8a01ae2d0c8ddc2ef32 diff --git a/tests/api-resources/audio.test.ts b/tests/api-resources/audio.test.ts index ac734ffa..f6baacac 100644 --- a/tests/api-resources/audio.test.ts +++ b/tests/api-resources/audio.test.ts @@ -8,8 +8,7 @@ const client = new Together({ }); describe('resource audio', () => { - // AttributeError: BinaryAPIResponse object has no attribute response - test.skip('create: required and optional params', async () => { + test('create: required and optional params', async () => { const response = await client.audio.create({ input: 'input', model: 'cartesia/sonic', From 1b53f5b8e355bf392c5da836b315d1c067e70023 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 14:06:04 +0000 Subject: [PATCH 43/49] =?UTF-8?q?fix(ci):=20release-doctor=20=E2=80=94=20r?= =?UTF-8?q?eport=20correct=20token=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/check-release-environment | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/check-release-environment b/bin/check-release-environment index 88071232..e4b6d58e 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -3,7 +3,7 @@ errors=() if [ -z "${NPM_TOKEN}" ]; then - errors+=("The TOGETHER_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi lenErrors=${#errors[@]} From e361be3aa6fd65031e99018c0f2dd88d819c8657 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 15:23:20 +0000 Subject: [PATCH 44/49] feat(api): api update --- .stats.yml | 4 ++-- src/resources/chat/completions.ts | 5 +++-- src/resources/completions.ts | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index f801d735..789cb89a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 33 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-9ca24c17ccf9b0b4c2d27c09881dc74bf4cb44efc7a5ccb7d54fa15caee095d1.yml -openapi_spec_hash: 306c08678a0677f1deb1d35def6f8713 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-3b15429fd18e4e400f69d6470041f6daa1ca3ad87d8644652c70d2c2f1987874.yml +openapi_spec_hash: 93a8442f9c29913ddea87215b545ec38 config_hash: ae07f8cefe84a8a01ae2d0c8ddc2ef32 diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index e0a5bde4..f05ffb38 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -341,8 +341,9 @@ export interface CompletionCreateParamsBase { logit_bias?: { [key: string]: number }; /** - * Integer (0 or 1) that controls whether log probabilities of generated tokens are - * returned. Log probabilities help assess model confidence in token predictions. + * An integer between 0 and 20 of the top k tokens to return log probabilities for + * at each generation step, instead of just the sampled token. Log probabilities + * help assess model confidence in token predictions. */ logprobs?: number; diff --git a/src/resources/completions.ts b/src/resources/completions.ts index d6d789c3..c9e003a8 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -231,8 +231,9 @@ export interface CompletionCreateParamsBase { logit_bias?: { [key: string]: number }; /** - * Integer (0 or 1) that controls whether log probabilities of generated tokens are - * returned. Log probabilities help assess model confidence in token predictions. + * An integer between 0 and 20 of the top k tokens to return log probabilities for + * at each generation step, instead of just the sampled token. Log probabilities + * help assess model confidence in token predictions. */ logprobs?: number; From 4411078dad04fdfa6247e6b127d29248a796859c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 16:23:06 +0000 Subject: [PATCH 45/49] feat(api): api update --- .stats.yml | 4 ++-- src/resources/chat/completions.ts | 39 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 789cb89a..934a5794 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 33 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-3b15429fd18e4e400f69d6470041f6daa1ca3ad87d8644652c70d2c2f1987874.yml -openapi_spec_hash: 93a8442f9c29913ddea87215b545ec38 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-0587b28a7ae7d241b442a774d024d83dc7d3aaea6d51ecc9bb825888f53a60ce.yml +openapi_spec_hash: 2bccc6c37221bacda7bc3f486fc4684d config_hash: ae07f8cefe84a8a01ae2d0c8ddc2ef32 diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index f05ffb38..9e5127c4 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -465,6 +465,8 @@ export namespace CompletionCreateParams { | ChatCompletionsAPI.ChatCompletionStructuredMessageText | ChatCompletionsAPI.ChatCompletionStructuredMessageImageURL | ChatCompletionsAPI.ChatCompletionStructuredMessageVideoURL + | ChatCompletionUserMessageParam.Audio + | ChatCompletionUserMessageParam.InputAudio >; role: 'user'; @@ -472,6 +474,43 @@ export namespace CompletionCreateParams { name?: string; } + export namespace ChatCompletionUserMessageParam { + export interface Audio { + audio_url: Audio.AudioURL; + + type: 'audio_url'; + } + + export namespace Audio { + export interface AudioURL { + /** + * The URL of the audio + */ + url: string; + } + } + + export interface InputAudio { + input_audio: InputAudio.InputAudio; + + type: 'input_audio'; + } + + export namespace InputAudio { + export interface InputAudio { + /** + * The base64 encoded audio data + */ + data: string; + + /** + * The format of the audio data + */ + format: 'wav'; + } + } + } + export interface ChatCompletionAssistantMessageParam { role: 'assistant'; From 0c5464dcd9a3038f15ff738db569a567efd2d001 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 22:38:19 +0000 Subject: [PATCH 46/49] chore(ci): only run for pushes and fork pull requests --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 673920b6..aeb4491d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/togetherai-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 @@ -35,6 +36,7 @@ jobs: timeout-minutes: 5 name: build runs-on: ${{ github.repository == 'stainless-sdks/togetherai-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork permissions: contents: read id-token: write @@ -70,6 +72,7 @@ jobs: timeout-minutes: 10 name: test runs-on: ${{ github.repository == 'stainless-sdks/togetherai-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 From a645c765478cb8213913a0173e0706cacafbe4fc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Jul 2025 18:11:36 +0000 Subject: [PATCH 47/49] chore: mention unit type in timeout docs --- src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.ts b/src/index.ts index 6a40c245..a4eae989 100644 --- a/src/index.ts +++ b/src/index.ts @@ -106,6 +106,8 @@ export interface ClientOptions { * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. + * + * @unit milliseconds */ timeout?: number | undefined; From 06b1e89b57bc17c433468d197198e648a785d1a1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Jul 2025 22:01:57 +0000 Subject: [PATCH 48/49] fix(client): don't send `Content-Type` for bodyless methods --- src/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.ts b/src/core.ts index 779e349a..fb94da09 100644 --- a/src/core.ts +++ b/src/core.ts @@ -231,7 +231,7 @@ export abstract class APIClient { protected defaultHeaders(opts: FinalRequestOptions): Headers { return { Accept: 'application/json', - 'Content-Type': 'application/json', + ...(['head', 'get'].includes(opts.method) ? {} : { 'Content-Type': 'application/json' }), 'User-Agent': this.getUserAgent(), ...getPlatformHeaders(), ...this.authHeaders(opts), From 163c9343266868e8c9635c1ffe25369593ded0e0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Jul 2025 22:02:21 +0000 Subject: [PATCH 49/49] release: 0.17.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 60 +++++++++++++++++++++++++++++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index bc7e4aae..7b51ca08 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.16.0" + ".": "0.17.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index d7764b09..304ca798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,65 @@ # Changelog +## 0.17.0 (2025-07-02) + +Full Changelog: [v0.16.0...v0.17.0](https://github.com/togethercomputer/together-typescript/compare/v0.16.0...v0.17.0) + +### Features + +* **api:** add batch api to config ([d51bc5a](https://github.com/togethercomputer/together-typescript/commit/d51bc5aef6cdc4d28ece075adaae4e21b3ad9c28)) +* **api:** Add file_type and file_purpose ([c48b452](https://github.com/togethercomputer/together-typescript/commit/c48b452006a360c32dc4c270740b3e7c8e5ea5b8)) +* **api:** add files/upload apu support and switch upload_file method over to use it. ([c365c86](https://github.com/togethercomputer/together-typescript/commit/c365c86033d20ef677e95707ccd4b3fe43c679a2)) +* **api:** address diagnostic issues in audio api, correct openapi issue in images api, disambiguate a response in finetune api, enable automated testing on finetune and images ([9ab1b66](https://github.com/togethercomputer/together-typescript/commit/9ab1b661c4d830b982e1e2a5a184564c9c16e815)) +* **api:** api update ([4411078](https://github.com/togethercomputer/together-typescript/commit/4411078dad04fdfa6247e6b127d29248a796859c)) +* **api:** api update ([e361be3](https://github.com/togethercomputer/together-typescript/commit/e361be3aa6fd65031e99018c0f2dd88d819c8657)) +* **api:** api update ([850a7da](https://github.com/togethercomputer/together-typescript/commit/850a7da0fcc711164290db4a88e07e31762e9d1f)) +* **api:** api update ([5d0865a](https://github.com/togethercomputer/together-typescript/commit/5d0865add14b040531018e85e59a38ee805a5a41)) +* **api:** api update ([f06baab](https://github.com/togethercomputer/together-typescript/commit/f06baab288f7f54d73ad803550b9f3ce55ab6756)) +* **api:** api update ([8de2307](https://github.com/togethercomputer/together-typescript/commit/8de23078f5b12ace4df74173a0e5fa0c86528d2d)) +* **api:** api update ([d7d7c68](https://github.com/togethercomputer/together-typescript/commit/d7d7c686ca1a2c665d58323bbc5498671c4ee5ef)) +* **api:** api update ([d7b7e65](https://github.com/togethercomputer/together-typescript/commit/d7b7e65ffab825567353d021f8ea1715a0e3b578)) +* **api:** api update ([a149f12](https://github.com/togethercomputer/together-typescript/commit/a149f12a4ed7d852aef5448c827d86bbebe2ebf4)) +* **api:** api update ([dac80cc](https://github.com/togethercomputer/together-typescript/commit/dac80cc60458d89fced596b22a3700be3d7a6c04)) +* **api:** api update ([418cdbf](https://github.com/togethercomputer/together-typescript/commit/418cdbf1c267c33e2f01e4b3d48aa21c6a618268)) +* **api:** Formatting fixes, some lint fixes ([ba11056](https://github.com/togethercomputer/together-typescript/commit/ba11056c22c6ce4ab829356d35a4c31540a2d5e1)) +* **api:** get test_code_interpreter passing ([426d647](https://github.com/togethercomputer/together-typescript/commit/426d647fa45c2220f7293f26c1b79336c0e948df)) +* **api:** update spec / config to remove remaining codegen warnings ([c7c3a91](https://github.com/togethercomputer/together-typescript/commit/c7c3a914e2b0bb866b01ba48a04add83bbb387cd)) +* **api:** Update spec and config to get all tests except code-interpolation an fine_tune unit tests working. ([ac5a26e](https://github.com/togethercomputer/together-typescript/commit/ac5a26e7a65e66e3e7cdb3e83dbe75016c1f785f)) +* **client:** add support for endpoint-specific base URLs ([7d7bb0c](https://github.com/togethercomputer/together-typescript/commit/7d7bb0c308b909713ef0a0fedbe7acea59594946)) + + +### Bug Fixes + +* **ci:** release-doctor — report correct token name ([1b53f5b](https://github.com/togethercomputer/together-typescript/commit/1b53f5b8e355bf392c5da836b315d1c067e70023)) +* **client:** don't send `Content-Type` for bodyless methods ([06b1e89](https://github.com/togethercomputer/together-typescript/commit/06b1e89b57bc17c433468d197198e648a785d1a1)) +* publish script — handle NPM errors correctly ([471c909](https://github.com/togethercomputer/together-typescript/commit/471c909ff1918076168d6dd221561c94a24bd947)) +* **tests:** format ([0ad22a6](https://github.com/togethercomputer/together-typescript/commit/0ad22a67f73dce1d4d596c353a31be5abbd1e092)) +* **tests:** remove unused tests ([26a5b65](https://github.com/togethercomputer/together-typescript/commit/26a5b65b48b4a20ac75cdc92b27c55e26b686382)) + + +### Chores + +* **api:** re-enable audio unit tests ([9b41a24](https://github.com/togethercomputer/together-typescript/commit/9b41a241c1d5a89b610ea76b96955b6896f433f1)) +* **ci:** bump node version for release workflows ([328ac07](https://github.com/togethercomputer/together-typescript/commit/328ac079658f878a74a28c3683e340bed6f15876)) +* **ci:** enable for pull requests ([e393ec0](https://github.com/togethercomputer/together-typescript/commit/e393ec0952cb571617df474597a8bdbdfbdf86ff)) +* **ci:** only run for pushes and fork pull requests ([0c5464d](https://github.com/togethercomputer/together-typescript/commit/0c5464dcd9a3038f15ff738db569a567efd2d001)) +* **docs:** grammar improvements ([fcc89b0](https://github.com/togethercomputer/together-typescript/commit/fcc89b0d13f7907fdb33ab23398ebae0003ec96e)) +* **docs:** use top-level-await in example snippets ([24e6833](https://github.com/togethercomputer/together-typescript/commit/24e68333612469dcd5ec1bbd30993cb1d46ed61d)) +* improve publish-npm script --latest tag logic ([6efef6c](https://github.com/togethercomputer/together-typescript/commit/6efef6c02fb2160f1b1a0ac33d128e4b45bf7ef3)) +* **internal:** make base APIResource abstract ([d64b679](https://github.com/togethercomputer/together-typescript/commit/d64b6790659e223a1e003396d39dcd95fe35ef0e)) +* mention unit type in timeout docs ([a645c76](https://github.com/togethercomputer/together-typescript/commit/a645c765478cb8213913a0173e0706cacafbe4fc)) + + +### Documentation + +* add examples to tsdocs ([e3bdd28](https://github.com/togethercomputer/together-typescript/commit/e3bdd286bdca4d56cae2b106f15283f594b05200)) +* **readme:** fix typo ([29c08f6](https://github.com/togethercomputer/together-typescript/commit/29c08f6c4126aa2a576aea5cbc0d16b033a9a04e)) + + +### Refactors + +* **types:** replace Record with mapped types ([c075e7e](https://github.com/togethercomputer/together-typescript/commit/c075e7eb2a447d4dfc6aca0f283f760f80c277a3)) + ## 0.16.0 (2025-04-28) Full Changelog: [v0.15.2...v0.16.0](https://github.com/togethercomputer/together-typescript/compare/v0.15.2...v0.16.0) diff --git a/package.json b/package.json index ef6a0e04..a3d99a25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "together-ai", - "version": "0.16.0", + "version": "0.17.0", "description": "The official TypeScript library for the Together API", "author": "Together ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index be03af20..0251da7d 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.16.0'; // x-release-please-version +export const VERSION = '0.17.0'; // x-release-please-version