diff --git a/package.json b/package.json
index 315ccd6a..b4098700 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cohere-ai",
- "version": "7.15.1",
+ "version": "7.15.2",
"private": false,
"repository": "https://github.com/cohere-ai/cohere-typescript",
"main": "./index.js",
@@ -17,9 +17,9 @@
"formdata-node": "^6.0.3",
"node-fetch": "2.7.0",
"qs": "6.11.2",
+ "readable-stream": "^4.5.2",
"js-base64": "3.7.2",
"form-data-encoder": "^4.0.2",
- "readable-stream": "^4.5.2",
"@aws-sdk/client-sagemaker": "^3.583.0",
"@aws-sdk/credential-providers": "^3.583.0",
"@aws-sdk/protocol-http": "^3.374.0",
@@ -30,7 +30,9 @@
"@types/url-join": "4.0.1",
"@types/qs": "6.9.8",
"@types/node-fetch": "2.6.9",
- "fetch-mock-jest": "^1.5.1",
+ "@types/readable-stream": "^4.0.14",
+ "webpack": "^5.91.0",
+ "ts-loader": "^9.5.1",
"jest": "^29.7.0",
"@types/jest": "29.5.5",
"ts-jest": "^29.1.2",
@@ -38,9 +40,6 @@
"@types/node": "17.0.33",
"prettier": "2.7.1",
"typescript": "4.6.4",
- "@types/readable-stream": "^4.0.14",
- "ts-loader": "^9.5.1",
- "webpack": "^5.91.0",
"@types/convict": "^6.1.6"
},
"browser": {
diff --git a/reference.md b/reference.md
index 3c35f502..e8a10e48 100644
--- a/reference.md
+++ b/reference.md
@@ -71,7 +71,7 @@ await client.checkApiKey();
-
-Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api).
+Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api).
Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2) for instructions on moving from API v1 to API v2.
@@ -89,48 +89,19 @@ Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2)
-
```typescript
-await client.v2.chatStream({
- model: "string",
+const response = await client.v2.chatStream({
+ model: "model",
messages: [
{
- role: "user",
- content: "string",
- },
- ],
- tools: [
- {
- type: "function",
- function: {
- name: "string",
- description: "string",
- parameters: {
- string: {
- key: "value",
- },
- },
- },
+ role: "tool",
+ toolCallId: "messages",
+ content: "messages",
},
],
- strictTools: true,
- documents: ["string"],
- citationOptions: {
- mode: Cohere.CitationOptionsMode.Fast,
- },
- responseFormat: {
- type: "text",
- },
- safetyMode: Cohere.V2ChatStreamRequestSafetyMode.Contextual,
- maxTokens: 1,
- stopSequences: ["string"],
- temperature: 1.1,
- seed: 1,
- frequencyPenalty: 1.1,
- presencePenalty: 1.1,
- k: 1.1,
- p: 1.1,
- returnPrompt: true,
- logprobs: true,
});
+for await (const item of response) {
+ console.log(item);
+}
```
@@ -273,8 +244,8 @@ If you want to learn more how to use the embedding model, have a look at the [Se
```typescript
await client.v2.embed({
model: "model",
- inputType: Cohere.EmbedInputType.SearchDocument,
- embeddingTypes: [Cohere.EmbeddingType.Float],
+ inputType: "search_document",
+ embeddingTypes: ["float"],
});
```
@@ -465,7 +436,7 @@ This API launches an async Embed job for a [Dataset](https://docs.cohere.com/doc
await client.embedJobs.create({
model: "model",
datasetId: "dataset_id",
- inputType: Cohere.EmbedInputType.SearchDocument,
+ inputType: "search_document",
});
```
@@ -722,7 +693,7 @@ Create a dataset by uploading a file. See ['Dataset Creation'](https://docs.cohe
```typescript
await client.datasets.create(fs.createReadStream("/path/to/your/file"), fs.createReadStream("/path/to/your/file"), {
name: "name",
- type: Cohere.DatasetType.EmbedInput,
+ type: "embed-input",
});
```
@@ -1549,7 +1520,7 @@ await client.finetuning.createFinetunedModel({
name: "api-test",
settings: {
baseModel: {
- baseType: Cohere.BaseType.BaseTypeChat,
+ baseType: "BASE_TYPE_CHAT",
},
datasetId: "my-dataset-id",
},
@@ -1701,7 +1672,7 @@ await client.finetuning.updateFinetunedModel("id", {
name: "name",
settings: {
baseModel: {
- baseType: Cohere.BaseType.BaseTypeUnspecified,
+ baseType: "BASE_TYPE_UNSPECIFIED",
},
datasetId: "dataset_id",
},
diff --git a/src/Client.ts b/src/Client.ts
index 48717632..8f95b472 100644
--- a/src/Client.ts
+++ b/src/Client.ts
@@ -34,14 +34,48 @@ export declare namespace CohereClient {
abortSignal?: AbortSignal;
/** Override the X-Client-Name header */
clientName?: string | undefined;
+ /** Additional headers to include in the request. */
+ headers?: Record;
}
}
export class CohereClient {
+ protected _v2: V2 | undefined;
+ protected _embedJobs: EmbedJobs | undefined;
+ protected _datasets: Datasets | undefined;
+ protected _connectors: Connectors | undefined;
+ protected _models: Models | undefined;
+ protected _finetuning: Finetuning | undefined;
+
constructor(protected readonly _options: CohereClient.Options = {}) {}
+ public get v2(): V2 {
+ return (this._v2 ??= new V2(this._options));
+ }
+
+ public get embedJobs(): EmbedJobs {
+ return (this._embedJobs ??= new EmbedJobs(this._options));
+ }
+
+ public get datasets(): Datasets {
+ return (this._datasets ??= new Datasets(this._options));
+ }
+
+ public get connectors(): Connectors {
+ return (this._connectors ??= new Connectors(this._options));
+ }
+
+ public get models(): Models {
+ return (this._models ??= new Models(this._options));
+ }
+
+ public get finetuning(): Finetuning {
+ return (this._finetuning ??= new Finetuning(this._options));
+ }
+
/**
- * Generates a text response to a user message.
+ * Generates a streamed text response to a user message.
+ *
* To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
*/
public async chatStream(
@@ -63,11 +97,12 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
Accepts: accepts != null ? accepts : undefined,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -115,59 +150,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -183,7 +180,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/chat.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -204,6 +201,7 @@ export class CohereClient {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -218,7 +216,7 @@ export class CohereClient {
* }, {
* role: "TOOL"
* }],
- * promptTruncation: Cohere.ChatRequestPromptTruncation.Off,
+ * promptTruncation: "OFF",
* temperature: 0.3
* })
*/
@@ -241,11 +239,12 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
Accepts: accepts != null ? accepts : undefined,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -282,59 +281,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -350,7 +311,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/chat.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -382,10 +343,11 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -433,59 +395,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -501,7 +425,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/generate.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -524,6 +448,7 @@ export class CohereClient {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -553,10 +478,11 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -593,59 +519,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -661,7 +549,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/generate.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -685,6 +573,7 @@ export class CohereClient {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -712,10 +601,11 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -749,59 +639,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -817,7 +669,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/embed.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -837,6 +689,7 @@ export class CohereClient {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -867,10 +720,11 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -904,59 +758,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -972,7 +788,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/rerank.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -993,6 +809,7 @@ export class CohereClient {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -1022,10 +839,11 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -1059,59 +877,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -1127,7 +907,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/classify.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -1150,6 +930,7 @@ export class CohereClient {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -1179,10 +960,11 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -1216,59 +998,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -1284,7 +1028,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/summarize.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -1304,6 +1048,7 @@ export class CohereClient {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -1334,10 +1079,11 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -1371,59 +1117,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -1439,7 +1147,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/tokenize.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -1459,6 +1167,7 @@ export class CohereClient {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -1489,10 +1198,11 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -1526,59 +1236,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -1594,7 +1266,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/detokenize.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -1613,6 +1285,7 @@ export class CohereClient {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -1637,10 +1310,11 @@ export class CohereClient {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -1669,59 +1343,21 @@ export class CohereClient {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -1737,7 +1373,7 @@ export class CohereClient {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/check-api-key.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -1745,42 +1381,6 @@ export class CohereClient {
}
}
- protected _v2: V2 | undefined;
-
- public get v2(): V2 {
- return (this._v2 ??= new V2(this._options));
- }
-
- protected _embedJobs: EmbedJobs | undefined;
-
- public get embedJobs(): EmbedJobs {
- return (this._embedJobs ??= new EmbedJobs(this._options));
- }
-
- protected _datasets: Datasets | undefined;
-
- public get datasets(): Datasets {
- return (this._datasets ??= new Datasets(this._options));
- }
-
- protected _connectors: Connectors | undefined;
-
- public get connectors(): Connectors {
- return (this._connectors ??= new Connectors(this._options));
- }
-
- protected _models: Models | undefined;
-
- public get models(): Models {
- return (this._models ??= new Models(this._options));
- }
-
- protected _finetuning: Finetuning | undefined;
-
- public get finetuning(): Finetuning {
- return (this._finetuning ??= new Finetuning(this._options));
- }
-
protected async _getAuthorizationHeader(): Promise {
const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["CO_API_KEY"];
if (bearer == null) {
diff --git a/src/api/client/requests/ChatRequest.ts b/src/api/client/requests/ChatRequest.ts
index 61dde805..d27824ea 100644
--- a/src/api/client/requests/ChatRequest.ts
+++ b/src/api/client/requests/ChatRequest.ts
@@ -13,7 +13,7 @@ import * as Cohere from "../../index";
* }, {
* role: "TOOL"
* }],
- * promptTruncation: Cohere.ChatRequestPromptTruncation.Off,
+ * promptTruncation: "OFF",
* temperature: 0.3
* }
*/
diff --git a/src/api/client/requests/ChatStreamRequest.ts b/src/api/client/requests/ChatStreamRequest.ts
index 271ae6d0..119115b0 100644
--- a/src/api/client/requests/ChatStreamRequest.ts
+++ b/src/api/client/requests/ChatStreamRequest.ts
@@ -7,86 +7,14 @@ import * as Cohere from "../../index";
/**
* @example
* {
- * accepts: "text/event-stream",
- * message: "string",
- * model: "string",
- * preamble: "string",
+ * message: "Can you give me a global market overview of solar panels?",
* chatHistory: [{
- * role: "CHATBOT",
- * message: "string",
- * toolCalls: [{
- * name: "string",
- * parameters: {
- * "string": {
- * "key": "value"
- * }
- * }
- * }]
+ * role: "TOOL"
+ * }, {
+ * role: "TOOL"
* }],
- * conversationId: "string",
- * promptTruncation: Cohere.ChatStreamRequestPromptTruncation.Off,
- * connectors: [{
- * id: "string",
- * userAccessToken: "string",
- * continueOnFailure: true,
- * options: {
- * "string": {
- * "key": "value"
- * }
- * }
- * }],
- * searchQueriesOnly: true,
- * documents: [{
- * "string": {
- * "key": "value"
- * }
- * }],
- * citationQuality: Cohere.ChatStreamRequestCitationQuality.Fast,
- * temperature: 1.1,
- * maxTokens: 1,
- * maxInputTokens: 1,
- * k: 1,
- * p: 1.1,
- * seed: 1,
- * stopSequences: ["string"],
- * connectorsSearchOptions: {
- * seed: 1
- * },
- * frequencyPenalty: 1.1,
- * presencePenalty: 1.1,
- * rawPrompting: true,
- * returnPrompt: true,
- * tools: [{
- * name: "string",
- * description: "string",
- * parameterDefinitions: {
- * "string": {
- * description: "string",
- * type: "string",
- * required: true
- * }
- * }
- * }],
- * toolResults: [{
- * call: {
- * name: "string",
- * parameters: {
- * "string": {
- * "key": "value"
- * }
- * }
- * },
- * outputs: [{
- * "string": {
- * "key": "value"
- * }
- * }]
- * }],
- * forceSingleStep: true,
- * responseFormat: {
- * type: "text"
- * },
- * safetyMode: Cohere.ChatStreamRequestSafetyMode.Contextual
+ * promptTruncation: "OFF",
+ * temperature: 0.3
* }
*/
export interface ChatStreamRequest {
diff --git a/src/api/client/requests/GenerateStreamRequest.ts b/src/api/client/requests/GenerateStreamRequest.ts
index 67dd10d3..4d2b3f97 100644
--- a/src/api/client/requests/GenerateStreamRequest.ts
+++ b/src/api/client/requests/GenerateStreamRequest.ts
@@ -7,22 +7,7 @@ import * as Cohere from "../../index";
/**
* @example
* {
- * prompt: "string",
- * model: "string",
- * numGenerations: 1,
- * maxTokens: 1,
- * truncate: Cohere.GenerateStreamRequestTruncate.None,
- * temperature: 1.1,
- * seed: 1,
- * preset: "string",
- * endSequences: ["string"],
- * stopSequences: ["string"],
- * k: 1,
- * p: 1.1,
- * frequencyPenalty: 1.1,
- * presencePenalty: 1.1,
- * returnLikelihoods: Cohere.GenerateStreamRequestReturnLikelihoods.Generation,
- * rawPrompting: true
+ * prompt: "Please explain to me how LLMs work"
* }
*/
export interface GenerateStreamRequest {
diff --git a/src/api/errors/ClientClosedRequestError.ts b/src/api/errors/ClientClosedRequestError.ts
index aebadb27..1c6f3d52 100644
--- a/src/api/errors/ClientClosedRequestError.ts
+++ b/src/api/errors/ClientClosedRequestError.ts
@@ -3,10 +3,9 @@
*/
import * as errors from "../../errors/index";
-import * as Cohere from "../index";
export class ClientClosedRequestError extends errors.CohereError {
- constructor(body: Cohere.ClientClosedRequestErrorBody) {
+ constructor(body?: unknown) {
super({
message: "ClientClosedRequestError",
statusCode: 499,
diff --git a/src/api/errors/GatewayTimeoutError.ts b/src/api/errors/GatewayTimeoutError.ts
index 45d9667a..2cf3fe7a 100644
--- a/src/api/errors/GatewayTimeoutError.ts
+++ b/src/api/errors/GatewayTimeoutError.ts
@@ -3,10 +3,9 @@
*/
import * as errors from "../../errors/index";
-import * as Cohere from "../index";
export class GatewayTimeoutError extends errors.CohereError {
- constructor(body: Cohere.GatewayTimeoutErrorBody) {
+ constructor(body?: unknown) {
super({
message: "GatewayTimeoutError",
statusCode: 504,
diff --git a/src/api/errors/InvalidTokenError.ts b/src/api/errors/InvalidTokenError.ts
new file mode 100644
index 00000000..e3f4cfd4
--- /dev/null
+++ b/src/api/errors/InvalidTokenError.ts
@@ -0,0 +1,16 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+
+import * as errors from "../../errors/index";
+
+export class InvalidTokenError extends errors.CohereError {
+ constructor(body?: unknown) {
+ super({
+ message: "InvalidTokenError",
+ statusCode: 498,
+ body: body,
+ });
+ Object.setPrototypeOf(this, InvalidTokenError.prototype);
+ }
+}
diff --git a/src/api/errors/NotImplementedError.ts b/src/api/errors/NotImplementedError.ts
index 091027ba..e0f57e30 100644
--- a/src/api/errors/NotImplementedError.ts
+++ b/src/api/errors/NotImplementedError.ts
@@ -3,10 +3,9 @@
*/
import * as errors from "../../errors/index";
-import * as Cohere from "../index";
export class NotImplementedError extends errors.CohereError {
- constructor(body: Cohere.NotImplementedErrorBody) {
+ constructor(body?: unknown) {
super({
message: "NotImplementedError",
statusCode: 501,
diff --git a/src/api/errors/TooManyRequestsError.ts b/src/api/errors/TooManyRequestsError.ts
index c7fdf0d6..525080b5 100644
--- a/src/api/errors/TooManyRequestsError.ts
+++ b/src/api/errors/TooManyRequestsError.ts
@@ -3,10 +3,9 @@
*/
import * as errors from "../../errors/index";
-import * as Cohere from "../index";
export class TooManyRequestsError extends errors.CohereError {
- constructor(body: Cohere.TooManyRequestsErrorBody) {
+ constructor(body?: unknown) {
super({
message: "TooManyRequestsError",
statusCode: 429,
diff --git a/src/api/errors/UnprocessableEntityError.ts b/src/api/errors/UnprocessableEntityError.ts
index a7c30c81..5bde21b6 100644
--- a/src/api/errors/UnprocessableEntityError.ts
+++ b/src/api/errors/UnprocessableEntityError.ts
@@ -3,10 +3,9 @@
*/
import * as errors from "../../errors/index";
-import * as Cohere from "../index";
export class UnprocessableEntityError extends errors.CohereError {
- constructor(body: Cohere.UnprocessableEntityErrorBody) {
+ constructor(body?: unknown) {
super({
message: "UnprocessableEntityError",
statusCode: 422,
diff --git a/src/api/errors/index.ts b/src/api/errors/index.ts
index cb601a98..651fac27 100644
--- a/src/api/errors/index.ts
+++ b/src/api/errors/index.ts
@@ -4,6 +4,7 @@ export * from "./ForbiddenError";
export * from "./NotFoundError";
export * from "./UnprocessableEntityError";
export * from "./TooManyRequestsError";
+export * from "./InvalidTokenError";
export * from "./ClientClosedRequestError";
export * from "./InternalServerError";
export * from "./NotImplementedError";
diff --git a/src/api/resources/connectors/client/Client.ts b/src/api/resources/connectors/client/Client.ts
index 7eef5094..5d4c79fc 100644
--- a/src/api/resources/connectors/client/Client.ts
+++ b/src/api/resources/connectors/client/Client.ts
@@ -27,6 +27,8 @@ export declare namespace Connectors {
abortSignal?: AbortSignal;
/** Override the X-Client-Name header */
clientName?: string | undefined;
+ /** Additional headers to include in the request. */
+ headers?: Record;
}
}
@@ -45,6 +47,7 @@ export class Connectors {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -82,10 +85,11 @@ export class Connectors {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
queryParameters: _queryParams,
@@ -115,59 +119,21 @@ export class Connectors {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -183,7 +149,7 @@ export class Connectors {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/connectors.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -203,6 +169,7 @@ export class Connectors {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -233,10 +200,11 @@ export class Connectors {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -270,59 +238,21 @@ export class Connectors {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -338,7 +268,7 @@ export class Connectors {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/connectors.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -358,6 +288,7 @@ export class Connectors {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -382,10 +313,11 @@ export class Connectors {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -414,59 +346,21 @@ export class Connectors {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -482,7 +376,7 @@ export class Connectors {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/connectors/{id}.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -502,6 +396,7 @@ export class Connectors {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -529,10 +424,11 @@ export class Connectors {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -561,59 +457,21 @@ export class Connectors {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -629,7 +487,7 @@ export class Connectors {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling DELETE /v1/connectors/{id}.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -650,6 +508,7 @@ export class Connectors {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -678,10 +537,11 @@ export class Connectors {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -715,59 +575,21 @@ export class Connectors {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -783,7 +605,7 @@ export class Connectors {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling PATCH /v1/connectors/{id}.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -792,7 +614,7 @@ export class Connectors {
}
/**
- * Authorize the connector with the given ID for the connector oauth app. See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information.
+ * Authorize the connector with the given ID for the connector oauth app. See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information.
*
* @param {string} id - The ID of the connector to authorize.
* @param {Cohere.ConnectorsOAuthAuthorizeRequest} request
@@ -804,6 +626,7 @@ export class Connectors {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -838,10 +661,11 @@ export class Connectors {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
queryParameters: _queryParams,
@@ -871,59 +695,21 @@ export class Connectors {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -939,7 +725,9 @@ export class Connectors {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError(
+ "Timeout exceeded when calling POST /v1/connectors/{id}/oauth/authorize."
+ );
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
diff --git a/src/api/resources/datasets/client/Client.ts b/src/api/resources/datasets/client/Client.ts
index 32a0332c..3be3fb0f 100644
--- a/src/api/resources/datasets/client/Client.ts
+++ b/src/api/resources/datasets/client/Client.ts
@@ -29,6 +29,8 @@ export declare namespace Datasets {
abortSignal?: AbortSignal;
/** Override the X-Client-Name header */
clientName?: string | undefined;
+ /** Additional headers to include in the request. */
+ headers?: Record;
}
}
@@ -47,6 +49,7 @@ export class Datasets {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -100,9 +103,11 @@ export class Datasets {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.12.0",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
queryParameters: _queryParams,
@@ -132,59 +137,21 @@ export class Datasets {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -200,7 +167,7 @@ export class Datasets {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/datasets.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -222,6 +189,7 @@ export class Datasets {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -231,7 +199,7 @@ export class Datasets {
* @example
* await client.datasets.create(fs.createReadStream("/path/to/your/file"), fs.createReadStream("/path/to/your/file"), {
* name: "name",
- * type: Cohere.DatasetType.EmbedInput
+ * type: "embed-input"
* })
*/
public async create(
@@ -280,9 +248,9 @@ export class Datasets {
}
const _request = await core.newFormData();
- await _request.appendFile("data", data, (data as File)?.name);
+ await _request.appendFile("data", data);
if (evalData != null) {
- await _request.appendFile("eval_data", evalData, (evalData as File)?.name);
+ await _request.appendFile("eval_data", evalData);
}
const _maybeEncodedRequest = await _request.getRequest();
@@ -300,10 +268,12 @@ export class Datasets {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.12.0",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
..._maybeEncodedRequest.headers,
+ ...requestOptions?.headers,
},
queryParameters: _queryParams,
requestType: "file",
@@ -334,59 +304,21 @@ export class Datasets {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -402,7 +334,7 @@ export class Datasets {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/datasets.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -421,6 +353,7 @@ export class Datasets {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -445,9 +378,11 @@ export class Datasets {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.12.0",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -476,59 +411,21 @@ export class Datasets {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -544,7 +441,7 @@ export class Datasets {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/datasets/usage.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -564,6 +461,7 @@ export class Datasets {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -588,9 +486,11 @@ export class Datasets {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.12.0",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -619,59 +519,21 @@ export class Datasets {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -687,7 +549,7 @@ export class Datasets {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/datasets/{id}.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -707,6 +569,7 @@ export class Datasets {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -731,9 +594,11 @@ export class Datasets {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.12.0",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -762,59 +627,21 @@ export class Datasets {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -830,7 +657,7 @@ export class Datasets {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling DELETE /v1/datasets/{id}.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
diff --git a/src/api/resources/datasets/client/requests/DatasetsCreateRequest.ts b/src/api/resources/datasets/client/requests/DatasetsCreateRequest.ts
index 87b1f5f4..21f4845c 100644
--- a/src/api/resources/datasets/client/requests/DatasetsCreateRequest.ts
+++ b/src/api/resources/datasets/client/requests/DatasetsCreateRequest.ts
@@ -8,7 +8,7 @@ import * as Cohere from "../../../../index";
* @example
* {
* name: "name",
- * type: Cohere.DatasetType.EmbedInput
+ * type: "embed-input"
* }
*/
export interface DatasetsCreateRequest {
diff --git a/src/api/resources/embedJobs/client/Client.ts b/src/api/resources/embedJobs/client/Client.ts
index 77fc10c1..7e15957e 100644
--- a/src/api/resources/embedJobs/client/Client.ts
+++ b/src/api/resources/embedJobs/client/Client.ts
@@ -27,6 +27,8 @@ export declare namespace EmbedJobs {
abortSignal?: AbortSignal;
/** Override the X-Client-Name header */
clientName?: string | undefined;
+ /** Additional headers to include in the request. */
+ headers?: Record;
}
}
@@ -44,6 +46,7 @@ export class EmbedJobs {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -68,10 +71,11 @@ export class EmbedJobs {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -100,59 +104,21 @@ export class EmbedJobs {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -168,7 +134,7 @@ export class EmbedJobs {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/embed-jobs.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -188,6 +154,7 @@ export class EmbedJobs {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -198,7 +165,7 @@ export class EmbedJobs {
* await client.embedJobs.create({
* model: "model",
* datasetId: "dataset_id",
- * inputType: Cohere.EmbedInputType.SearchDocument
+ * inputType: "search_document"
* })
*/
public async create(
@@ -219,10 +186,11 @@ export class EmbedJobs {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -256,59 +224,21 @@ export class EmbedJobs {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -324,7 +254,7 @@ export class EmbedJobs {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/embed-jobs.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -344,6 +274,7 @@ export class EmbedJobs {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -368,10 +299,11 @@ export class EmbedJobs {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -400,59 +332,21 @@ export class EmbedJobs {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -468,7 +362,7 @@ export class EmbedJobs {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/embed-jobs/{id}.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -488,6 +382,7 @@ export class EmbedJobs {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -512,10 +407,11 @@ export class EmbedJobs {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -538,59 +434,21 @@ export class EmbedJobs {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -606,7 +464,7 @@ export class EmbedJobs {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v1/embed-jobs/{id}/cancel.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
diff --git a/src/api/resources/embedJobs/client/requests/CreateEmbedJobRequest.ts b/src/api/resources/embedJobs/client/requests/CreateEmbedJobRequest.ts
index c747ed03..974b8509 100644
--- a/src/api/resources/embedJobs/client/requests/CreateEmbedJobRequest.ts
+++ b/src/api/resources/embedJobs/client/requests/CreateEmbedJobRequest.ts
@@ -9,7 +9,7 @@ import * as Cohere from "../../../../index";
* {
* model: "model",
* datasetId: "dataset_id",
- * inputType: Cohere.EmbedInputType.SearchDocument
+ * inputType: "search_document"
* }
*/
export interface CreateEmbedJobRequest {
diff --git a/src/api/resources/embedJobs/types/CreateEmbedJobRequestTruncate.ts b/src/api/resources/embedJobs/types/CreateEmbedJobRequestTruncate.ts
index 711e8c6d..7a98132b 100644
--- a/src/api/resources/embedJobs/types/CreateEmbedJobRequestTruncate.ts
+++ b/src/api/resources/embedJobs/types/CreateEmbedJobRequestTruncate.ts
@@ -8,7 +8,6 @@
* Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.
*/
export type CreateEmbedJobRequestTruncate = "START" | "END";
-
export const CreateEmbedJobRequestTruncate = {
Start: "START",
End: "END",
diff --git a/src/api/resources/finetuning/client/Client.ts b/src/api/resources/finetuning/client/Client.ts
index c8b67b24..d76a8053 100644
--- a/src/api/resources/finetuning/client/Client.ts
+++ b/src/api/resources/finetuning/client/Client.ts
@@ -27,6 +27,8 @@ export declare namespace Finetuning {
abortSignal?: AbortSignal;
/** Override the X-Client-Name header */
clientName?: string | undefined;
+ /** Additional headers to include in the request. */
+ headers?: Record;
}
}
@@ -82,10 +84,11 @@ export class Finetuning {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
queryParameters: _queryParams,
@@ -133,7 +136,9 @@ export class Finetuning {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError(
+ "Timeout exceeded when calling GET /v1/finetuning/finetuned-models."
+ );
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -157,7 +162,7 @@ export class Finetuning {
* name: "api-test",
* settings: {
* baseModel: {
- * baseType: Cohere.finetuning.BaseType.BaseTypeChat
+ * baseType: "BASE_TYPE_CHAT"
* },
* datasetId: "my-dataset-id"
* }
@@ -181,10 +186,11 @@ export class Finetuning {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -236,7 +242,9 @@ export class Finetuning {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError(
+ "Timeout exceeded when calling POST /v1/finetuning/finetuned-models."
+ );
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -276,10 +284,11 @@ export class Finetuning {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -326,7 +335,9 @@ export class Finetuning {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError(
+ "Timeout exceeded when calling GET /v1/finetuning/finetuned-models/{id}."
+ );
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -366,10 +377,11 @@ export class Finetuning {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -416,7 +428,9 @@ export class Finetuning {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError(
+ "Timeout exceeded when calling DELETE /v1/finetuning/finetuned-models/{id}."
+ );
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -441,7 +455,7 @@ export class Finetuning {
* name: "name",
* settings: {
* baseModel: {
- * baseType: Cohere.finetuning.BaseType.BaseTypeUnspecified
+ * baseType: "BASE_TYPE_UNSPECIFIED"
* },
* datasetId: "dataset_id"
* }
@@ -466,10 +480,11 @@ export class Finetuning {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -521,7 +536,9 @@ export class Finetuning {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError(
+ "Timeout exceeded when calling PATCH /v1/finetuning/finetuned-models/{id}."
+ );
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -577,10 +594,11 @@ export class Finetuning {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
queryParameters: _queryParams,
@@ -628,7 +646,9 @@ export class Finetuning {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError(
+ "Timeout exceeded when calling GET /v1/finetuning/finetuned-models/{finetuned_model_id}/events."
+ );
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -680,10 +700,11 @@ export class Finetuning {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
queryParameters: _queryParams,
@@ -731,7 +752,9 @@ export class Finetuning {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError(
+ "Timeout exceeded when calling GET /v1/finetuning/finetuned-models/{finetuned_model_id}/training-step-metrics."
+ );
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
diff --git a/src/api/resources/finetuning/client/requests/FinetuningListEventsRequest.ts b/src/api/resources/finetuning/client/requests/FinetuningListEventsRequest.ts
index b96e5bd4..0d771bfc 100644
--- a/src/api/resources/finetuning/client/requests/FinetuningListEventsRequest.ts
+++ b/src/api/resources/finetuning/client/requests/FinetuningListEventsRequest.ts
@@ -8,7 +8,8 @@
*/
export interface FinetuningListEventsRequest {
/**
- * Maximum number of results to be returned by the server. If 0, defaults to 50.
+ * Maximum number of results to be returned by the server. If 0, defaults to
+ * 50.
*/
pageSize?: number;
/**
@@ -21,8 +22,7 @@ export interface FinetuningListEventsRequest {
* " desc" to the field name. For example: "created_at desc,name".
*
* Supported sorting fields:
- *
- * - created_at (default)
+ * - created_at (default)
*/
orderBy?: string;
}
diff --git a/src/api/resources/finetuning/client/requests/FinetuningListFinetunedModelsRequest.ts b/src/api/resources/finetuning/client/requests/FinetuningListFinetunedModelsRequest.ts
index 833f92db..48ea8b27 100644
--- a/src/api/resources/finetuning/client/requests/FinetuningListFinetunedModelsRequest.ts
+++ b/src/api/resources/finetuning/client/requests/FinetuningListFinetunedModelsRequest.ts
@@ -8,7 +8,8 @@
*/
export interface FinetuningListFinetunedModelsRequest {
/**
- * Maximum number of results to be returned by the server. If 0, defaults to 50.
+ * Maximum number of results to be returned by the server. If 0, defaults to
+ * 50.
*/
pageSize?: number;
/**
@@ -21,8 +22,7 @@ export interface FinetuningListFinetunedModelsRequest {
* " desc" to the field name. For example: "created_at desc,name".
*
* Supported sorting fields:
- *
- * - created_at (default)
+ * - created_at (default)
*/
orderBy?: string;
}
diff --git a/src/api/resources/finetuning/client/requests/FinetuningListTrainingStepMetricsRequest.ts b/src/api/resources/finetuning/client/requests/FinetuningListTrainingStepMetricsRequest.ts
index 535c0b83..b9661fec 100644
--- a/src/api/resources/finetuning/client/requests/FinetuningListTrainingStepMetricsRequest.ts
+++ b/src/api/resources/finetuning/client/requests/FinetuningListTrainingStepMetricsRequest.ts
@@ -8,7 +8,8 @@
*/
export interface FinetuningListTrainingStepMetricsRequest {
/**
- * Maximum number of results to be returned by the server. If 0, defaults to 50.
+ * Maximum number of results to be returned by the server. If 0, defaults to
+ * 50.
*/
pageSize?: number;
/**
diff --git a/src/api/resources/finetuning/client/requests/FinetuningUpdateFinetunedModelRequest.ts b/src/api/resources/finetuning/client/requests/FinetuningUpdateFinetunedModelRequest.ts
index e8a2bbc9..ac5e06a5 100644
--- a/src/api/resources/finetuning/client/requests/FinetuningUpdateFinetunedModelRequest.ts
+++ b/src/api/resources/finetuning/client/requests/FinetuningUpdateFinetunedModelRequest.ts
@@ -10,7 +10,7 @@ import * as Cohere from "../../../../index";
* name: "name",
* settings: {
* baseModel: {
- * baseType: Cohere.finetuning.BaseType.BaseTypeUnspecified
+ * baseType: "BASE_TYPE_UNSPECIFIED"
* },
* datasetId: "dataset_id"
* }
diff --git a/src/api/resources/finetuning/resources/finetuning/types/BaseType.ts b/src/api/resources/finetuning/resources/finetuning/types/BaseType.ts
index 43ab778a..20b88699 100644
--- a/src/api/resources/finetuning/resources/finetuning/types/BaseType.ts
+++ b/src/api/resources/finetuning/resources/finetuning/types/BaseType.ts
@@ -5,11 +5,11 @@
/**
* The possible types of fine-tuned models.
*
- * - BASE_TYPE_UNSPECIFIED: Unspecified model.
- * - BASE_TYPE_GENERATIVE: Deprecated: Generative model.
- * - BASE_TYPE_CLASSIFICATION: Classification model.
- * - BASE_TYPE_RERANK: Rerank model.
- * - BASE_TYPE_CHAT: Chat model.
+ * - BASE_TYPE_UNSPECIFIED: Unspecified model.
+ * - BASE_TYPE_GENERATIVE: Deprecated: Generative model.
+ * - BASE_TYPE_CLASSIFICATION: Classification model.
+ * - BASE_TYPE_RERANK: Rerank model.
+ * - BASE_TYPE_CHAT: Chat model.
*/
export type BaseType =
| "BASE_TYPE_UNSPECIFIED"
@@ -17,7 +17,6 @@ export type BaseType =
| "BASE_TYPE_CLASSIFICATION"
| "BASE_TYPE_RERANK"
| "BASE_TYPE_CHAT";
-
export const BaseType = {
BaseTypeUnspecified: "BASE_TYPE_UNSPECIFIED",
BaseTypeGenerative: "BASE_TYPE_GENERATIVE",
diff --git a/src/api/resources/finetuning/resources/finetuning/types/LoraTargetModules.ts b/src/api/resources/finetuning/resources/finetuning/types/LoraTargetModules.ts
index e8430eab..b3c17c8b 100644
--- a/src/api/resources/finetuning/resources/finetuning/types/LoraTargetModules.ts
+++ b/src/api/resources/finetuning/resources/finetuning/types/LoraTargetModules.ts
@@ -5,17 +5,16 @@
/**
* The possible combinations of LoRA modules to target.
*
- * - LORA_TARGET_MODULES_UNSPECIFIED: Unspecified LoRA target modules.
- * - LORA_TARGET_MODULES_QV: LoRA adapts the query and value matrices in transformer attention layers.
- * - LORA_TARGET_MODULES_QKVO: LoRA adapts query, key, value, and output matrices in attention layers.
- * - LORA_TARGET_MODULES_QKVO_FFN: LoRA adapts attention projection matrices and feed-forward networks (FFN).
+ * - LORA_TARGET_MODULES_UNSPECIFIED: Unspecified LoRA target modules.
+ * - LORA_TARGET_MODULES_QV: LoRA adapts the query and value matrices in transformer attention layers.
+ * - LORA_TARGET_MODULES_QKVO: LoRA adapts query, key, value, and output matrices in attention layers.
+ * - LORA_TARGET_MODULES_QKVO_FFN: LoRA adapts attention projection matrices and feed-forward networks (FFN).
*/
export type LoraTargetModules =
| "LORA_TARGET_MODULES_UNSPECIFIED"
| "LORA_TARGET_MODULES_QV"
| "LORA_TARGET_MODULES_QKVO"
| "LORA_TARGET_MODULES_QKVO_FFN";
-
export const LoraTargetModules = {
LoraTargetModulesUnspecified: "LORA_TARGET_MODULES_UNSPECIFIED",
LoraTargetModulesQv: "LORA_TARGET_MODULES_QV",
diff --git a/src/api/resources/finetuning/resources/finetuning/types/Status.ts b/src/api/resources/finetuning/resources/finetuning/types/Status.ts
index 9718b49a..04f72b89 100644
--- a/src/api/resources/finetuning/resources/finetuning/types/Status.ts
+++ b/src/api/resources/finetuning/resources/finetuning/types/Status.ts
@@ -5,15 +5,15 @@
/**
* The possible stages of a fine-tuned model life-cycle.
*
- * - STATUS_UNSPECIFIED: Unspecified status.
- * - STATUS_FINETUNING: The fine-tuned model is being fine-tuned.
- * - STATUS_DEPLOYING_API: Deprecated: The fine-tuned model is being deployed.
- * - STATUS_READY: The fine-tuned model is ready to receive requests.
- * - STATUS_FAILED: The fine-tuned model failed.
- * - STATUS_DELETED: The fine-tuned model was deleted.
- * - STATUS_TEMPORARILY_OFFLINE: Deprecated: The fine-tuned model is temporarily unavailable.
- * - STATUS_PAUSED: Deprecated: The fine-tuned model is paused (Vanilla only).
- * - STATUS_QUEUED: The fine-tuned model is queued for training.
+ * - STATUS_UNSPECIFIED: Unspecified status.
+ * - STATUS_FINETUNING: The fine-tuned model is being fine-tuned.
+ * - STATUS_DEPLOYING_API: Deprecated: The fine-tuned model is being deployed.
+ * - STATUS_READY: The fine-tuned model is ready to receive requests.
+ * - STATUS_FAILED: The fine-tuned model failed.
+ * - STATUS_DELETED: The fine-tuned model was deleted.
+ * - STATUS_TEMPORARILY_OFFLINE: Deprecated: The fine-tuned model is temporarily unavailable.
+ * - STATUS_PAUSED: Deprecated: The fine-tuned model is paused (Vanilla only).
+ * - STATUS_QUEUED: The fine-tuned model is queued for training.
*/
export type Status =
| "STATUS_UNSPECIFIED"
@@ -25,7 +25,6 @@ export type Status =
| "STATUS_TEMPORARILY_OFFLINE"
| "STATUS_PAUSED"
| "STATUS_QUEUED";
-
export const Status = {
StatusUnspecified: "STATUS_UNSPECIFIED",
StatusFinetuning: "STATUS_FINETUNING",
diff --git a/src/api/resources/finetuning/resources/finetuning/types/Strategy.ts b/src/api/resources/finetuning/resources/finetuning/types/Strategy.ts
index c1e47c15..455569d8 100644
--- a/src/api/resources/finetuning/resources/finetuning/types/Strategy.ts
+++ b/src/api/resources/finetuning/resources/finetuning/types/Strategy.ts
@@ -5,12 +5,11 @@
/**
* The possible strategy used to serve a fine-tuned models.
*
- * - STRATEGY_UNSPECIFIED: Unspecified strategy.
- * - STRATEGY_VANILLA: Deprecated: Serve the fine-tuned model on a dedicated GPU.
- * - STRATEGY_TFEW: Deprecated: Serve the fine-tuned model on a shared GPU.
+ * - STRATEGY_UNSPECIFIED: Unspecified strategy.
+ * - STRATEGY_VANILLA: Deprecated: Serve the fine-tuned model on a dedicated GPU.
+ * - STRATEGY_TFEW: Deprecated: Serve the fine-tuned model on a shared GPU.
*/
export type Strategy = "STRATEGY_UNSPECIFIED" | "STRATEGY_VANILLA" | "STRATEGY_TFEW";
-
export const Strategy = {
StrategyUnspecified: "STRATEGY_UNSPECIFIED",
StrategyVanilla: "STRATEGY_VANILLA",
diff --git a/src/api/resources/models/client/Client.ts b/src/api/resources/models/client/Client.ts
index 8723b5fe..28dfefff 100644
--- a/src/api/resources/models/client/Client.ts
+++ b/src/api/resources/models/client/Client.ts
@@ -27,6 +27,8 @@ export declare namespace Models {
abortSignal?: AbortSignal;
/** Override the X-Client-Name header */
clientName?: string | undefined;
+ /** Additional headers to include in the request. */
+ headers?: Record;
}
}
@@ -45,6 +47,7 @@ export class Models {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -69,10 +72,11 @@ export class Models {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -101,59 +105,21 @@ export class Models {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -169,7 +135,7 @@ export class Models {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/models/{model}.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -189,6 +155,7 @@ export class Models {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -234,10 +201,11 @@ export class Models {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
queryParameters: _queryParams,
@@ -267,59 +235,21 @@ export class Models {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -335,7 +265,7 @@ export class Models {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling GET /v1/models.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
diff --git a/src/api/resources/v2/client/Client.ts b/src/api/resources/v2/client/Client.ts
index 5401fad0..98091411 100644
--- a/src/api/resources/v2/client/Client.ts
+++ b/src/api/resources/v2/client/Client.ts
@@ -28,6 +28,8 @@ export declare namespace V2 {
abortSignal?: AbortSignal;
/** Override the X-Client-Name header */
clientName?: string | undefined;
+ /** Additional headers to include in the request. */
+ headers?: Record;
}
}
@@ -35,7 +37,7 @@ export class V2 {
constructor(protected readonly _options: V2.Options = {}) {}
/**
- * Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api).
+ * Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api).
*
* Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2) for instructions on moving from API v1 to API v2.
*/
@@ -57,10 +59,11 @@ export class V2 {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -108,59 +111,21 @@ export class V2 {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -176,7 +141,7 @@ export class V2 {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v2/chat.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -198,6 +163,7 @@ export class V2 {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -229,10 +195,11 @@ export class V2 {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -269,59 +236,21 @@ export class V2 {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -337,7 +266,7 @@ export class V2 {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v2/chat.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -361,6 +290,7 @@ export class V2 {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -370,8 +300,8 @@ export class V2 {
* @example
* await client.v2.embed({
* model: "model",
- * inputType: Cohere.EmbedInputType.SearchDocument,
- * embeddingTypes: [Cohere.EmbeddingType.Float]
+ * inputType: "search_document",
+ * embeddingTypes: ["float"]
* })
*/
public async embed(
@@ -392,10 +322,11 @@ export class V2 {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -429,59 +360,21 @@ export class V2 {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -497,7 +390,7 @@ export class V2 {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v2/embed.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
@@ -517,6 +410,7 @@ export class V2 {
* @throws {@link Cohere.NotFoundError}
* @throws {@link Cohere.UnprocessableEntityError}
* @throws {@link Cohere.TooManyRequestsError}
+ * @throws {@link Cohere.InvalidTokenError}
* @throws {@link Cohere.ClientClosedRequestError}
* @throws {@link Cohere.InternalServerError}
* @throws {@link Cohere.NotImplementedError}
@@ -548,10 +442,11 @@ export class V2 {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "cohere-ai",
- "X-Fern-SDK-Version": "7.15.1",
- "User-Agent": "cohere-ai/7.15.1",
+ "X-Fern-SDK-Version": "7.15.2",
+ "User-Agent": "cohere-ai/7.15.2",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
+ ...requestOptions?.headers,
},
contentType: "application/json",
requestType: "json",
@@ -585,59 +480,21 @@ export class V2 {
case 404:
throw new Cohere.NotFoundError(_response.error.body);
case 422:
- throw new Cohere.UnprocessableEntityError(
- serializers.UnprocessableEntityErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.UnprocessableEntityError(_response.error.body);
case 429:
- throw new Cohere.TooManyRequestsError(
- serializers.TooManyRequestsErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.TooManyRequestsError(_response.error.body);
+ case 498:
+ throw new Cohere.InvalidTokenError(_response.error.body);
case 499:
- throw new Cohere.ClientClosedRequestError(
- serializers.ClientClosedRequestErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.ClientClosedRequestError(_response.error.body);
case 500:
throw new Cohere.InternalServerError(_response.error.body);
case 501:
- throw new Cohere.NotImplementedError(
- serializers.NotImplementedErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.NotImplementedError(_response.error.body);
case 503:
throw new Cohere.ServiceUnavailableError(_response.error.body);
case 504:
- throw new Cohere.GatewayTimeoutError(
- serializers.GatewayTimeoutErrorBody.parseOrThrow(_response.error.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- })
- );
+ throw new Cohere.GatewayTimeoutError(_response.error.body);
default:
throw new errors.CohereError({
statusCode: _response.error.statusCode,
@@ -653,7 +510,7 @@ export class V2 {
body: _response.error.rawBody,
});
case "timeout":
- throw new errors.CohereTimeoutError();
+ throw new errors.CohereTimeoutError("Timeout exceeded when calling POST /v2/rerank.");
case "unknown":
throw new errors.CohereError({
message: _response.error.errorMessage,
diff --git a/src/api/resources/v2/client/requests/V2ChatStreamRequest.ts b/src/api/resources/v2/client/requests/V2ChatStreamRequest.ts
index 4042b0e5..2e283fb7 100644
--- a/src/api/resources/v2/client/requests/V2ChatStreamRequest.ts
+++ b/src/api/resources/v2/client/requests/V2ChatStreamRequest.ts
@@ -7,42 +7,12 @@ import * as Cohere from "../../../../index";
/**
* @example
* {
- * model: "string",
+ * model: "model",
* messages: [{
- * role: "user",
- * content: "string"
- * }],
- * tools: [{
- * type: "function",
- * function: {
- * name: "string",
- * description: "string",
- * parameters: {
- * "string": {
- * "key": "value"
- * }
- * }
- * }
- * }],
- * strictTools: true,
- * documents: ["string"],
- * citationOptions: {
- * mode: Cohere.CitationOptionsMode.Fast
- * },
- * responseFormat: {
- * type: "text"
- * },
- * safetyMode: Cohere.V2ChatStreamRequestSafetyMode.Contextual,
- * maxTokens: 1,
- * stopSequences: ["string"],
- * temperature: 1.1,
- * seed: 1,
- * frequencyPenalty: 1.1,
- * presencePenalty: 1.1,
- * k: 1.1,
- * p: 1.1,
- * returnPrompt: true,
- * logprobs: true
+ * role: "tool",
+ * toolCallId: "messages",
+ * content: "messages"
+ * }]
* }
*/
export interface V2ChatStreamRequest {
diff --git a/src/api/resources/v2/client/requests/V2EmbedRequest.ts b/src/api/resources/v2/client/requests/V2EmbedRequest.ts
index ba0776d9..59a133bf 100644
--- a/src/api/resources/v2/client/requests/V2EmbedRequest.ts
+++ b/src/api/resources/v2/client/requests/V2EmbedRequest.ts
@@ -8,8 +8,8 @@ import * as Cohere from "../../../../index";
* @example
* {
* model: "model",
- * inputType: Cohere.EmbedInputType.SearchDocument,
- * embeddingTypes: [Cohere.EmbeddingType.Float]
+ * inputType: "search_document",
+ * embeddingTypes: ["float"]
* }
*/
export interface V2EmbedRequest {
diff --git a/src/api/resources/v2/types/V2ChatRequestSafetyMode.ts b/src/api/resources/v2/types/V2ChatRequestSafetyMode.ts
index 93468ab9..6b92cc81 100644
--- a/src/api/resources/v2/types/V2ChatRequestSafetyMode.ts
+++ b/src/api/resources/v2/types/V2ChatRequestSafetyMode.ts
@@ -13,7 +13,6 @@
* **Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.
*/
export type V2ChatRequestSafetyMode = "CONTEXTUAL" | "STRICT" | "OFF";
-
export const V2ChatRequestSafetyMode = {
Contextual: "CONTEXTUAL",
Strict: "STRICT",
diff --git a/src/api/resources/v2/types/V2ChatStreamRequestSafetyMode.ts b/src/api/resources/v2/types/V2ChatStreamRequestSafetyMode.ts
index 670bfdca..f1db0698 100644
--- a/src/api/resources/v2/types/V2ChatStreamRequestSafetyMode.ts
+++ b/src/api/resources/v2/types/V2ChatStreamRequestSafetyMode.ts
@@ -13,7 +13,6 @@
* **Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.
*/
export type V2ChatStreamRequestSafetyMode = "CONTEXTUAL" | "STRICT" | "OFF";
-
export const V2ChatStreamRequestSafetyMode = {
Contextual: "CONTEXTUAL",
Strict: "STRICT",
diff --git a/src/api/resources/v2/types/V2EmbedRequestTruncate.ts b/src/api/resources/v2/types/V2EmbedRequestTruncate.ts
index 4ee1ce6e..5c1ed7cb 100644
--- a/src/api/resources/v2/types/V2EmbedRequestTruncate.ts
+++ b/src/api/resources/v2/types/V2EmbedRequestTruncate.ts
@@ -10,7 +10,6 @@
* If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
*/
export type V2EmbedRequestTruncate = "NONE" | "START" | "END";
-
export const V2EmbedRequestTruncate = {
None: "NONE",
Start: "START",
diff --git a/src/api/types/AssistantMessageContentItem.ts b/src/api/types/AssistantMessageContentItem.ts
index 091f5414..63c4b6b9 100644
--- a/src/api/types/AssistantMessageContentItem.ts
+++ b/src/api/types/AssistantMessageContentItem.ts
@@ -6,8 +6,8 @@ import * as Cohere from "../index";
export type AssistantMessageContentItem = Cohere.AssistantMessageContentItem.Text;
-export declare namespace AssistantMessageContentItem {
- interface Text extends Cohere.TextContent {
+export namespace AssistantMessageContentItem {
+ export interface Text extends Cohere.TextContent {
type: "text";
}
}
diff --git a/src/api/types/AssistantMessageResponseContentItem.ts b/src/api/types/AssistantMessageResponseContentItem.ts
index 500efce2..96d96338 100644
--- a/src/api/types/AssistantMessageResponseContentItem.ts
+++ b/src/api/types/AssistantMessageResponseContentItem.ts
@@ -6,8 +6,8 @@ import * as Cohere from "../index";
export type AssistantMessageResponseContentItem = Cohere.AssistantMessageResponseContentItem.Text;
-export declare namespace AssistantMessageResponseContentItem {
- interface Text extends Cohere.TextContent {
+export namespace AssistantMessageResponseContentItem {
+ export interface Text extends Cohere.TextContent {
type: "text";
}
}
diff --git a/src/api/types/AuthTokenType.ts b/src/api/types/AuthTokenType.ts
index 02bcc6ac..4d8af59f 100644
--- a/src/api/types/AuthTokenType.ts
+++ b/src/api/types/AuthTokenType.ts
@@ -6,7 +6,6 @@
* The token_type specifies the way the token is passed in the Authorization header. Valid values are "bearer", "basic", and "noscheme".
*/
export type AuthTokenType = "bearer" | "basic" | "noscheme";
-
export const AuthTokenType = {
Bearer: "bearer",
Basic: "basic",
diff --git a/src/api/types/ChatFinishReason.ts b/src/api/types/ChatFinishReason.ts
index e49fabc9..a1c2323e 100644
--- a/src/api/types/ChatFinishReason.ts
+++ b/src/api/types/ChatFinishReason.ts
@@ -12,7 +12,6 @@
* - **error**: The generation failed due to an internal error
*/
export type ChatFinishReason = "COMPLETE" | "STOP_SEQUENCE" | "MAX_TOKENS" | "TOOL_CALL" | "ERROR";
-
export const ChatFinishReason = {
Complete: "COMPLETE",
StopSequence: "STOP_SEQUENCE",
diff --git a/src/api/types/ChatMessageV2.ts b/src/api/types/ChatMessageV2.ts
index b6e83362..2f1fd327 100644
--- a/src/api/types/ChatMessageV2.ts
+++ b/src/api/types/ChatMessageV2.ts
@@ -13,20 +13,20 @@ export type ChatMessageV2 =
| Cohere.ChatMessageV2.System
| Cohere.ChatMessageV2.Tool;
-export declare namespace ChatMessageV2 {
- interface User extends Cohere.UserMessage {
+export namespace ChatMessageV2 {
+ export interface User extends Cohere.UserMessage {
role: "user";
}
- interface Assistant extends Cohere.AssistantMessage {
+ export interface Assistant extends Cohere.AssistantMessage {
role: "assistant";
}
- interface System extends Cohere.SystemMessage {
+ export interface System extends Cohere.SystemMessage {
role: "system";
}
- interface Tool extends Cohere.ToolMessageV2 {
+ export interface Tool extends Cohere.ToolMessageV2 {
role: "tool";
}
}
diff --git a/src/api/types/ChatRequestCitationQuality.ts b/src/api/types/ChatRequestCitationQuality.ts
index f19d39ea..ad63f8b1 100644
--- a/src/api/types/ChatRequestCitationQuality.ts
+++ b/src/api/types/ChatRequestCitationQuality.ts
@@ -10,7 +10,6 @@
* Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
*/
export type ChatRequestCitationQuality = "fast" | "accurate" | "off";
-
export const ChatRequestCitationQuality = {
Fast: "fast",
Accurate: "accurate",
diff --git a/src/api/types/ChatRequestPromptTruncation.ts b/src/api/types/ChatRequestPromptTruncation.ts
index af9886bf..c4db05a2 100644
--- a/src/api/types/ChatRequestPromptTruncation.ts
+++ b/src/api/types/ChatRequestPromptTruncation.ts
@@ -14,12 +14,10 @@
* With `prompt_truncation` set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a `TooManyTokens` error will be returned.
*
* Compatible Deployments:
- *
- * - AUTO: Cohere Platform Only
- * - AUTO_PRESERVE_ORDER: Azure, AWS Sagemaker/Bedrock, Private Deployments
+ * - AUTO: Cohere Platform Only
+ * - AUTO_PRESERVE_ORDER: Azure, AWS Sagemaker/Bedrock, Private Deployments
*/
export type ChatRequestPromptTruncation = "OFF" | "AUTO" | "AUTO_PRESERVE_ORDER";
-
export const ChatRequestPromptTruncation = {
Off: "OFF",
Auto: "AUTO",
diff --git a/src/api/types/ChatRequestSafetyMode.ts b/src/api/types/ChatRequestSafetyMode.ts
index bc00cb6f..45e8866f 100644
--- a/src/api/types/ChatRequestSafetyMode.ts
+++ b/src/api/types/ChatRequestSafetyMode.ts
@@ -15,7 +15,6 @@
* Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
*/
export type ChatRequestSafetyMode = "CONTEXTUAL" | "STRICT" | "NONE";
-
export const ChatRequestSafetyMode = {
Contextual: "CONTEXTUAL",
Strict: "STRICT",
diff --git a/src/api/types/ChatStreamEndEventFinishReason.ts b/src/api/types/ChatStreamEndEventFinishReason.ts
index 8e945033..d2866314 100644
--- a/src/api/types/ChatStreamEndEventFinishReason.ts
+++ b/src/api/types/ChatStreamEndEventFinishReason.ts
@@ -10,7 +10,6 @@
* - `ERROR_TOXIC` - the model generated a reply that was deemed toxic
*/
export type ChatStreamEndEventFinishReason = "COMPLETE" | "ERROR_LIMIT" | "MAX_TOKENS" | "ERROR" | "ERROR_TOXIC";
-
export const ChatStreamEndEventFinishReason = {
Complete: "COMPLETE",
ErrorLimit: "ERROR_LIMIT",
diff --git a/src/api/types/ChatStreamRequestCitationQuality.ts b/src/api/types/ChatStreamRequestCitationQuality.ts
index 9c0db488..3534f1f3 100644
--- a/src/api/types/ChatStreamRequestCitationQuality.ts
+++ b/src/api/types/ChatStreamRequestCitationQuality.ts
@@ -10,7 +10,6 @@
* Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
*/
export type ChatStreamRequestCitationQuality = "fast" | "accurate" | "off";
-
export const ChatStreamRequestCitationQuality = {
Fast: "fast",
Accurate: "accurate",
diff --git a/src/api/types/ChatStreamRequestPromptTruncation.ts b/src/api/types/ChatStreamRequestPromptTruncation.ts
index 9eca9f7f..72ba8fa2 100644
--- a/src/api/types/ChatStreamRequestPromptTruncation.ts
+++ b/src/api/types/ChatStreamRequestPromptTruncation.ts
@@ -14,12 +14,10 @@
* With `prompt_truncation` set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a `TooManyTokens` error will be returned.
*
* Compatible Deployments:
- *
- * - AUTO: Cohere Platform Only
- * - AUTO_PRESERVE_ORDER: Azure, AWS Sagemaker/Bedrock, Private Deployments
+ * - AUTO: Cohere Platform Only
+ * - AUTO_PRESERVE_ORDER: Azure, AWS Sagemaker/Bedrock, Private Deployments
*/
export type ChatStreamRequestPromptTruncation = "OFF" | "AUTO" | "AUTO_PRESERVE_ORDER";
-
export const ChatStreamRequestPromptTruncation = {
Off: "OFF",
Auto: "AUTO",
diff --git a/src/api/types/ChatStreamRequestSafetyMode.ts b/src/api/types/ChatStreamRequestSafetyMode.ts
index 0c2898bc..7ade2fa6 100644
--- a/src/api/types/ChatStreamRequestSafetyMode.ts
+++ b/src/api/types/ChatStreamRequestSafetyMode.ts
@@ -15,7 +15,6 @@
* Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
*/
export type ChatStreamRequestSafetyMode = "CONTEXTUAL" | "STRICT" | "NONE";
-
export const ChatStreamRequestSafetyMode = {
Contextual: "CONTEXTUAL",
Strict: "STRICT",
diff --git a/src/api/types/CitationOptionsMode.ts b/src/api/types/CitationOptionsMode.ts
index dc2136d4..5da3fd53 100644
--- a/src/api/types/CitationOptionsMode.ts
+++ b/src/api/types/CitationOptionsMode.ts
@@ -9,7 +9,6 @@
* **Note**: `command-r7b-12-2024` only supports `"fast"` and `"off"` modes. Its default is `"fast"`.
*/
export type CitationOptionsMode = "FAST" | "ACCURATE" | "OFF";
-
export const CitationOptionsMode = {
Fast: "FAST",
Accurate: "ACCURATE",
diff --git a/src/api/types/ClassifyRequestTruncate.ts b/src/api/types/ClassifyRequestTruncate.ts
index 8e5e9a12..2be543fb 100644
--- a/src/api/types/ClassifyRequestTruncate.ts
+++ b/src/api/types/ClassifyRequestTruncate.ts
@@ -8,7 +8,6 @@
* If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
*/
export type ClassifyRequestTruncate = "NONE" | "START" | "END";
-
export const ClassifyRequestTruncate = {
None: "NONE",
Start: "START",
diff --git a/src/api/types/ClassifyResponseClassificationsItemClassificationType.ts b/src/api/types/ClassifyResponseClassificationsItemClassificationType.ts
index c588edcc..fa6d2792 100644
--- a/src/api/types/ClassifyResponseClassificationsItemClassificationType.ts
+++ b/src/api/types/ClassifyResponseClassificationsItemClassificationType.ts
@@ -6,7 +6,6 @@
* The type of classification performed
*/
export type ClassifyResponseClassificationsItemClassificationType = "single-label" | "multi-label";
-
export const ClassifyResponseClassificationsItemClassificationType = {
SingleLabel: "single-label",
MultiLabel: "multi-label",
diff --git a/src/api/types/ClientClosedRequestErrorBody.ts b/src/api/types/ClientClosedRequestErrorBody.ts
deleted file mode 100644
index 8c199217..00000000
--- a/src/api/types/ClientClosedRequestErrorBody.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-export interface ClientClosedRequestErrorBody {
- data?: string;
-}
diff --git a/src/api/types/CompatibleEndpoint.ts b/src/api/types/CompatibleEndpoint.ts
index 01678519..70838ac6 100644
--- a/src/api/types/CompatibleEndpoint.ts
+++ b/src/api/types/CompatibleEndpoint.ts
@@ -6,7 +6,6 @@
* One of the Cohere API endpoints that the model can be used with.
*/
export type CompatibleEndpoint = "chat" | "embed" | "classify" | "summarize" | "rerank" | "rate" | "generate";
-
export const CompatibleEndpoint = {
Chat: "chat",
Embed: "embed",
diff --git a/src/api/types/ConnectorAuthStatus.ts b/src/api/types/ConnectorAuthStatus.ts
index a63100df..cbcced19 100644
--- a/src/api/types/ConnectorAuthStatus.ts
+++ b/src/api/types/ConnectorAuthStatus.ts
@@ -6,7 +6,6 @@
* The OAuth status for the user making the request. One of ["valid", "expired", ""]. Empty string (field is omitted) means the user has not authorized the connector yet.
*/
export type ConnectorAuthStatus = "valid" | "expired";
-
export const ConnectorAuthStatus = {
Valid: "valid",
Expired: "expired",
diff --git a/src/api/types/Content.ts b/src/api/types/Content.ts
index 21f7ecc8..c8581ca7 100644
--- a/src/api/types/Content.ts
+++ b/src/api/types/Content.ts
@@ -9,8 +9,8 @@ import * as Cohere from "../index";
*/
export type Content = Cohere.Content.Text;
-export declare namespace Content {
- interface Text extends Cohere.TextContent {
+export namespace Content {
+ export interface Text extends Cohere.TextContent {
type: "text";
}
}
diff --git a/src/api/types/DatasetType.ts b/src/api/types/DatasetType.ts
index 444d1cd3..7c58b811 100644
--- a/src/api/types/DatasetType.ts
+++ b/src/api/types/DatasetType.ts
@@ -14,7 +14,6 @@ export type DatasetType =
| "single-label-classification-finetune-input"
| "chat-finetune-input"
| "multi-label-classification-finetune-input";
-
export const DatasetType = {
EmbedInput: "embed-input",
EmbedResult: "embed-result",
diff --git a/src/api/types/DatasetValidationStatus.ts b/src/api/types/DatasetValidationStatus.ts
index d8cd7ab4..66728038 100644
--- a/src/api/types/DatasetValidationStatus.ts
+++ b/src/api/types/DatasetValidationStatus.ts
@@ -6,7 +6,6 @@
* The validation status of the dataset
*/
export type DatasetValidationStatus = "unknown" | "queued" | "processing" | "failed" | "validated" | "skipped";
-
export const DatasetValidationStatus = {
Unknown: "unknown",
Queued: "queued",
diff --git a/src/api/types/EmbedInputType.ts b/src/api/types/EmbedInputType.ts
index 37ae64f4..adf6052a 100644
--- a/src/api/types/EmbedInputType.ts
+++ b/src/api/types/EmbedInputType.ts
@@ -12,7 +12,6 @@
* - `"image"`: Used for embeddings with image input.
*/
export type EmbedInputType = "search_document" | "search_query" | "classification" | "clustering" | "image";
-
export const EmbedInputType = {
SearchDocument: "search_document",
SearchQuery: "search_query",
diff --git a/src/api/types/EmbedJobStatus.ts b/src/api/types/EmbedJobStatus.ts
index 94303024..ca212325 100644
--- a/src/api/types/EmbedJobStatus.ts
+++ b/src/api/types/EmbedJobStatus.ts
@@ -6,7 +6,6 @@
* The status of the embed job
*/
export type EmbedJobStatus = "processing" | "complete" | "cancelling" | "cancelled" | "failed";
-
export const EmbedJobStatus = {
Processing: "processing",
Complete: "complete",
diff --git a/src/api/types/EmbedJobTruncate.ts b/src/api/types/EmbedJobTruncate.ts
index 140c86ae..de4a2967 100644
--- a/src/api/types/EmbedJobTruncate.ts
+++ b/src/api/types/EmbedJobTruncate.ts
@@ -6,7 +6,6 @@
* The truncation option used
*/
export type EmbedJobTruncate = "START" | "END";
-
export const EmbedJobTruncate = {
Start: "START",
End: "END",
diff --git a/src/api/types/EmbedRequestTruncate.ts b/src/api/types/EmbedRequestTruncate.ts
index 8786bd60..79ca8191 100644
--- a/src/api/types/EmbedRequestTruncate.ts
+++ b/src/api/types/EmbedRequestTruncate.ts
@@ -10,7 +10,6 @@
* If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
*/
export type EmbedRequestTruncate = "NONE" | "START" | "END";
-
export const EmbedRequestTruncate = {
None: "NONE",
Start: "START",
diff --git a/src/api/types/EmbedResponse.ts b/src/api/types/EmbedResponse.ts
index 5e2de086..7cbfed24 100644
--- a/src/api/types/EmbedResponse.ts
+++ b/src/api/types/EmbedResponse.ts
@@ -6,12 +6,12 @@ import * as Cohere from "../index";
export type EmbedResponse = Cohere.EmbedResponse.EmbeddingsFloats | Cohere.EmbedResponse.EmbeddingsByType;
-export declare namespace EmbedResponse {
- interface EmbeddingsFloats extends Cohere.EmbedFloatsResponse {
+export namespace EmbedResponse {
+ export interface EmbeddingsFloats extends Cohere.EmbedFloatsResponse {
responseType: "embeddings_floats";
}
- interface EmbeddingsByType extends Cohere.EmbedByTypeResponse {
+ export interface EmbeddingsByType extends Cohere.EmbedByTypeResponse {
responseType: "embeddings_by_type";
}
}
diff --git a/src/api/types/EmbeddingType.ts b/src/api/types/EmbeddingType.ts
index 1260d14d..25d30335 100644
--- a/src/api/types/EmbeddingType.ts
+++ b/src/api/types/EmbeddingType.ts
@@ -3,7 +3,6 @@
*/
export type EmbeddingType = "float" | "int8" | "uint8" | "binary" | "ubinary";
-
export const EmbeddingType = {
Float: "float",
Int8: "int8",
diff --git a/src/api/types/FinishReason.ts b/src/api/types/FinishReason.ts
index abed5a60..49397f37 100644
--- a/src/api/types/FinishReason.ts
+++ b/src/api/types/FinishReason.ts
@@ -10,7 +10,6 @@ export type FinishReason =
| "ERROR_LIMIT"
| "USER_CANCEL"
| "MAX_TOKENS";
-
export const FinishReason = {
Complete: "COMPLETE",
StopSequence: "STOP_SEQUENCE",
diff --git a/src/api/types/GatewayTimeoutErrorBody.ts b/src/api/types/GatewayTimeoutErrorBody.ts
deleted file mode 100644
index b9350446..00000000
--- a/src/api/types/GatewayTimeoutErrorBody.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-export interface GatewayTimeoutErrorBody {
- data?: string;
-}
diff --git a/src/api/types/GenerateRequestReturnLikelihoods.ts b/src/api/types/GenerateRequestReturnLikelihoods.ts
index bfed5f06..7d7661b8 100644
--- a/src/api/types/GenerateRequestReturnLikelihoods.ts
+++ b/src/api/types/GenerateRequestReturnLikelihoods.ts
@@ -10,7 +10,6 @@
* WARNING: `ALL` is deprecated, and will be removed in a future release.
*/
export type GenerateRequestReturnLikelihoods = "GENERATION" | "ALL" | "NONE";
-
export const GenerateRequestReturnLikelihoods = {
Generation: "GENERATION",
All: "ALL",
diff --git a/src/api/types/GenerateRequestTruncate.ts b/src/api/types/GenerateRequestTruncate.ts
index 7e6654f6..c9c0d528 100644
--- a/src/api/types/GenerateRequestTruncate.ts
+++ b/src/api/types/GenerateRequestTruncate.ts
@@ -10,7 +10,6 @@
* If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
*/
export type GenerateRequestTruncate = "NONE" | "START" | "END";
-
export const GenerateRequestTruncate = {
None: "NONE",
Start: "START",
diff --git a/src/api/types/GenerateStreamRequestReturnLikelihoods.ts b/src/api/types/GenerateStreamRequestReturnLikelihoods.ts
index 3a7fc915..55699010 100644
--- a/src/api/types/GenerateStreamRequestReturnLikelihoods.ts
+++ b/src/api/types/GenerateStreamRequestReturnLikelihoods.ts
@@ -10,7 +10,6 @@
* WARNING: `ALL` is deprecated, and will be removed in a future release.
*/
export type GenerateStreamRequestReturnLikelihoods = "GENERATION" | "ALL" | "NONE";
-
export const GenerateStreamRequestReturnLikelihoods = {
Generation: "GENERATION",
All: "ALL",
diff --git a/src/api/types/GenerateStreamRequestTruncate.ts b/src/api/types/GenerateStreamRequestTruncate.ts
index ac39cd2c..f64dcbec 100644
--- a/src/api/types/GenerateStreamRequestTruncate.ts
+++ b/src/api/types/GenerateStreamRequestTruncate.ts
@@ -10,7 +10,6 @@
* If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
*/
export type GenerateStreamRequestTruncate = "NONE" | "START" | "END";
-
export const GenerateStreamRequestTruncate = {
None: "NONE",
Start: "START",
diff --git a/src/api/types/GenerateStreamedResponse.ts b/src/api/types/GenerateStreamedResponse.ts
index 140537d3..1838d15e 100644
--- a/src/api/types/GenerateStreamedResponse.ts
+++ b/src/api/types/GenerateStreamedResponse.ts
@@ -12,16 +12,16 @@ export type GenerateStreamedResponse =
| Cohere.GenerateStreamedResponse.StreamEnd
| Cohere.GenerateStreamedResponse.StreamError;
-export declare namespace GenerateStreamedResponse {
- interface TextGeneration extends Cohere.GenerateStreamText {
+export namespace GenerateStreamedResponse {
+ export interface TextGeneration extends Cohere.GenerateStreamText {
eventType: "text-generation";
}
- interface StreamEnd extends Cohere.GenerateStreamEnd {
+ export interface StreamEnd extends Cohere.GenerateStreamEnd {
eventType: "stream-end";
}
- interface StreamError extends Cohere.GenerateStreamError {
+ export interface StreamError extends Cohere.GenerateStreamError {
eventType: "stream-error";
}
}
diff --git a/src/api/types/JsonResponseFormat.ts b/src/api/types/JsonResponseFormat.ts
index 98651e7f..0efa1c49 100644
--- a/src/api/types/JsonResponseFormat.ts
+++ b/src/api/types/JsonResponseFormat.ts
@@ -6,13 +6,12 @@ export interface JsonResponseFormat {
/**
* A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information.
* Example (required name and age object):
- *
* ```json
* {
* "type": "object",
* "properties": {
- * "name": { "type": "string" },
- * "age": { "type": "integer" }
+ * "name": {"type": "string"},
+ * "age": {"type": "integer"}
* },
* "required": ["name", "age"]
* }
diff --git a/src/api/types/JsonResponseFormatV2.ts b/src/api/types/JsonResponseFormatV2.ts
index 3e80d85b..ebfa3354 100644
--- a/src/api/types/JsonResponseFormatV2.ts
+++ b/src/api/types/JsonResponseFormatV2.ts
@@ -6,13 +6,12 @@ export interface JsonResponseFormatV2 {
/**
* A [JSON schema](https://json-schema.org/overview/what-is-jsonschema) object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information.
* Example (required name and age object):
- *
* ```json
* {
* "type": "object",
* "properties": {
- * "name": { "type": "string" },
- * "age": { "type": "integer" }
+ * "name": {"type": "string"},
+ * "age": {"type": "integer"}
* },
* "required": ["name", "age"]
* }
diff --git a/src/api/types/Message.ts b/src/api/types/Message.ts
index 28b86f3b..94d4f46e 100644
--- a/src/api/types/Message.ts
+++ b/src/api/types/Message.ts
@@ -6,20 +6,20 @@ import * as Cohere from "../index";
export type Message = Cohere.Message.Chatbot | Cohere.Message.System | Cohere.Message.User | Cohere.Message.Tool;
-export declare namespace Message {
- interface Chatbot extends Cohere.ChatMessage {
+export namespace Message {
+ export interface Chatbot extends Cohere.ChatMessage {
role: "CHATBOT";
}
- interface System extends Cohere.ChatMessage {
+ export interface System extends Cohere.ChatMessage {
role: "SYSTEM";
}
- interface User extends Cohere.ChatMessage {
+ export interface User extends Cohere.ChatMessage {
role: "USER";
}
- interface Tool extends Cohere.ToolMessage {
+ export interface Tool extends Cohere.ToolMessage {
role: "TOOL";
}
}
diff --git a/src/api/types/NotImplementedErrorBody.ts b/src/api/types/NotImplementedErrorBody.ts
deleted file mode 100644
index f4088a4b..00000000
--- a/src/api/types/NotImplementedErrorBody.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-export interface NotImplementedErrorBody {
- data?: string;
-}
diff --git a/src/api/types/ResponseFormat.ts b/src/api/types/ResponseFormat.ts
index 13989153..7c8f4912 100644
--- a/src/api/types/ResponseFormat.ts
+++ b/src/api/types/ResponseFormat.ts
@@ -11,17 +11,17 @@ import * as Cohere from "../index";
*
* A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure.
*
- * **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.
+ * **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.
* **Limitation**: The parameter is not supported in RAG mode (when any of `connectors`, `documents`, `tools`, `tool_results` are provided).
*/
export type ResponseFormat = Cohere.ResponseFormat.Text | Cohere.ResponseFormat.JsonObject;
-export declare namespace ResponseFormat {
- interface Text extends Cohere.TextResponseFormat {
+export namespace ResponseFormat {
+ export interface Text extends Cohere.TextResponseFormat {
type: "text";
}
- interface JsonObject extends Cohere.JsonResponseFormat {
+ export interface JsonObject extends Cohere.JsonResponseFormat {
type: "json_object";
}
}
diff --git a/src/api/types/ResponseFormatV2.ts b/src/api/types/ResponseFormatV2.ts
index da32b530..2f891a82 100644
--- a/src/api/types/ResponseFormatV2.ts
+++ b/src/api/types/ResponseFormatV2.ts
@@ -11,7 +11,7 @@ import * as Cohere from "../index";
*
* A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure.
*
- * **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.
+ * **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.
*
* **Note**: When `json_schema` is not specified, the generated object can have up to 5 layers of nesting.
*
@@ -19,12 +19,12 @@ import * as Cohere from "../index";
*/
export type ResponseFormatV2 = Cohere.ResponseFormatV2.Text | Cohere.ResponseFormatV2.JsonObject;
-export declare namespace ResponseFormatV2 {
- interface Text extends Cohere.TextResponseFormatV2 {
+export namespace ResponseFormatV2 {
+ export interface Text extends Cohere.TextResponseFormatV2 {
type: "text";
}
- interface JsonObject extends Cohere.JsonResponseFormatV2 {
+ export interface JsonObject extends Cohere.JsonResponseFormatV2 {
type: "json_object";
}
}
diff --git a/src/api/types/Source.ts b/src/api/types/Source.ts
index 9d7b0d8a..9375c2f6 100644
--- a/src/api/types/Source.ts
+++ b/src/api/types/Source.ts
@@ -9,12 +9,12 @@ import * as Cohere from "../index";
*/
export type Source = Cohere.Source.Tool | Cohere.Source.Document;
-export declare namespace Source {
- interface Tool extends Cohere.ToolSource {
+export namespace Source {
+ export interface Tool extends Cohere.ToolSource {
type: "tool";
}
- interface Document extends Cohere.DocumentSource {
+ export interface Document extends Cohere.DocumentSource {
type: "document";
}
}
diff --git a/src/api/types/StreamedChatResponse.ts b/src/api/types/StreamedChatResponse.ts
index 1e5e659b..439783ef 100644
--- a/src/api/types/StreamedChatResponse.ts
+++ b/src/api/types/StreamedChatResponse.ts
@@ -18,40 +18,40 @@ export type StreamedChatResponse =
| Cohere.StreamedChatResponse.ToolCallsChunk
| Cohere.StreamedChatResponse.Debug;
-export declare namespace StreamedChatResponse {
- interface StreamStart extends Cohere.ChatStreamStartEvent {
+export namespace StreamedChatResponse {
+ export interface StreamStart extends Cohere.ChatStreamStartEvent {
eventType: "stream-start";
}
- interface SearchQueriesGeneration extends Cohere.ChatSearchQueriesGenerationEvent {
+ export interface SearchQueriesGeneration extends Cohere.ChatSearchQueriesGenerationEvent {
eventType: "search-queries-generation";
}
- interface SearchResults extends Cohere.ChatSearchResultsEvent {
+ export interface SearchResults extends Cohere.ChatSearchResultsEvent {
eventType: "search-results";
}
- interface TextGeneration extends Cohere.ChatTextGenerationEvent {
+ export interface TextGeneration extends Cohere.ChatTextGenerationEvent {
eventType: "text-generation";
}
- interface CitationGeneration extends Cohere.ChatCitationGenerationEvent {
+ export interface CitationGeneration extends Cohere.ChatCitationGenerationEvent {
eventType: "citation-generation";
}
- interface ToolCallsGeneration extends Cohere.ChatToolCallsGenerationEvent {
+ export interface ToolCallsGeneration extends Cohere.ChatToolCallsGenerationEvent {
eventType: "tool-calls-generation";
}
- interface StreamEnd extends Cohere.ChatStreamEndEvent {
+ export interface StreamEnd extends Cohere.ChatStreamEndEvent {
eventType: "stream-end";
}
- interface ToolCallsChunk extends Cohere.ChatToolCallsChunkEvent {
+ export interface ToolCallsChunk extends Cohere.ChatToolCallsChunkEvent {
eventType: "tool-calls-chunk";
}
- interface Debug extends Cohere.ChatDebugEvent {
+ export interface Debug extends Cohere.ChatDebugEvent {
eventType: "debug";
}
}
diff --git a/src/api/types/StreamedChatResponseV2.ts b/src/api/types/StreamedChatResponseV2.ts
index 5a7f05dc..dc8a0556 100644
--- a/src/api/types/StreamedChatResponseV2.ts
+++ b/src/api/types/StreamedChatResponseV2.ts
@@ -21,52 +21,52 @@ export type StreamedChatResponseV2 =
| Cohere.StreamedChatResponseV2.MessageEnd
| Cohere.StreamedChatResponseV2.Debug;
-export declare namespace StreamedChatResponseV2 {
- interface MessageStart extends Cohere.ChatMessageStartEvent {
+export namespace StreamedChatResponseV2 {
+ export interface MessageStart extends Cohere.ChatMessageStartEvent {
type: "message-start";
}
- interface ContentStart extends Cohere.ChatContentStartEvent {
+ export interface ContentStart extends Cohere.ChatContentStartEvent {
type: "content-start";
}
- interface ContentDelta extends Cohere.ChatContentDeltaEvent {
+ export interface ContentDelta extends Cohere.ChatContentDeltaEvent {
type: "content-delta";
}
- interface ContentEnd extends Cohere.ChatContentEndEvent {
+ export interface ContentEnd extends Cohere.ChatContentEndEvent {
type: "content-end";
}
- interface ToolPlanDelta extends Cohere.ChatToolPlanDeltaEvent {
+ export interface ToolPlanDelta extends Cohere.ChatToolPlanDeltaEvent {
type: "tool-plan-delta";
}
- interface ToolCallStart extends Cohere.ChatToolCallStartEvent {
+ export interface ToolCallStart extends Cohere.ChatToolCallStartEvent {
type: "tool-call-start";
}
- interface ToolCallDelta extends Cohere.ChatToolCallDeltaEvent {
+ export interface ToolCallDelta extends Cohere.ChatToolCallDeltaEvent {
type: "tool-call-delta";
}
- interface ToolCallEnd extends Cohere.ChatToolCallEndEvent {
+ export interface ToolCallEnd extends Cohere.ChatToolCallEndEvent {
type: "tool-call-end";
}
- interface CitationStart extends Cohere.CitationStartEvent {
+ export interface CitationStart extends Cohere.CitationStartEvent {
type: "citation-start";
}
- interface CitationEnd extends Cohere.CitationEndEvent {
+ export interface CitationEnd extends Cohere.CitationEndEvent {
type: "citation-end";
}
- interface MessageEnd extends Cohere.ChatMessageEndEvent {
+ export interface MessageEnd extends Cohere.ChatMessageEndEvent {
type: "message-end";
}
- interface Debug extends Cohere.ChatDebugEvent {
+ export interface Debug extends Cohere.ChatDebugEvent {
type: "debug";
}
}
diff --git a/src/api/types/SummarizeRequestExtractiveness.ts b/src/api/types/SummarizeRequestExtractiveness.ts
index d09b35c6..dbf2ca2f 100644
--- a/src/api/types/SummarizeRequestExtractiveness.ts
+++ b/src/api/types/SummarizeRequestExtractiveness.ts
@@ -6,7 +6,6 @@
* One of `low`, `medium`, `high`, or `auto`, defaults to `auto`. Controls how close to the original text the summary is. `high` extractiveness summaries will lean towards reusing sentences verbatim, while `low` extractiveness summaries will tend to paraphrase more. If `auto` is selected, the best option will be picked based on the input text.
*/
export type SummarizeRequestExtractiveness = "low" | "medium" | "high";
-
export const SummarizeRequestExtractiveness = {
Low: "low",
Medium: "medium",
diff --git a/src/api/types/SummarizeRequestFormat.ts b/src/api/types/SummarizeRequestFormat.ts
index 0f69ec00..aaba1c8a 100644
--- a/src/api/types/SummarizeRequestFormat.ts
+++ b/src/api/types/SummarizeRequestFormat.ts
@@ -6,7 +6,6 @@
* One of `paragraph`, `bullets`, or `auto`, defaults to `auto`. Indicates the style in which the summary will be delivered - in a free form paragraph or in bullet points. If `auto` is selected, the best option will be picked based on the input text.
*/
export type SummarizeRequestFormat = "paragraph" | "bullets";
-
export const SummarizeRequestFormat = {
Paragraph: "paragraph",
Bullets: "bullets",
diff --git a/src/api/types/SummarizeRequestLength.ts b/src/api/types/SummarizeRequestLength.ts
index b801f59b..d5a7742a 100644
--- a/src/api/types/SummarizeRequestLength.ts
+++ b/src/api/types/SummarizeRequestLength.ts
@@ -6,7 +6,6 @@
* One of `short`, `medium`, `long`, or `auto` defaults to `auto`. Indicates the approximate length of the summary. If `auto` is selected, the best option will be picked based on the input text.
*/
export type SummarizeRequestLength = "short" | "medium" | "long";
-
export const SummarizeRequestLength = {
Short: "short",
Medium: "medium",
diff --git a/src/api/types/SystemMessageContentItem.ts b/src/api/types/SystemMessageContentItem.ts
index 3d3abade..ec85c628 100644
--- a/src/api/types/SystemMessageContentItem.ts
+++ b/src/api/types/SystemMessageContentItem.ts
@@ -6,8 +6,8 @@ import * as Cohere from "../index";
export type SystemMessageContentItem = Cohere.SystemMessageContentItem.Text;
-export declare namespace SystemMessageContentItem {
- interface Text extends Cohere.TextContent {
+export namespace SystemMessageContentItem {
+ export interface Text extends Cohere.TextContent {
type: "text";
}
}
diff --git a/src/api/types/TooManyRequestsErrorBody.ts b/src/api/types/TooManyRequestsErrorBody.ts
deleted file mode 100644
index 5bc99045..00000000
--- a/src/api/types/TooManyRequestsErrorBody.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-export interface TooManyRequestsErrorBody {
- data?: string;
-}
diff --git a/src/api/types/Tool.ts b/src/api/types/Tool.ts
index 75761f06..e43ede9a 100644
--- a/src/api/types/Tool.ts
+++ b/src/api/types/Tool.ts
@@ -11,7 +11,6 @@ export interface Tool {
description: string;
/**
* The input parameters of the tool. Accepts a dictionary where the key is the name of the parameter and the value is the parameter spec. Valid parameter names contain only the characters `a-z`, `A-Z`, `0-9`, `_` and must not begin with a digit.
- *
* ```
* {
* "my_param": {
diff --git a/src/api/types/ToolContent.ts b/src/api/types/ToolContent.ts
index 41649246..2e757f4c 100644
--- a/src/api/types/ToolContent.ts
+++ b/src/api/types/ToolContent.ts
@@ -9,12 +9,12 @@ import * as Cohere from "../index";
*/
export type ToolContent = Cohere.ToolContent.Text | Cohere.ToolContent.Document;
-export declare namespace ToolContent {
- interface Text extends Cohere.TextContent {
+export namespace ToolContent {
+ export interface Text extends Cohere.TextContent {
type: "text";
}
- interface Document extends Cohere.DocumentContent {
+ export interface Document extends Cohere.DocumentContent {
type: "document";
}
}
diff --git a/src/api/types/UnprocessableEntityErrorBody.ts b/src/api/types/UnprocessableEntityErrorBody.ts
deleted file mode 100644
index 79aa4af5..00000000
--- a/src/api/types/UnprocessableEntityErrorBody.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-export interface UnprocessableEntityErrorBody {
- data?: string;
-}
diff --git a/src/api/types/index.ts b/src/api/types/index.ts
index 3c84d507..3e242408 100644
--- a/src/api/types/index.ts
+++ b/src/api/types/index.ts
@@ -2,11 +2,6 @@ export * from "./ChatStreamRequestPromptTruncation";
export * from "./ChatStreamRequestCitationQuality";
export * from "./ChatStreamRequestConnectorsSearchOptions";
export * from "./ChatStreamRequestSafetyMode";
-export * from "./UnprocessableEntityErrorBody";
-export * from "./TooManyRequestsErrorBody";
-export * from "./ClientClosedRequestErrorBody";
-export * from "./NotImplementedErrorBody";
-export * from "./GatewayTimeoutErrorBody";
export * from "./ChatRequestPromptTruncation";
export * from "./ChatRequestCitationQuality";
export * from "./ChatRequestConnectorsSearchOptions";
diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts
index d67bc042..b8f23717 100644
--- a/src/core/fetcher/Fetcher.ts
+++ b/src/core/fetcher/Fetcher.ts
@@ -21,7 +21,7 @@ export declare namespace Fetcher {
withCredentials?: boolean;
abortSignal?: AbortSignal;
requestType?: "json" | "file" | "bytes";
- responseType?: "json" | "blob" | "sse" | "streaming" | "text";
+ responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer";
duplex?: "half";
}
diff --git a/src/core/fetcher/getResponseBody.ts b/src/core/fetcher/getResponseBody.ts
index a7a9c508..d046e6ea 100644
--- a/src/core/fetcher/getResponseBody.ts
+++ b/src/core/fetcher/getResponseBody.ts
@@ -3,6 +3,8 @@ import { chooseStreamWrapper } from "./stream-wrappers/chooseStreamWrapper";
export async function getResponseBody(response: Response, responseType?: string): Promise {
if (response.body != null && responseType === "blob") {
return await response.blob();
+ } else if (response.body != null && responseType === "arrayBuffer") {
+ return await response.arrayBuffer();
} else if (response.body != null && responseType === "sse") {
return response.body;
} else if (response.body != null && responseType === "streaming") {
diff --git a/src/core/fetcher/requestWithRetries.ts b/src/core/fetcher/requestWithRetries.ts
index ff5dc3bb..8d5af9d5 100644
--- a/src/core/fetcher/requestWithRetries.ts
+++ b/src/core/fetcher/requestWithRetries.ts
@@ -1,6 +1,13 @@
-const INITIAL_RETRY_DELAY = 1;
-const MAX_RETRY_DELAY = 60;
+const INITIAL_RETRY_DELAY = 1000; // in milliseconds
+const MAX_RETRY_DELAY = 60000; // in milliseconds
const DEFAULT_MAX_RETRIES = 2;
+const JITTER_FACTOR = 0.2; // 20% random jitter
+
+function addJitter(delay: number): number {
+ // Generate a random value between -JITTER_FACTOR and +JITTER_FACTOR
+ const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR;
+ return delay * jitterMultiplier;
+}
export async function requestWithRetries(
requestFn: () => Promise,
@@ -10,8 +17,13 @@ export async function requestWithRetries(
for (let i = 0; i < maxRetries; ++i) {
if ([408, 409, 429].includes(response.status) || response.status >= 500) {
- const delay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY);
- await new Promise((resolve) => setTimeout(resolve, delay));
+ // Calculate base delay using exponential backoff (in milliseconds)
+ const baseDelay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY);
+
+ // Add jitter to the delay
+ const delayWithJitter = addJitter(baseDelay);
+
+ await new Promise((resolve) => setTimeout(resolve, delayWithJitter));
response = await requestFn();
} else {
break;
diff --git a/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts b/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts
index e5db8734..4d7b7d52 100644
--- a/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts
+++ b/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts
@@ -1,4 +1,4 @@
-import type { Writable } from "stream";
+import type { Writable } from "readable-stream";
import { EventCallback, StreamWrapper } from "./chooseStreamWrapper";
export class Node18UniversalStreamWrapper
@@ -173,8 +173,12 @@ export class Node18UniversalStreamWrapper {
diff --git a/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts b/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts
index 7a52805d..263af009 100644
--- a/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts
+++ b/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts
@@ -78,7 +78,7 @@ export class UndiciStreamWrapper | WritableStream): void {
+ public unpipe(dest: UndiciStreamWrapper | WritableStream): void {
this.off("data", (chunk) => {
if (dest instanceof UndiciStreamWrapper) {
dest._write(chunk);
@@ -160,8 +160,12 @@ export class UndiciStreamWrapper void;
@@ -25,7 +25,7 @@ export async function chooseStreamWrapper(responseBody: any): Promise {
}
export const SchemaType = {
+ BIGINT: "bigint",
DATE: "date",
ENUM: "enum",
LIST: "list",
diff --git a/src/core/schemas/builders/bigint/bigint.ts b/src/core/schemas/builders/bigint/bigint.ts
new file mode 100644
index 00000000..dc9c742e
--- /dev/null
+++ b/src/core/schemas/builders/bigint/bigint.ts
@@ -0,0 +1,50 @@
+import { BaseSchema, Schema, SchemaType } from "../../Schema";
+import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
+import { maybeSkipValidation } from "../../utils/maybeSkipValidation";
+import { getSchemaUtils } from "../schema-utils";
+
+export function bigint(): Schema {
+ const baseSchema: BaseSchema = {
+ parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
+ if (typeof raw !== "string") {
+ return {
+ ok: false,
+ errors: [
+ {
+ path: breadcrumbsPrefix,
+ message: getErrorMessageForIncorrectType(raw, "string"),
+ },
+ ],
+ };
+ }
+ return {
+ ok: true,
+ value: BigInt(raw),
+ };
+ },
+ json: (bigint, { breadcrumbsPrefix = [] } = {}) => {
+ if (typeof bigint === "bigint") {
+ return {
+ ok: true,
+ value: bigint.toString(),
+ };
+ } else {
+ return {
+ ok: false,
+ errors: [
+ {
+ path: breadcrumbsPrefix,
+ message: getErrorMessageForIncorrectType(bigint, "bigint"),
+ },
+ ],
+ };
+ }
+ },
+ getType: () => SchemaType.BIGINT,
+ };
+
+ return {
+ ...maybeSkipValidation(baseSchema),
+ ...getSchemaUtils(baseSchema),
+ };
+}
diff --git a/src/core/schemas/builders/bigint/index.ts b/src/core/schemas/builders/bigint/index.ts
new file mode 100644
index 00000000..e5843043
--- /dev/null
+++ b/src/core/schemas/builders/bigint/index.ts
@@ -0,0 +1 @@
+export { bigint } from "./bigint";
diff --git a/src/core/schemas/builders/index.ts b/src/core/schemas/builders/index.ts
index 050cd2c4..65211f92 100644
--- a/src/core/schemas/builders/index.ts
+++ b/src/core/schemas/builders/index.ts
@@ -1,3 +1,4 @@
+export * from "./bigint";
export * from "./date";
export * from "./enum";
export * from "./lazy";
diff --git a/src/core/schemas/builders/object/object.ts b/src/core/schemas/builders/object/object.ts
index e00136d7..8d40c33c 100644
--- a/src/core/schemas/builders/object/object.ts
+++ b/src/core/schemas/builders/object/object.ts
@@ -260,6 +260,47 @@ export function getObjectUtils(schema: BaseObjectSchema SchemaType.OBJECT,
};
+ return {
+ ...baseSchema,
+ ...getSchemaUtils(baseSchema),
+ ...getObjectLikeUtils(baseSchema),
+ ...getObjectUtils(baseSchema),
+ };
+ },
+ passthrough: () => {
+ const baseSchema: BaseObjectSchema =
+ {
+ _getParsedProperties: () => schema._getParsedProperties(),
+ _getRawProperties: () => schema._getRawProperties(),
+ parse: (raw, opts) => {
+ const transformed = schema.parse(raw, { ...opts, unrecognizedObjectKeys: "passthrough" });
+ if (!transformed.ok) {
+ return transformed;
+ }
+ return {
+ ok: true,
+ value: {
+ ...(raw as any),
+ ...transformed.value,
+ },
+ };
+ },
+ json: (parsed, opts) => {
+ const transformed = schema.json(parsed, { ...opts, unrecognizedObjectKeys: "passthrough" });
+ if (!transformed.ok) {
+ return transformed;
+ }
+ return {
+ ok: true,
+ value: {
+ ...(parsed as any),
+ ...transformed.value,
+ },
+ };
+ },
+ getType: () => SchemaType.OBJECT,
+ };
+
return {
...baseSchema,
...getSchemaUtils(baseSchema),
diff --git a/src/core/schemas/builders/object/types.ts b/src/core/schemas/builders/object/types.ts
index de9bb407..9f87cbb7 100644
--- a/src/core/schemas/builders/object/types.ts
+++ b/src/core/schemas/builders/object/types.ts
@@ -18,6 +18,7 @@ export interface ObjectUtils {
extend: (
schemas: ObjectSchema
) => ObjectSchema;
+ passthrough: () => ObjectSchema;
}
export type inferRawObject> = O extends ObjectSchema ? Raw : never;
diff --git a/src/core/schemas/utils/getErrorMessageForIncorrectType.ts b/src/core/schemas/utils/getErrorMessageForIncorrectType.ts
index 438012df..1a5c3102 100644
--- a/src/core/schemas/utils/getErrorMessageForIncorrectType.ts
+++ b/src/core/schemas/utils/getErrorMessageForIncorrectType.ts
@@ -9,9 +9,13 @@ function getTypeAsString(value: unknown): string {
if (value === null) {
return "null";
}
+ if (value instanceof BigInt) {
+ return "BigInt";
+ }
switch (typeof value) {
case "string":
return `"${value}"`;
+ case "bigint":
case "number":
case "boolean":
case "undefined":
diff --git a/src/errors/CohereTimeoutError.ts b/src/errors/CohereTimeoutError.ts
index 6d1b46ef..bee7c7fc 100644
--- a/src/errors/CohereTimeoutError.ts
+++ b/src/errors/CohereTimeoutError.ts
@@ -3,8 +3,8 @@
*/
export class CohereTimeoutError extends Error {
- constructor() {
- super("Timeout");
+ constructor(message: string) {
+ super(message);
Object.setPrototypeOf(this, CohereTimeoutError.prototype);
}
}
diff --git a/src/serialization/types/ClientClosedRequestErrorBody.ts b/src/serialization/types/ClientClosedRequestErrorBody.ts
deleted file mode 100644
index 84fb4f3b..00000000
--- a/src/serialization/types/ClientClosedRequestErrorBody.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-import * as serializers from "../index";
-import * as Cohere from "../../api/index";
-import * as core from "../../core";
-
-export const ClientClosedRequestErrorBody: core.serialization.ObjectSchema<
- serializers.ClientClosedRequestErrorBody.Raw,
- Cohere.ClientClosedRequestErrorBody
-> = core.serialization.object({
- data: core.serialization.string().optional(),
-});
-
-export declare namespace ClientClosedRequestErrorBody {
- interface Raw {
- data?: string | null;
- }
-}
diff --git a/src/serialization/types/GatewayTimeoutErrorBody.ts b/src/serialization/types/GatewayTimeoutErrorBody.ts
deleted file mode 100644
index b539b08c..00000000
--- a/src/serialization/types/GatewayTimeoutErrorBody.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-import * as serializers from "../index";
-import * as Cohere from "../../api/index";
-import * as core from "../../core";
-
-export const GatewayTimeoutErrorBody: core.serialization.ObjectSchema<
- serializers.GatewayTimeoutErrorBody.Raw,
- Cohere.GatewayTimeoutErrorBody
-> = core.serialization.object({
- data: core.serialization.string().optional(),
-});
-
-export declare namespace GatewayTimeoutErrorBody {
- interface Raw {
- data?: string | null;
- }
-}
diff --git a/src/serialization/types/NotImplementedErrorBody.ts b/src/serialization/types/NotImplementedErrorBody.ts
deleted file mode 100644
index 66df27aa..00000000
--- a/src/serialization/types/NotImplementedErrorBody.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-import * as serializers from "../index";
-import * as Cohere from "../../api/index";
-import * as core from "../../core";
-
-export const NotImplementedErrorBody: core.serialization.ObjectSchema<
- serializers.NotImplementedErrorBody.Raw,
- Cohere.NotImplementedErrorBody
-> = core.serialization.object({
- data: core.serialization.string().optional(),
-});
-
-export declare namespace NotImplementedErrorBody {
- interface Raw {
- data?: string | null;
- }
-}
diff --git a/src/serialization/types/TooManyRequestsErrorBody.ts b/src/serialization/types/TooManyRequestsErrorBody.ts
deleted file mode 100644
index d36cdd4e..00000000
--- a/src/serialization/types/TooManyRequestsErrorBody.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-import * as serializers from "../index";
-import * as Cohere from "../../api/index";
-import * as core from "../../core";
-
-export const TooManyRequestsErrorBody: core.serialization.ObjectSchema<
- serializers.TooManyRequestsErrorBody.Raw,
- Cohere.TooManyRequestsErrorBody
-> = core.serialization.object({
- data: core.serialization.string().optional(),
-});
-
-export declare namespace TooManyRequestsErrorBody {
- interface Raw {
- data?: string | null;
- }
-}
diff --git a/src/serialization/types/UnprocessableEntityErrorBody.ts b/src/serialization/types/UnprocessableEntityErrorBody.ts
deleted file mode 100644
index bb7dc161..00000000
--- a/src/serialization/types/UnprocessableEntityErrorBody.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * This file was auto-generated by Fern from our API Definition.
- */
-
-import * as serializers from "../index";
-import * as Cohere from "../../api/index";
-import * as core from "../../core";
-
-export const UnprocessableEntityErrorBody: core.serialization.ObjectSchema<
- serializers.UnprocessableEntityErrorBody.Raw,
- Cohere.UnprocessableEntityErrorBody
-> = core.serialization.object({
- data: core.serialization.string().optional(),
-});
-
-export declare namespace UnprocessableEntityErrorBody {
- interface Raw {
- data?: string | null;
- }
-}
diff --git a/src/serialization/types/index.ts b/src/serialization/types/index.ts
index 3c84d507..3e242408 100644
--- a/src/serialization/types/index.ts
+++ b/src/serialization/types/index.ts
@@ -2,11 +2,6 @@ export * from "./ChatStreamRequestPromptTruncation";
export * from "./ChatStreamRequestCitationQuality";
export * from "./ChatStreamRequestConnectorsSearchOptions";
export * from "./ChatStreamRequestSafetyMode";
-export * from "./UnprocessableEntityErrorBody";
-export * from "./TooManyRequestsErrorBody";
-export * from "./ClientClosedRequestErrorBody";
-export * from "./NotImplementedErrorBody";
-export * from "./GatewayTimeoutErrorBody";
export * from "./ChatRequestPromptTruncation";
export * from "./ChatRequestCitationQuality";
export * from "./ChatRequestConnectorsSearchOptions";
diff --git a/src/version.ts b/src/version.ts
new file mode 100644
index 00000000..3100e8ba
--- /dev/null
+++ b/src/version.ts
@@ -0,0 +1 @@
+export const SDK_VERSION = "7.15.2";
diff --git a/tests/unit/fetcher/Fetcher.test.ts b/tests/unit/fetcher/Fetcher.test.ts
index 0e14a8c7..ff804217 100644
--- a/tests/unit/fetcher/Fetcher.test.ts
+++ b/tests/unit/fetcher/Fetcher.test.ts
@@ -1,5 +1,6 @@
-import fetchMock from "fetch-mock-jest";
+import fs from "fs";
import { Fetcher, fetcherImpl } from "../../../src/core/fetcher/Fetcher";
+import { join } from "path";
describe("Test fetcherImpl", () => {
it("should handle successful request", async () => {
@@ -12,8 +13,11 @@ describe("Test fetcherImpl", () => {
requestType: "json",
};
- fetchMock.mock("https://httpbin.org/post", 200, {
- response: JSON.stringify({ data: "test" }),
+ global.fetch = jest.fn().mockResolvedValue({
+ ok: true,
+ status: 200,
+ text: () => Promise.resolve(JSON.stringify({ data: "test" })),
+ json: () => ({ data: "test" }),
});
const result = await fetcherImpl(mockArgs);
@@ -21,5 +25,49 @@ describe("Test fetcherImpl", () => {
if (result.ok) {
expect(result.body).toEqual({ data: "test" });
}
+
+ expect(global.fetch).toHaveBeenCalledWith(
+ "https://httpbin.org/post",
+ expect.objectContaining({
+ method: "POST",
+ headers: expect.objectContaining({ "X-Test": "x-test-header" }),
+ body: JSON.stringify({ data: "test" }),
+ })
+ );
+ });
+
+ it("should send octet stream", async () => {
+ const url = "https://httpbin.org/post/file";
+ const mockArgs: Fetcher.Args = {
+ url,
+ method: "POST",
+ headers: { "X-Test": "x-test-header" },
+ contentType: "application/octet-stream",
+ requestType: "bytes",
+ duplex: "half",
+ body: fs.createReadStream(join(__dirname, "test-file.txt")),
+ };
+
+ global.fetch = jest.fn().mockResolvedValue({
+ ok: true,
+ status: 200,
+ text: () => Promise.resolve(JSON.stringify({ data: "test" })),
+ json: () => Promise.resolve({ data: "test" }),
+ });
+
+ const result = await fetcherImpl(mockArgs);
+
+ expect(global.fetch).toHaveBeenCalledWith(
+ url,
+ expect.objectContaining({
+ method: "POST",
+ headers: expect.objectContaining({ "X-Test": "x-test-header" }),
+ body: expect.any(fs.ReadStream),
+ })
+ );
+ expect(result.ok).toBe(true);
+ if (result.ok) {
+ expect(result.body).toEqual({ data: "test" });
+ }
});
});
diff --git a/tests/unit/fetcher/getRequestBody.test.ts b/tests/unit/fetcher/getRequestBody.test.ts
index 1b1462c5..919604c2 100644
--- a/tests/unit/fetcher/getRequestBody.test.ts
+++ b/tests/unit/fetcher/getRequestBody.test.ts
@@ -1,10 +1,6 @@
import { RUNTIME } from "../../../src/core/runtime";
import { getRequestBody } from "../../../src/core/fetcher/getRequestBody";
-if (RUNTIME.type === "browser") {
- require("jest-fetch-mock").enableMocks();
-}
-
describe("Test getRequestBody", () => {
it("should return FormData as is in Node environment", async () => {
if (RUNTIME.type === "node") {
diff --git a/tests/unit/fetcher/getResponseBody.test.ts b/tests/unit/fetcher/getResponseBody.test.ts
index 3510779e..1030c517 100644
--- a/tests/unit/fetcher/getResponseBody.test.ts
+++ b/tests/unit/fetcher/getResponseBody.test.ts
@@ -2,10 +2,6 @@ import { RUNTIME } from "../../../src/core/runtime";
import { getResponseBody } from "../../../src/core/fetcher/getResponseBody";
import { chooseStreamWrapper } from "../../../src/core/fetcher/stream-wrappers/chooseStreamWrapper";
-if (RUNTIME.type === "browser") {
- require("jest-fetch-mock").enableMocks();
-}
-
describe("Test getResponseBody", () => {
it("should handle blob response type", async () => {
const mockBlob = new Blob(["test"], { type: "text/plain" });
diff --git a/tests/unit/fetcher/makeRequest.test.ts b/tests/unit/fetcher/makeRequest.test.ts
index 5969d515..be94ab45 100644
--- a/tests/unit/fetcher/makeRequest.test.ts
+++ b/tests/unit/fetcher/makeRequest.test.ts
@@ -1,10 +1,6 @@
import { RUNTIME } from "../../../src/core/runtime";
import { makeRequest } from "../../../src/core/fetcher/makeRequest";
-if (RUNTIME.type === "browser") {
- require("jest-fetch-mock").enableMocks();
-}
-
describe("Test makeRequest", () => {
const mockPostUrl = "https://httpbin.org/post";
const mockGetUrl = "https://httpbin.org/get";
diff --git a/tests/unit/fetcher/requestWithRetries.test.ts b/tests/unit/fetcher/requestWithRetries.test.ts
index b53e0436..6f77f093 100644
--- a/tests/unit/fetcher/requestWithRetries.test.ts
+++ b/tests/unit/fetcher/requestWithRetries.test.ts
@@ -1,85 +1,133 @@
import { RUNTIME } from "../../../src/core/runtime";
import { requestWithRetries } from "../../../src/core/fetcher/requestWithRetries";
-if (RUNTIME.type === "browser") {
- require("jest-fetch-mock").enableMocks();
-}
-
-describe("Test exponential backoff", () => {
+describe("requestWithRetries", () => {
let mockFetch: jest.Mock;
- let originalSetTimeout: typeof setTimeout;
+ let originalMathRandom: typeof Math.random;
+ let setTimeoutSpy: jest.SpyInstance;
beforeEach(() => {
mockFetch = jest.fn();
- originalSetTimeout = global.setTimeout;
- jest.useFakeTimers();
+ originalMathRandom = Math.random;
+
+ // Mock Math.random for consistent jitter
+ Math.random = jest.fn(() => 0.5);
+
+ jest.useFakeTimers({ doNotFake: ["nextTick"] });
});
afterEach(() => {
- jest.useRealTimers();
- global.setTimeout = originalSetTimeout;
+ Math.random = originalMathRandom;
+ jest.clearAllMocks();
+ jest.clearAllTimers();
});
- it("should retry on 408, 409, 429, 500+", async () => {
- mockFetch
- .mockResolvedValueOnce(new Response("", { status: 408 }))
- .mockResolvedValueOnce(new Response("", { status: 409 }))
- .mockResolvedValueOnce(new Response("", { status: 429 }))
- .mockResolvedValueOnce(new Response("", { status: 500 }))
- .mockResolvedValueOnce(new Response("", { status: 502 }))
- .mockResolvedValueOnce(new Response("", { status: 200 }))
- .mockResolvedValueOnce(new Response("", { status: 408 }));
+ it("should retry on retryable status codes", async () => {
+ setTimeoutSpy = jest.spyOn(global, "setTimeout").mockImplementation((callback) => {
+ process.nextTick(callback);
+ return null as any;
+ });
+
+ const retryableStatuses = [408, 409, 429, 500, 502];
+ let callCount = 0;
- const responsePromise = requestWithRetries(() => mockFetch(), 10);
+ mockFetch.mockImplementation(async () => {
+ if (callCount < retryableStatuses.length) {
+ return new Response("", { status: retryableStatuses[callCount++] });
+ }
+ return new Response("", { status: 200 });
+ });
- await jest.advanceTimersByTimeAsync(10000);
+ const responsePromise = requestWithRetries(() => mockFetch(), retryableStatuses.length);
+ await jest.runAllTimersAsync();
const response = await responsePromise;
- expect(mockFetch).toHaveBeenCalledTimes(6);
+ expect(mockFetch).toHaveBeenCalledTimes(retryableStatuses.length + 1);
expect(response.status).toBe(200);
});
- it("should retry max 3 times", async () => {
- mockFetch
- .mockResolvedValueOnce(new Response("", { status: 408 }))
- .mockResolvedValueOnce(new Response("", { status: 409 }))
- .mockResolvedValueOnce(new Response("", { status: 429 }))
- .mockResolvedValueOnce(new Response("", { status: 429 }));
+ it("should respect maxRetries limit", async () => {
+ setTimeoutSpy = jest.spyOn(global, "setTimeout").mockImplementation((callback) => {
+ process.nextTick(callback);
+ return null as any;
+ });
- const responsePromise = requestWithRetries(() => mockFetch(), 3);
+ const maxRetries = 2;
+ mockFetch.mockResolvedValue(new Response("", { status: 500 }));
- await jest.advanceTimersByTimeAsync(10000);
+ const responsePromise = requestWithRetries(() => mockFetch(), maxRetries);
+ await jest.runAllTimersAsync();
const response = await responsePromise;
- expect(mockFetch).toHaveBeenCalledTimes(4);
- expect(response.status).toBe(429);
+ expect(mockFetch).toHaveBeenCalledTimes(maxRetries + 1);
+ expect(response.status).toBe(500);
});
- it("should not retry on 200", async () => {
- mockFetch
- .mockResolvedValueOnce(new Response("", { status: 200 }))
- .mockResolvedValueOnce(new Response("", { status: 409 }));
- const responsePromise = requestWithRetries(() => mockFetch(), 3);
+ it("should not retry on success status codes", async () => {
+ setTimeoutSpy = jest.spyOn(global, "setTimeout").mockImplementation((callback) => {
+ process.nextTick(callback);
+ return null as any;
+ });
- await jest.advanceTimersByTimeAsync(10000);
- const response = await responsePromise;
+ const successStatuses = [200, 201, 202];
- expect(mockFetch).toHaveBeenCalledTimes(1);
- expect(response.status).toBe(200);
+ for (const status of successStatuses) {
+ mockFetch.mockReset();
+ setTimeoutSpy.mockClear();
+ mockFetch.mockResolvedValueOnce(new Response("", { status }));
+
+ const responsePromise = requestWithRetries(() => mockFetch(), 3);
+ await jest.runAllTimersAsync();
+ await responsePromise;
+
+ expect(mockFetch).toHaveBeenCalledTimes(1);
+ expect(setTimeoutSpy).not.toHaveBeenCalled();
+ }
});
- it("should retry with exponential backoff timing", async () => {
+ it("should apply correct exponential backoff with jitter", async () => {
+ setTimeoutSpy = jest.spyOn(global, "setTimeout").mockImplementation((callback) => {
+ process.nextTick(callback);
+ return null as any;
+ });
+
mockFetch.mockResolvedValue(new Response("", { status: 500 }));
- const maxRetries = 7;
+ const maxRetries = 3;
+ const expectedDelays = [1000, 2000, 4000];
+
const responsePromise = requestWithRetries(() => mockFetch(), maxRetries);
- expect(mockFetch).toHaveBeenCalledTimes(1);
+ await jest.runAllTimersAsync();
+ await responsePromise;
- const delays = [1, 2, 4, 8, 16, 32, 64];
- for (let i = 0; i < delays.length; i++) {
- await jest.advanceTimersByTimeAsync(delays[i] as number);
- expect(mockFetch).toHaveBeenCalledTimes(Math.min(i + 2, maxRetries + 1));
- }
- const response = await responsePromise;
- expect(response.status).toBe(500);
+ // Verify setTimeout calls
+ expect(setTimeoutSpy).toHaveBeenCalledTimes(expectedDelays.length);
+
+ expectedDelays.forEach((delay, index) => {
+ expect(setTimeoutSpy).toHaveBeenNthCalledWith(index + 1, expect.any(Function), delay);
+ });
+
+ expect(mockFetch).toHaveBeenCalledTimes(maxRetries + 1);
+ });
+
+ it("should handle concurrent retries independently", async () => {
+ setTimeoutSpy = jest.spyOn(global, "setTimeout").mockImplementation((callback) => {
+ process.nextTick(callback);
+ return null as any;
+ });
+
+ mockFetch
+ .mockResolvedValueOnce(new Response("", { status: 500 }))
+ .mockResolvedValueOnce(new Response("", { status: 500 }))
+ .mockResolvedValueOnce(new Response("", { status: 200 }))
+ .mockResolvedValueOnce(new Response("", { status: 200 }));
+
+ const promise1 = requestWithRetries(() => mockFetch(), 1);
+ const promise2 = requestWithRetries(() => mockFetch(), 1);
+
+ await jest.runAllTimersAsync();
+ const [response1, response2] = await Promise.all([promise1, promise2]);
+
+ expect(response1.status).toBe(200);
+ expect(response2.status).toBe(200);
});
});
diff --git a/tests/unit/fetcher/stream-wrappers/Node18UniversalStreamWrapper.test.ts b/tests/unit/fetcher/stream-wrappers/Node18UniversalStreamWrapper.test.ts
index e307b158..1dc9be0c 100644
--- a/tests/unit/fetcher/stream-wrappers/Node18UniversalStreamWrapper.test.ts
+++ b/tests/unit/fetcher/stream-wrappers/Node18UniversalStreamWrapper.test.ts
@@ -60,7 +60,7 @@ describe("Node18UniversalStreamWrapper", () => {
},
});
const stream = new Node18UniversalStreamWrapper(rawStream);
- const dest = new (await import("stream")).Writable({
+ const dest = new (await import("readable-stream")).Writable({
write(chunk, encoding, callback) {
expect(chunk.toString()).toEqual("test");
callback();
diff --git a/tests/unit/fetcher/stream-wrappers/NodePre18StreamWrapper.test.ts b/tests/unit/fetcher/stream-wrappers/NodePre18StreamWrapper.test.ts
index 861142a0..0c99d3b2 100644
--- a/tests/unit/fetcher/stream-wrappers/NodePre18StreamWrapper.test.ts
+++ b/tests/unit/fetcher/stream-wrappers/NodePre18StreamWrapper.test.ts
@@ -2,7 +2,7 @@ import { NodePre18StreamWrapper } from "../../../../src/core/fetcher/stream-wrap
describe("NodePre18StreamWrapper", () => {
it("should set encoding to utf-8", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
const stream = new NodePre18StreamWrapper(rawStream);
const setEncodingSpy = jest.spyOn(stream, "setEncoding");
@@ -12,7 +12,7 @@ describe("NodePre18StreamWrapper", () => {
});
it("should register an event listener for readable", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
const stream = new NodePre18StreamWrapper(rawStream);
const onSpy = jest.spyOn(stream, "on");
@@ -22,7 +22,7 @@ describe("NodePre18StreamWrapper", () => {
});
it("should remove an event listener for data", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
const stream = new NodePre18StreamWrapper(rawStream);
const offSpy = jest.spyOn(stream, "off");
@@ -34,9 +34,9 @@ describe("NodePre18StreamWrapper", () => {
});
it("should write to dest when calling pipe to node writable stream", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
const stream = new NodePre18StreamWrapper(rawStream);
- const dest = new (await import("stream")).Writable({
+ const dest = new (await import("readable-stream")).Writable({
write(chunk, encoding, callback) {
expect(chunk.toString()).toEqual("test");
callback();
@@ -47,10 +47,10 @@ describe("NodePre18StreamWrapper", () => {
});
it("should write nothing when calling pipe and unpipe", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
const stream = new NodePre18StreamWrapper(rawStream);
const buffer: Uint8Array[] = [];
- const dest = new (await import("stream")).Writable({
+ const dest = new (await import("readable-stream")).Writable({
write(chunk, encoding, callback) {
buffer.push(chunk);
callback();
@@ -63,7 +63,7 @@ describe("NodePre18StreamWrapper", () => {
});
it("should destroy the stream", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
const stream = new NodePre18StreamWrapper(rawStream);
const destroySpy = jest.spyOn(stream, "destroy");
@@ -73,7 +73,7 @@ describe("NodePre18StreamWrapper", () => {
});
it("should pause the stream and resume", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
const stream = new NodePre18StreamWrapper(rawStream);
const pauseSpy = jest.spyOn(stream, "pause");
@@ -86,7 +86,7 @@ describe("NodePre18StreamWrapper", () => {
});
it("should read the stream", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
const stream = new NodePre18StreamWrapper(rawStream);
expect(await stream.read()).toEqual("test");
@@ -94,7 +94,7 @@ describe("NodePre18StreamWrapper", () => {
});
it("should read the stream as text", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
const stream = new NodePre18StreamWrapper(rawStream);
const data = await stream.text();
@@ -103,7 +103,7 @@ describe("NodePre18StreamWrapper", () => {
});
it("should read the stream as json", async () => {
- const rawStream = (await import("stream")).Readable.from([JSON.stringify({ test: "test" })]);
+ const rawStream = (await import("readable-stream")).Readable.from([JSON.stringify({ test: "test" })]);
const stream = new NodePre18StreamWrapper(rawStream);
const data = await stream.json();
@@ -112,7 +112,7 @@ describe("NodePre18StreamWrapper", () => {
});
it("should allow use with async iteratable stream", async () => {
- const rawStream = (await import("stream")).Readable.from(["test", "test"]);
+ const rawStream = (await import("readable-stream")).Readable.from(["test", "test"]);
let data = "";
const stream = new NodePre18StreamWrapper(rawStream);
for await (const chunk of stream) {
diff --git a/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts b/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts
index aff7579e..17cf37a2 100644
--- a/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts
+++ b/tests/unit/fetcher/stream-wrappers/chooseStreamWrapper.test.ts
@@ -21,7 +21,7 @@ describe("chooseStreamWrapper", () => {
});
it('should return a NodePre18StreamWrapper when RUNTIME.type is "node" and RUNTIME.parsedVersion is not null and RUNTIME.parsedVersion is less than 18', async () => {
- const stream = await import("stream");
+ const stream = await import("readable-stream");
const expected = new NodePre18StreamWrapper(new stream.Readable());
RUNTIME.type = "node";
diff --git a/tests/unit/fetcher/stream-wrappers/webpack.test.ts b/tests/unit/fetcher/stream-wrappers/webpack.test.ts
new file mode 100644
index 00000000..557db6dc
--- /dev/null
+++ b/tests/unit/fetcher/stream-wrappers/webpack.test.ts
@@ -0,0 +1,38 @@
+import webpack from "webpack";
+
+describe("test env compatibility", () => {
+ test("webpack", () => {
+ return new Promise((resolve, reject) => {
+ webpack(
+ {
+ mode: "production",
+ entry: "./src/index.ts",
+ module: {
+ rules: [
+ {
+ test: /\.tsx?$/,
+ use: "ts-loader",
+ exclude: /node_modules/,
+ },
+ ],
+ },
+ resolve: {
+ extensions: [".tsx", ".ts", ".js"],
+ },
+ },
+ (err, stats) => {
+ try {
+ expect(err).toBe(null);
+ if (stats?.hasErrors()) {
+ console.log(stats?.toString());
+ }
+ expect(stats?.hasErrors()).toBe(false);
+ resolve();
+ } catch (error) {
+ reject(error);
+ }
+ }
+ );
+ });
+ }, 60_000);
+});
diff --git a/tests/unit/fetcher/test-file.txt b/tests/unit/fetcher/test-file.txt
new file mode 100644
index 00000000..c66d471e
--- /dev/null
+++ b/tests/unit/fetcher/test-file.txt
@@ -0,0 +1 @@
+This is a test file!
diff --git a/tests/unit/zurg/bigint/bigint.test.ts b/tests/unit/zurg/bigint/bigint.test.ts
new file mode 100644
index 00000000..cf9935a7
--- /dev/null
+++ b/tests/unit/zurg/bigint/bigint.test.ts
@@ -0,0 +1,24 @@
+import { bigint } from "../../../../src/core/schemas/builders/bigint";
+import { itSchema } from "../utils/itSchema";
+import { itValidateJson, itValidateParse } from "../utils/itValidate";
+
+describe("bigint", () => {
+ itSchema("converts between raw string and parsed bigint", bigint(), {
+ raw: "123456789012345678901234567890123456789012345678901234567890",
+ parsed: BigInt("123456789012345678901234567890123456789012345678901234567890"),
+ });
+
+ itValidateParse("non-string", bigint(), 42, [
+ {
+ message: "Expected string. Received 42.",
+ path: [],
+ },
+ ]);
+
+ itValidateJson("non-bigint", bigint(), "hello", [
+ {
+ message: 'Expected bigint. Received "hello".',
+ path: [],
+ },
+ ]);
+});
diff --git a/tests/unit/zurg/object/passthrough.test.ts b/tests/unit/zurg/object/passthrough.test.ts
new file mode 100644
index 00000000..28ce3b1f
--- /dev/null
+++ b/tests/unit/zurg/object/passthrough.test.ts
@@ -0,0 +1,87 @@
+import { object, string, stringLiteral } from "../../../../src/core/schemas/builders";
+import { itJson, itParse, itSchema } from "../utils/itSchema";
+import { itValidate } from "../utils/itValidate";
+
+describe("passthrough", () => {
+ const baseSchema = object({
+ foo: string(),
+ bar: stringLiteral("bar"),
+ });
+
+ describe("parse", () => {
+ itParse("includes unknown values", baseSchema.passthrough(), {
+ raw: {
+ foo: "hello",
+ bar: "bar",
+ baz: "extra",
+ },
+ parsed: {
+ foo: "hello",
+ bar: "bar",
+ baz: "extra",
+ },
+ });
+
+ itValidate(
+ "preserves schema validation",
+ baseSchema.passthrough(),
+ {
+ foo: 123,
+ bar: "bar",
+ baz: "extra",
+ },
+ [
+ {
+ path: ["foo"],
+ message: "Expected string. Received 123.",
+ },
+ ]
+ );
+ });
+
+ describe("json", () => {
+ itJson("includes unknown values", baseSchema.passthrough(), {
+ raw: {
+ foo: "hello",
+ bar: "bar",
+
+ baz: "extra",
+ },
+ parsed: {
+ foo: "hello",
+ bar: "bar",
+
+ baz: "extra",
+ },
+ });
+
+ itValidate(
+ "preserves schema validation",
+ baseSchema.passthrough(),
+ {
+ foo: "hello",
+ bar: "wrong",
+ baz: "extra",
+ },
+ [
+ {
+ path: ["bar"],
+ message: 'Expected "bar". Received "wrong".',
+ },
+ ]
+ );
+ });
+
+ itSchema("preserves schema validation in both directions", baseSchema.passthrough(), {
+ raw: {
+ foo: "hello",
+ bar: "bar",
+ extra: 42,
+ },
+ parsed: {
+ foo: "hello",
+ bar: "bar",
+ extra: 42,
+ },
+ });
+});
diff --git a/yarn.lock b/yarn.lock
index 0a18f5c0..afcc7ce7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -597,7 +597,7 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.26.3.tgz#99488264a56b2aded63983abd6a417f03b92ed02"
integrity sha512-nHIxvKPniQXpmQLb0vhY3VaFb3S0YrTAwpOWJZh1wn3oJPjJk9Asva204PsBdmAE8vpzfHudT8DB0scYvy9q0g==
-"@babel/core@^7.0.0", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.23.9":
+"@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.23.9":
version "7.26.0"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.26.0.tgz#d78b6023cc8f3114ccf049eb219613f74a747b40"
integrity sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==
@@ -811,13 +811,6 @@
dependencies:
"@babel/helper-plugin-utils" "^7.25.9"
-"@babel/runtime@^7.0.0":
- version "7.26.0"
- resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1"
- integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==
- dependencies:
- regenerator-runtime "^0.14.0"
-
"@babel/template@^7.25.9", "@babel/template@^7.3.3":
version "7.25.9"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.25.9.tgz#ecb62d81a8a6f5dc5fe8abfc3901fc52ddf15016"
@@ -2304,11 +2297,6 @@ convict@^6.2.4:
lodash.clonedeep "^4.5.0"
yargs-parser "^20.2.7"
-core-js@^3.0.0:
- version "3.39.0"
- resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.39.0.tgz#57f7647f4d2d030c32a72ea23a0555b2eaa30f83"
- integrity sha512-raM0ew0/jJUqkJ0E6e8UDtl+y/7ktFivgWvqw8dNSQeNWoSDLvQ1H/RN3aPXB9tBd4/FhyR4RDPGhsNIMsAn7g==
-
create-jest@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320"
@@ -2582,9 +2570,9 @@ fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0, fast-json-sta
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
fast-uri@^3.0.1:
- version "3.0.3"
- resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.0.3.tgz#892a1c91802d5d7860de728f18608a0573142241"
- integrity sha512-aLrHthzCjH5He4Z2H9YZ+v6Ujb9ocRuW6ZzkJQOrTxleEijANq4v1TsaPaVG1PZcuurEzrLcWRyYBYXD5cEiaw==
+ version "3.0.5"
+ resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.0.5.tgz#19f5f9691d0dab9b85861a7bb5d98fca961da9cd"
+ integrity sha512-5JnBCWpFlMo0a3ciDy/JckMzzv1U9coZrIhedq+HXxxUfDTAiS0LA8OKVao4G9BxmCVck/jtA5r3KAtRWEyD8Q==
fast-xml-parser@4.4.1:
version "4.4.1"
@@ -2600,29 +2588,6 @@ fb-watchman@^2.0.0:
dependencies:
bser "2.1.1"
-fetch-mock-jest@^1.5.1:
- version "1.5.1"
- resolved "https://registry.yarnpkg.com/fetch-mock-jest/-/fetch-mock-jest-1.5.1.tgz#0e13df990d286d9239e284f12b279ed509bf53cd"
- integrity sha512-+utwzP8C+Pax1GSka3nFXILWMY3Er2L+s090FOgqVNrNCPp0fDqgXnAHAJf12PLHi0z4PhcTaZNTz8e7K3fjqQ==
- dependencies:
- fetch-mock "^9.11.0"
-
-fetch-mock@^9.11.0:
- version "9.11.0"
- resolved "https://registry.yarnpkg.com/fetch-mock/-/fetch-mock-9.11.0.tgz#371c6fb7d45584d2ae4a18ee6824e7ad4b637a3f"
- integrity sha512-PG1XUv+x7iag5p/iNHD4/jdpxL9FtVSqRMUQhPab4hVDt80T1MH5ehzVrL2IdXO9Q2iBggArFvPqjUbHFuI58Q==
- dependencies:
- "@babel/core" "^7.0.0"
- "@babel/runtime" "^7.0.0"
- core-js "^3.0.0"
- debug "^4.1.1"
- glob-to-regexp "^0.4.0"
- is-subset "^0.1.1"
- lodash.isequal "^4.5.0"
- path-to-regexp "^2.2.1"
- querystring "^0.2.0"
- whatwg-url "^6.5.0"
-
filelist@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.4.tgz#f78978a1e944775ff9e62e744424f215e58352b5"
@@ -2723,7 +2688,7 @@ get-stream@^6.0.0:
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7"
integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==
-glob-to-regexp@^0.4.0, glob-to-regexp@^0.4.1:
+glob-to-regexp@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==
@@ -2881,11 +2846,6 @@ is-stream@^2.0.0:
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077"
integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==
-is-subset@^0.1.1:
- version "0.1.1"
- resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6"
- integrity sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==
-
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
@@ -3442,21 +3402,11 @@ lodash.clonedeep@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==
-lodash.isequal@^4.5.0:
- version "4.5.0"
- resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
- integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==
-
lodash.memoize@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==
-lodash.sortby@^4.7.0:
- version "4.7.0"
- resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
- integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==
-
lru-cache@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
@@ -3663,11 +3613,6 @@ path-parse@^1.0.7:
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
-path-to-regexp@^2.2.1:
- version "2.4.0"
- resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-2.4.0.tgz#35ce7f333d5616f1c1e1bfe266c3aba2e5b2e704"
- integrity sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w==
-
picocolors@^1.0.0, picocolors@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b"
@@ -3741,11 +3686,6 @@ qs@6.11.2:
dependencies:
side-channel "^1.0.4"
-querystring@^0.2.0:
- version "0.2.1"
- resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.1.tgz#40d77615bb09d16902a85c3e38aa8b5ed761c2dd"
- integrity sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==
-
querystringify@^2.1.1:
version "2.2.0"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6"
@@ -3774,11 +3714,6 @@ readable-stream@^4.5.2:
process "^0.11.10"
string_decoder "^1.3.0"
-regenerator-runtime@^0.14.0:
- version "0.14.1"
- resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f"
- integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==
-
require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
@@ -4115,13 +4050,6 @@ tough-cookie@^4.1.2:
universalify "^0.2.0"
url-parse "^1.5.3"
-tr46@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09"
- integrity sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==
- dependencies:
- punycode "^2.1.0"
-
tr46@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-3.0.0.tgz#555c4e297a950617e8eeddef633c87d4d9d6cbf9"
@@ -4264,11 +4192,6 @@ webidl-conversions@^3.0.0:
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==
-webidl-conversions@^4.0.2:
- version "4.0.2"
- resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
- integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==
-
webidl-conversions@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a"
@@ -4336,15 +4259,6 @@ whatwg-url@^5.0.0:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"
-whatwg-url@^6.5.0:
- version "6.5.0"
- resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.5.0.tgz#f2df02bff176fd65070df74ad5ccbb5a199965a8"
- integrity sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==
- dependencies:
- lodash.sortby "^4.7.0"
- tr46 "^1.0.1"
- webidl-conversions "^4.0.2"
-
which@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"