From c142180b4080274664f7e0228df757734b4faf93 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:18:23 +0000 Subject: [PATCH 1/3] SDK regeneration --- package.json | 2 +- src/Client.ts | 22 ++++---- src/api/resources/connectors/client/Client.ts | 12 ++--- src/api/resources/datasets/client/Client.ts | 51 +++---------------- src/api/resources/embedJobs/client/Client.ts | 8 +-- src/api/types/Dataset.ts | 2 + src/api/types/SingleGenerationInStream.ts | 3 ++ src/serialization/types/Dataset.ts | 10 ++++ .../types/SingleGenerationInStream.ts | 5 ++ 9 files changed, 49 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index 200875b..f3f64b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cohere-ai", - "version": "7.7.2", + "version": "7.7.3", "private": false, "repository": "https://github.com/cohere-ai/cohere-typescript", "main": "./index.js", diff --git a/src/Client.ts b/src/Client.ts index 48e0277..134512c 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -52,7 +52,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: { @@ -124,7 +124,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: { @@ -187,7 +187,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: { @@ -266,7 +266,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: { @@ -342,7 +342,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.EmbedRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -409,7 +409,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.RerankRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -472,7 +472,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.ClassifyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -544,7 +544,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.DetectLanguageRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -604,7 +604,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.SummarizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -666,7 +666,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.TokenizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -733,7 +733,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.DetokenizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), diff --git a/src/api/resources/connectors/client/Client.ts b/src/api/resources/connectors/client/Client.ts index 7c7b22a..0eebefa 100644 --- a/src/api/resources/connectors/client/Client.ts +++ b/src/api/resources/connectors/client/Client.ts @@ -61,7 +61,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", queryParameters: _queryParams, @@ -131,7 +131,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.CreateConnectorRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -200,7 +200,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -275,7 +275,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -350,7 +350,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.UpdateConnectorRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -434,7 +434,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", queryParameters: _queryParams, diff --git a/src/api/resources/datasets/client/Client.ts b/src/api/resources/datasets/client/Client.ts index 62c095b..64541af 100644 --- a/src/api/resources/datasets/client/Client.ts +++ b/src/api/resources/datasets/client/Client.ts @@ -73,7 +73,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", queryParameters: _queryParams, @@ -116,55 +116,18 @@ export class Datasets { * Create a dataset by uploading a file. See ['Dataset Creation'](https://docs.cohere.com/docs/datasets#dataset-creation) for more information. */ public async create( - request: Cohere.DatasetsCreateRequest, data: File | fs.ReadStream, - evalData?: File | fs.ReadStream, + evalData: File | fs.ReadStream, requestOptions?: Datasets.RequestOptions ): Promise { const _request = new FormData(); _request.append("data", data); - if (evalData) { - _request.append("eval_data", evalData); - } - - const _queryParams: any = {} - - if (request.name != null) { - _queryParams["name"] = request.name; - } - - if (request.type != null) { - _queryParams["type"] = request.type; - } - - if (request.keepOriginalFile != null) { - _queryParams["keep_original_file"] = request.keepOriginalFile; - } - if (request.skipMalformedInput != null) { - _queryParams["skip_malformed_input"] = request.skipMalformedInput; - } - if (request.keepFields != null) { - _queryParams["keep_fields"] = request.keepFields; - } - - if (request.optionalFields != null) { - _queryParams["optional_fields"] = request.optionalFields; - } - - if (request.textSeparator != null) { - _queryParams["text_separator"] = request.textSeparator; - } - - if (request.csvDelimiter != null) { - _queryParams["csv_delimiter"] = request.csvDelimiter; - } - + _request.append("eval_data", evalData); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, "datasets" ), - queryParameters: _queryParams, method: "POST", headers: { Authorization: await this._getAuthorizationHeader(), @@ -174,7 +137,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "multipart/form-data; boundary=" + _request.getBoundary(), body: _request, @@ -234,7 +197,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -293,7 +256,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -352,7 +315,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, diff --git a/src/api/resources/embedJobs/client/Client.ts b/src/api/resources/embedJobs/client/Client.ts index e967855..41565c1 100644 --- a/src/api/resources/embedJobs/client/Client.ts +++ b/src/api/resources/embedJobs/client/Client.ts @@ -48,7 +48,7 @@ export class EmbedJobs { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -116,7 +116,7 @@ export class EmbedJobs { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", body: await serializers.CreateEmbedJobRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -183,7 +183,7 @@ export class EmbedJobs { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -254,7 +254,7 @@ export class EmbedJobs { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.2", + "X-Fern-SDK-Version": "7.7.3", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, diff --git a/src/api/types/Dataset.ts b/src/api/types/Dataset.ts index e0c3641..6f2b965 100644 --- a/src/api/types/Dataset.ts +++ b/src/api/types/Dataset.ts @@ -13,6 +13,8 @@ export interface Dataset { createdAt: Date; /** The last update date */ updatedAt: Date; + datasetType: Cohere.DatasetType; + validationStatus: Cohere.DatasetValidationStatus; /** Errors found during validation */ validationError?: string; /** the avro schema of the dataset */ diff --git a/src/api/types/SingleGenerationInStream.ts b/src/api/types/SingleGenerationInStream.ts index 5bb1394..74a1644 100644 --- a/src/api/types/SingleGenerationInStream.ts +++ b/src/api/types/SingleGenerationInStream.ts @@ -2,10 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as Cohere from ".."; + export interface SingleGenerationInStream { id: string; /** Full text of the generation. */ text: string; /** Refers to the nth generation. Only present when `num_generations` is greater than zero. */ index?: number; + finishReason: Cohere.FinishReason; } diff --git a/src/serialization/types/Dataset.ts b/src/serialization/types/Dataset.ts index 2bd8ebb..1e64824 100644 --- a/src/serialization/types/Dataset.ts +++ b/src/serialization/types/Dataset.ts @@ -12,6 +12,14 @@ export const Dataset: core.serialization.ObjectSchema (await import("..")).DatasetType) + ), + validationStatus: core.serialization.property( + "validation_status", + core.serialization.lazy(async () => (await import("..")).DatasetValidationStatus) + ), validationError: core.serialization.property("validation_error", core.serialization.string().optional()), schema: core.serialization.string().optional(), requiredFields: core.serialization.property( @@ -40,6 +48,8 @@ export declare namespace Dataset { name: string; created_at: string; updated_at: string; + dataset_type: serializers.DatasetType.Raw; + validation_status: serializers.DatasetValidationStatus.Raw; validation_error?: string | null; schema?: string | null; required_fields?: string[] | null; diff --git a/src/serialization/types/SingleGenerationInStream.ts b/src/serialization/types/SingleGenerationInStream.ts index 48ca473..409c965 100644 --- a/src/serialization/types/SingleGenerationInStream.ts +++ b/src/serialization/types/SingleGenerationInStream.ts @@ -13,6 +13,10 @@ export const SingleGenerationInStream: core.serialization.ObjectSchema< id: core.serialization.string(), text: core.serialization.string(), index: core.serialization.number().optional(), + finishReason: core.serialization.property( + "finish_reason", + core.serialization.lazy(async () => (await import("..")).FinishReason) + ), }); export declare namespace SingleGenerationInStream { @@ -20,5 +24,6 @@ export declare namespace SingleGenerationInStream { id: string; text: string; index?: number | null; + finish_reason: serializers.FinishReason.Raw; } } From 09298269a8d5aac84804eb661a90893bd173cae2 Mon Sep 17 00:00:00 2001 From: billytrend-cohere <144115527+billytrend-cohere@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:39:16 +0000 Subject: [PATCH 2/3] Make evalData optional --- src/api/resources/datasets/client/Client.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/resources/datasets/client/Client.ts b/src/api/resources/datasets/client/Client.ts index 64541af..1b029ea 100644 --- a/src/api/resources/datasets/client/Client.ts +++ b/src/api/resources/datasets/client/Client.ts @@ -117,12 +117,14 @@ export class Datasets { */ public async create( data: File | fs.ReadStream, - evalData: File | fs.ReadStream, + evalData?: File | fs.ReadStream, requestOptions?: Datasets.RequestOptions ): Promise { const _request = new FormData(); _request.append("data", data); - _request.append("eval_data", evalData); + if (evalData) { + _request.append("eval_data", evalData); + } const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, From d5e7d55c8abde2fe790876c728b5823f9472b561 Mon Sep 17 00:00:00 2001 From: billytrend-cohere <144115527+billytrend-cohere@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:20:01 +0000 Subject: [PATCH 3/3] Add _queryParams --- src/api/resources/datasets/client/Client.ts | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/api/resources/datasets/client/Client.ts b/src/api/resources/datasets/client/Client.ts index 1b029ea..9788997 100644 --- a/src/api/resources/datasets/client/Client.ts +++ b/src/api/resources/datasets/client/Client.ts @@ -116,6 +116,7 @@ export class Datasets { * Create a dataset by uploading a file. See ['Dataset Creation'](https://docs.cohere.com/docs/datasets#dataset-creation) for more information. */ public async create( + request: Cohere.DatasetsCreateRequest, data: File | fs.ReadStream, evalData?: File | fs.ReadStream, requestOptions?: Datasets.RequestOptions @@ -125,11 +126,45 @@ export class Datasets { if (evalData) { _request.append("eval_data", evalData); } + + const _queryParams: any = {} + + if (request.name != null) { + _queryParams["name"] = request.name; + } + + if (request.type != null) { + _queryParams["type"] = request.type; + } + + if (request.keepOriginalFile != null) { + _queryParams["keep_original_file"] = request.keepOriginalFile; + } + if (request.skipMalformedInput != null) { + _queryParams["skip_malformed_input"] = request.skipMalformedInput; + } + if (request.keepFields != null) { + _queryParams["keep_fields"] = request.keepFields; + } + + if (request.optionalFields != null) { + _queryParams["optional_fields"] = request.optionalFields; + } + + if (request.textSeparator != null) { + _queryParams["text_separator"] = request.textSeparator; + } + + if (request.csvDelimiter != null) { + _queryParams["csv_delimiter"] = request.csvDelimiter; + } + const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, "datasets" ), + queryParameters: _queryParams, method: "POST", headers: { Authorization: await this._getAuthorizationHeader(),