From c6d41e4b9ccf719d6728c03e9059479622f000d9 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:20:39 +0000 Subject: [PATCH 1/3] SDK regeneration --- package.json | 2 +- src/Client.ts | 179 ++++++++---------- src/api/client/requests/ChatRequest.ts | 27 +++ src/api/client/requests/ChatStreamRequest.ts | 9 + src/api/client/requests/ClassifyRequest.ts | 9 + .../client/requests/DetectLanguageRequest.ts | 16 -- src/api/client/requests/DetokenizeRequest.ts | 6 + src/api/client/requests/GenerateRequest.ts | 29 ++- .../client/requests/GenerateStreamRequest.ts | 19 +- src/api/client/requests/RerankRequest.ts | 7 + src/api/client/requests/SummarizeRequest.ts | 9 + src/api/client/requests/TokenizeRequest.ts | 6 + src/api/client/requests/index.ts | 1 - src/api/resources/connectors/client/Client.ts | 51 +++-- .../client/requests/CreateConnectorRequest.ts | 12 ++ .../client/requests/UpdateConnectorRequest.ts | 10 + src/api/resources/datasets/client/Client.ts | 65 ++----- src/api/resources/embedJobs/client/Client.ts | 29 ++- .../client/requests/CreateEmbedJobRequest.ts | 9 + src/api/types/ChatConnector.ts | 2 +- src/api/types/ChatRequestPromptOverride.ts | 12 ++ src/api/types/ChatRequestSearchOptions.ts | 13 ++ src/api/types/ChatSearchResult.ts | 2 +- src/api/types/ChatSearchResultConnector.ts | 11 ++ .../types/ChatStreamRequestPromptOverride.ts | 12 ++ .../types/ChatStreamRequestSearchOptions.ts | 13 ++ src/api/types/DetectLanguageResponse.ts | 11 -- .../DetectLanguageResponseResultsItem.ts | 8 - src/api/types/index.ts | 7 +- src/core/fetcher/Fetcher.ts | 37 ++-- src/environments.ts | 2 +- .../client/requests/ChatRequest.ts | 4 + .../client/requests/ChatStreamRequest.ts | 4 + .../client/requests/DetectLanguageRequest.ts | 22 --- .../client/requests/GenerateRequest.ts | 2 + .../client/requests/GenerateStreamRequest.ts | 2 + src/serialization/client/requests/index.ts | 1 - .../types/ChatRequestPromptOverride.ts | 24 +++ .../types/ChatRequestSearchOptions.ts | 26 +++ src/serialization/types/ChatSearchResult.ts | 4 +- .../types/ChatSearchResultConnector.ts | 20 ++ .../types/ChatStreamRequestPromptOverride.ts | 24 +++ .../types/ChatStreamRequestSearchOptions.ts | 26 +++ .../types/DetectLanguageResponse.ts | 24 --- .../DetectLanguageResponseResultsItem.ts | 22 --- src/serialization/types/index.ts | 7 +- yarn.lock | 6 +- 47 files changed, 526 insertions(+), 317 deletions(-) delete mode 100644 src/api/client/requests/DetectLanguageRequest.ts create mode 100644 src/api/types/ChatRequestPromptOverride.ts create mode 100644 src/api/types/ChatRequestSearchOptions.ts create mode 100644 src/api/types/ChatSearchResultConnector.ts create mode 100644 src/api/types/ChatStreamRequestPromptOverride.ts create mode 100644 src/api/types/ChatStreamRequestSearchOptions.ts delete mode 100644 src/api/types/DetectLanguageResponse.ts delete mode 100644 src/api/types/DetectLanguageResponseResultsItem.ts delete mode 100644 src/serialization/client/requests/DetectLanguageRequest.ts create mode 100644 src/serialization/types/ChatRequestPromptOverride.ts create mode 100644 src/serialization/types/ChatRequestSearchOptions.ts create mode 100644 src/serialization/types/ChatSearchResultConnector.ts create mode 100644 src/serialization/types/ChatStreamRequestPromptOverride.ts create mode 100644 src/serialization/types/ChatStreamRequestSearchOptions.ts delete mode 100644 src/serialization/types/DetectLanguageResponse.ts delete mode 100644 src/serialization/types/DetectLanguageResponseResultsItem.ts diff --git a/package.json b/package.json index f3f64b5..0a44277 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cohere-ai", - "version": "7.7.3", + "version": "7.7.4", "private": false, "repository": "https://github.com/cohere-ai/cohere-typescript", "main": "./index.js", diff --git a/src/Client.ts b/src/Client.ts index 134512c..132e9d7 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -41,7 +41,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "chat" + "v1/chat" ), method: "POST", headers: { @@ -52,13 +52,10 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", - body: { - ...(await serializers.ChatStreamRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" })), - stream: true, - }, + body: await serializers.ChatStreamRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), responseType: "streaming", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, @@ -105,6 +102,23 @@ export class CohereClient { * The `chat` endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the `conversation_id` parameter, or they can pass in their own conversation history using the `chat_history` parameter. * * The endpoint features additional parameters such as [connectors](https://docs.cohere.com/docs/connectors) and `documents` that enable conversations enriched by external knowledge. We call this ["Retrieval Augmented Generation"](https://docs.cohere.com/docs/retrieval-augmented-generation-rag), or "RAG". For a full breakdown of the Chat API endpoint, document and connector modes, and streaming (with code samples), see [this guide](https://docs.cohere.com/docs/cochat-beta). + * + * @example + * await cohere.chat({ + * message: "string", + * stream: false, + * chatHistory: [{ + * role: Cohere.ChatMessageRole.Chatbot, + * message: "string" + * }], + * promptTruncation: Cohere.ChatRequestPromptTruncation.Off, + * connectors: [{ + * id: "string" + * }], + * citationQuality: Cohere.ChatRequestCitationQuality.Fast, + * searchOptions: {}, + * promptOverride: {} + * }) */ public async chat( request: Cohere.ChatRequest, @@ -113,7 +127,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "chat" + "v1/chat" ), method: "POST", headers: { @@ -124,13 +138,10 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", - body: { - ...(await serializers.ChatRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" })), - stream: false, - }, + body: await serializers.ChatRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, }); @@ -176,7 +187,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "generate" + "v1/generate" ), method: "POST", headers: { @@ -187,13 +198,10 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", - body: { - ...(await serializers.GenerateStreamRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" })), - stream: true, - }, + body: await serializers.GenerateStreamRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), responseType: "streaming", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, @@ -247,6 +255,15 @@ export class CohereClient { * This endpoint generates realistic text conditioned on a given input. * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.InternalServerError} + * + * @example + * await cohere.generate({ + * prompt: "Please explain to me how LLMs work", + * stream: false, + * truncate: Cohere.GenerateRequestTruncate.None, + * preset: "my-preset-a58sbd", + * returnLikelihoods: Cohere.GenerateRequestReturnLikelihoods.Generation + * }) */ public async generate( request: Cohere.GenerateRequest, @@ -255,7 +272,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "generate" + "v1/generate" ), method: "POST", headers: { @@ -266,13 +283,10 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", - body: { - ...(await serializers.GenerateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" })), - stream: false, - }, + body: await serializers.GenerateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, }); @@ -331,7 +345,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "embed" + "v1/embed" ), method: "POST", headers: { @@ -342,7 +356,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", body: await serializers.EmbedRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -390,6 +404,12 @@ export class CohereClient { /** * This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score. + * + * @example + * await cohere.rerank({ + * query: "string", + * documents: [] + * }) */ public async rerank( request: Cohere.RerankRequest, @@ -398,7 +418,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "rerank" + "v1/rerank" ), method: "POST", headers: { @@ -409,7 +429,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", body: await serializers.RerankRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -453,6 +473,14 @@ export class CohereClient { * Note: [Fine-tuned models](https://docs.cohere.com/docs/classify-fine-tuning) trained on classification examples don't require the `examples` parameter to be passed in explicitly. * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.InternalServerError} + * + * @example + * await cohere.classify({ + * inputs: [], + * examples: [{}], + * preset: "my-preset-a58sbd", + * truncate: Cohere.ClassifyRequestTruncate.None + * }) */ public async classify( request: Cohere.ClassifyRequest, @@ -461,7 +489,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "classify" + "v1/classify" ), method: "POST", headers: { @@ -472,7 +500,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", body: await serializers.ClassifyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -519,73 +547,16 @@ export class CohereClient { } /** - * This endpoint identifies which language each of the provided texts is written in. + * This endpoint generates a summary in English for a given text. * * @example - * await cohere.detectLanguage({ - * texts: [] + * await cohere.summarize({ + * text: "string", + * length: Cohere.SummarizeRequestLength.Short, + * format: Cohere.SummarizeRequestFormat.Paragraph, + * extractiveness: Cohere.SummarizeRequestExtractiveness.Low * }) */ - public async detectLanguage( - request: Cohere.DetectLanguageRequest, - requestOptions?: CohereClient.RequestOptions - ): Promise { - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "detect-language" - ), - method: "POST", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Client-Name": - (await core.Supplier.get(this._options.clientName)) != null - ? await core.Supplier.get(this._options.clientName) - : undefined, - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", - }, - contentType: "application/json", - body: await serializers.DetectLanguageRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, - maxRetries: requestOptions?.maxRetries, - }); - if (_response.ok) { - return await serializers.DetectLanguageResponse.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }); - } - - if (_response.error.reason === "status-code") { - throw new errors.CohereError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - - switch (_response.error.reason) { - case "non-json": - throw new errors.CohereError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.CohereTimeoutError(); - case "unknown": - throw new errors.CohereError({ - message: _response.error.errorMessage, - }); - } - } - - /** - * This endpoint generates a summary in English for a given text. - */ public async summarize( request: Cohere.SummarizeRequest, requestOptions?: CohereClient.RequestOptions @@ -593,7 +564,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "summarize" + "v1/summarize" ), method: "POST", headers: { @@ -604,7 +575,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", body: await serializers.SummarizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -647,6 +618,11 @@ export class CohereClient { * This endpoint splits input text into smaller units called tokens using byte-pair encoding (BPE). To learn more about tokenization and byte pair encoding, see the tokens page. * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.InternalServerError} + * + * @example + * await cohere.tokenize({ + * text: "string" + * }) */ public async tokenize( request: Cohere.TokenizeRequest, @@ -655,7 +631,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "tokenize" + "v1/tokenize" ), method: "POST", headers: { @@ -666,7 +642,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", body: await serializers.TokenizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -714,6 +690,11 @@ export class CohereClient { /** * This endpoint takes tokens using byte-pair encoding and returns their text representation. To learn more about tokenization and byte pair encoding, see the tokens page. + * + * @example + * await cohere.detokenize({ + * tokens: [] + * }) */ public async detokenize( request: Cohere.DetokenizeRequest, @@ -722,7 +703,7 @@ export class CohereClient { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "detokenize" + "v1/detokenize" ), method: "POST", headers: { @@ -733,7 +714,7 @@ export class CohereClient { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", body: await serializers.DetokenizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), diff --git a/src/api/client/requests/ChatRequest.ts b/src/api/client/requests/ChatRequest.ts index e834788..7ff4586 100644 --- a/src/api/client/requests/ChatRequest.ts +++ b/src/api/client/requests/ChatRequest.ts @@ -4,6 +4,24 @@ import * as Cohere from "../.."; +/** + * @example + * { + * message: "string", + * stream: false, + * chatHistory: [{ + * role: Cohere.ChatMessageRole.Chatbot, + * message: "string" + * }], + * promptTruncation: Cohere.ChatRequestPromptTruncation.Off, + * connectors: [{ + * id: "string" + * }], + * citationQuality: Cohere.ChatRequestCitationQuality.Fast, + * searchOptions: {}, + * promptOverride: {} + * } + */ export interface ChatRequest { /** * Accepts a string. @@ -79,6 +97,15 @@ export interface ChatRequest { * * A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations. * + * Randomness can be further maximized by increasing the value of the `p` parameter. + * */ temperature?: number; + /** + * Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + * + */ + frequencyPenalty?: number; + /** Defaults to `0.0`, min value of `0.0`, max value of `1.0`. Can be used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. */ + presencePenalty?: number; } diff --git a/src/api/client/requests/ChatStreamRequest.ts b/src/api/client/requests/ChatStreamRequest.ts index 43c322e..5b6155e 100644 --- a/src/api/client/requests/ChatStreamRequest.ts +++ b/src/api/client/requests/ChatStreamRequest.ts @@ -79,6 +79,15 @@ export interface ChatStreamRequest { * * A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations. * + * Randomness can be further maximized by increasing the value of the `p` parameter. + * */ temperature?: number; + /** + * Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + * + */ + frequencyPenalty?: number; + /** Defaults to `0.0`, min value of `0.0`, max value of `1.0`. Can be used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. */ + presencePenalty?: number; } diff --git a/src/api/client/requests/ClassifyRequest.ts b/src/api/client/requests/ClassifyRequest.ts index f3540a4..89f1cc2 100644 --- a/src/api/client/requests/ClassifyRequest.ts +++ b/src/api/client/requests/ClassifyRequest.ts @@ -4,6 +4,15 @@ import * as Cohere from "../.."; +/** + * @example + * { + * inputs: [], + * examples: [{}], + * preset: "my-preset-a58sbd", + * truncate: Cohere.ClassifyRequestTruncate.None + * } + */ export interface ClassifyRequest { /** * A list of up to 96 texts to be classified. Each one must be a non-empty string. diff --git a/src/api/client/requests/DetectLanguageRequest.ts b/src/api/client/requests/DetectLanguageRequest.ts deleted file mode 100644 index f9b5475..0000000 --- a/src/api/client/requests/DetectLanguageRequest.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -/** - * @example - * { - * texts: [] - * } - */ -export interface DetectLanguageRequest { - /** List of strings to run the detection on. */ - texts: string[]; - /** The identifier of the model to generate with. */ - model?: string; -} diff --git a/src/api/client/requests/DetokenizeRequest.ts b/src/api/client/requests/DetokenizeRequest.ts index fa20aa9..777a5d1 100644 --- a/src/api/client/requests/DetokenizeRequest.ts +++ b/src/api/client/requests/DetokenizeRequest.ts @@ -2,6 +2,12 @@ * This file was auto-generated by Fern from our API Definition. */ +/** + * @example + * { + * tokens: [] + * } + */ export interface DetokenizeRequest { /** The list of tokens to be detokenized. */ tokens: number[]; diff --git a/src/api/client/requests/GenerateRequest.ts b/src/api/client/requests/GenerateRequest.ts index fe29cef..fa0b412 100644 --- a/src/api/client/requests/GenerateRequest.ts +++ b/src/api/client/requests/GenerateRequest.ts @@ -4,6 +4,16 @@ import * as Cohere from "../.."; +/** + * @example + * { + * prompt: "Please explain to me how LLMs work", + * stream: false, + * truncate: Cohere.GenerateRequestTruncate.None, + * preset: "my-preset-a58sbd", + * returnLikelihoods: Cohere.GenerateRequestReturnLikelihoods.Generation + * } + */ export interface GenerateRequest { /** * The input text that serves as the starting point for generating the response. @@ -67,11 +77,20 @@ export interface GenerateRequest { */ p?: number; /** - * Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.' + * Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + * + * Using `frequency_penalty` in combination with `presence_penalty` is not supported on newer models. * */ frequencyPenalty?: number; - /** Defaults to `0.0`, min value of `0.0`, max value of `1.0`. Can be used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. */ + /** + * Defaults to `0.0`, min value of `0.0`, max value of `1.0`. + * + * Can be used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. + * + * Using `frequency_penalty` in combination with `presence_penalty` is not supported on newer models. + * + */ presencePenalty?: number; /** * One of `GENERATION|ALL|NONE` to specify how and if the token likelihoods are returned with the response. Defaults to `NONE`. @@ -82,11 +101,13 @@ export interface GenerateRequest { */ returnLikelihoods?: Cohere.GenerateRequestReturnLikelihoods; /** + * Certain models support the `logit_bias` parameter. + * * Used to prevent the model from generating unwanted tokens or to incentivize it to include desired tokens. The format is `{token_id: bias}` where bias is a float between -10 and 10. Tokens can be obtained from text using [Tokenize](/reference/tokenize). * * For example, if the value `{'11': -10}` is provided, the model will be very unlikely to include the token 11 (`"\n"`, the newline character) anywhere in the generated text. In contrast `{'11': 10}` will result in generations that nearly only contain that token. Values between -10 and 10 will proportionally affect the likelihood of the token appearing in the generated text. - * - * Note: logit bias may not be supported for all custom models. */ logitBias?: Record; + /** When enabled, the user's prompt will be sent to the model without any pre-processing. */ + rawPrompting?: boolean; } diff --git a/src/api/client/requests/GenerateStreamRequest.ts b/src/api/client/requests/GenerateStreamRequest.ts index 8c6860c..0ecaeb4 100644 --- a/src/api/client/requests/GenerateStreamRequest.ts +++ b/src/api/client/requests/GenerateStreamRequest.ts @@ -67,11 +67,20 @@ export interface GenerateStreamRequest { */ p?: number; /** - * Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.' + * Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. + * + * Using `frequency_penalty` in combination with `presence_penalty` is not supported on newer models. * */ frequencyPenalty?: number; - /** Defaults to `0.0`, min value of `0.0`, max value of `1.0`. Can be used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. */ + /** + * Defaults to `0.0`, min value of `0.0`, max value of `1.0`. + * + * Can be used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. + * + * Using `frequency_penalty` in combination with `presence_penalty` is not supported on newer models. + * + */ presencePenalty?: number; /** * One of `GENERATION|ALL|NONE` to specify how and if the token likelihoods are returned with the response. Defaults to `NONE`. @@ -82,11 +91,13 @@ export interface GenerateStreamRequest { */ returnLikelihoods?: Cohere.GenerateStreamRequestReturnLikelihoods; /** + * Certain models support the `logit_bias` parameter. + * * Used to prevent the model from generating unwanted tokens or to incentivize it to include desired tokens. The format is `{token_id: bias}` where bias is a float between -10 and 10. Tokens can be obtained from text using [Tokenize](/reference/tokenize). * * For example, if the value `{'11': -10}` is provided, the model will be very unlikely to include the token 11 (`"\n"`, the newline character) anywhere in the generated text. In contrast `{'11': 10}` will result in generations that nearly only contain that token. Values between -10 and 10 will proportionally affect the likelihood of the token appearing in the generated text. - * - * Note: logit bias may not be supported for all custom models. */ logitBias?: Record; + /** When enabled, the user's prompt will be sent to the model without any pre-processing. */ + rawPrompting?: boolean; } diff --git a/src/api/client/requests/RerankRequest.ts b/src/api/client/requests/RerankRequest.ts index 816dc89..066e64f 100644 --- a/src/api/client/requests/RerankRequest.ts +++ b/src/api/client/requests/RerankRequest.ts @@ -4,6 +4,13 @@ import * as Cohere from "../.."; +/** + * @example + * { + * query: "string", + * documents: [] + * } + */ export interface RerankRequest { /** The identifier of the model to use, one of : `rerank-english-v2.0`, `rerank-multilingual-v2.0` */ model?: string; diff --git a/src/api/client/requests/SummarizeRequest.ts b/src/api/client/requests/SummarizeRequest.ts index 73bf791..38237bc 100644 --- a/src/api/client/requests/SummarizeRequest.ts +++ b/src/api/client/requests/SummarizeRequest.ts @@ -4,6 +4,15 @@ import * as Cohere from "../.."; +/** + * @example + * { + * text: "string", + * length: Cohere.SummarizeRequestLength.Short, + * format: Cohere.SummarizeRequestFormat.Paragraph, + * extractiveness: Cohere.SummarizeRequestExtractiveness.Low + * } + */ export interface SummarizeRequest { /** The text to generate a summary for. Can be up to 100,000 characters long. Currently the only supported language is English. */ text: string; diff --git a/src/api/client/requests/TokenizeRequest.ts b/src/api/client/requests/TokenizeRequest.ts index 0411de4..bdc2933 100644 --- a/src/api/client/requests/TokenizeRequest.ts +++ b/src/api/client/requests/TokenizeRequest.ts @@ -2,6 +2,12 @@ * This file was auto-generated by Fern from our API Definition. */ +/** + * @example + * { + * text: "string" + * } + */ export interface TokenizeRequest { /** The string to be tokenized, the minimum text length is 1 character, and the maximum text length is 65536 characters. */ text: string; diff --git a/src/api/client/requests/index.ts b/src/api/client/requests/index.ts index 72d990c..20584c9 100644 --- a/src/api/client/requests/index.ts +++ b/src/api/client/requests/index.ts @@ -5,7 +5,6 @@ export { GenerateRequest } from "./GenerateRequest"; export { EmbedRequest } from "./EmbedRequest"; export { RerankRequest } from "./RerankRequest"; export { ClassifyRequest } from "./ClassifyRequest"; -export { DetectLanguageRequest } from "./DetectLanguageRequest"; export { SummarizeRequest } from "./SummarizeRequest"; export { TokenizeRequest } from "./TokenizeRequest"; export { DetokenizeRequest } from "./DetokenizeRequest"; diff --git a/src/api/resources/connectors/client/Client.ts b/src/api/resources/connectors/client/Client.ts index 0eebefa..e71f9a5 100644 --- a/src/api/resources/connectors/client/Client.ts +++ b/src/api/resources/connectors/client/Client.ts @@ -50,7 +50,7 @@ export class Connectors { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "connectors" + "v1/connectors" ), method: "GET", headers: { @@ -61,7 +61,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", queryParameters: _queryParams, @@ -112,6 +112,17 @@ export class Connectors { * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.InternalServerError} + * + * @example + * await cohere.connectors.create({ + * name: "string", + * url: "string", + * oauth: {}, + * serviceAuth: { + * type: Cohere.AuthTokenType.Bearer, + * token: "string" + * } + * }) */ public async create( request: Cohere.CreateConnectorRequest, @@ -120,7 +131,7 @@ export class Connectors { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "connectors" + "v1/connectors" ), method: "POST", headers: { @@ -131,7 +142,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", body: await serializers.CreateConnectorRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -184,12 +195,15 @@ export class Connectors { * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.InternalServerError} + * + * @example + * await cohere.connectors.get("string") */ public async get(id: string, requestOptions?: Connectors.RequestOptions): Promise { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - `connectors/${id}` + `v1/connectors/${id}` ), method: "GET", headers: { @@ -200,7 +214,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -255,7 +269,7 @@ export class Connectors { * @throws {@link Cohere.InternalServerError} * * @example - * await cohere.connectors.delete("id") + * await cohere.connectors.delete("string") */ public async delete( id: string, @@ -264,7 +278,7 @@ export class Connectors { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - `connectors/${id}` + `v1/connectors/${id}` ), method: "DELETE", headers: { @@ -275,7 +289,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -330,6 +344,15 @@ export class Connectors { * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.InternalServerError} + * + * @example + * await cohere.connectors.update("string", { + * oauth: {}, + * serviceAuth: { + * type: Cohere.AuthTokenType.Bearer, + * token: "string" + * } + * }) */ public async update( id: string, @@ -339,7 +362,7 @@ export class Connectors { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - `connectors/${id}` + `v1/connectors/${id}` ), method: "PATCH", headers: { @@ -350,7 +373,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", body: await serializers.UpdateConnectorRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -407,7 +430,7 @@ export class Connectors { * @throws {@link Cohere.InternalServerError} * * @example - * await cohere.connectors.oAuthAuthorize("id", {}) + * await cohere.connectors.oAuthAuthorize("string", {}) */ public async oAuthAuthorize( id: string, @@ -423,7 +446,7 @@ export class Connectors { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - `connectors/${id}/oauth/authorize` + `v1/connectors/${id}/oauth/authorize` ), method: "POST", headers: { @@ -434,7 +457,7 @@ export class Connectors { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", queryParameters: _queryParams, diff --git a/src/api/resources/connectors/client/requests/CreateConnectorRequest.ts b/src/api/resources/connectors/client/requests/CreateConnectorRequest.ts index 275a439..b095add 100644 --- a/src/api/resources/connectors/client/requests/CreateConnectorRequest.ts +++ b/src/api/resources/connectors/client/requests/CreateConnectorRequest.ts @@ -4,6 +4,18 @@ import * as Cohere from "../../../.."; +/** + * @example + * { + * name: "string", + * url: "string", + * oauth: {}, + * serviceAuth: { + * type: Cohere.AuthTokenType.Bearer, + * token: "string" + * } + * } + */ export interface CreateConnectorRequest { /** A human-readable name for the connector. */ name: string; diff --git a/src/api/resources/connectors/client/requests/UpdateConnectorRequest.ts b/src/api/resources/connectors/client/requests/UpdateConnectorRequest.ts index 8c96ac7..84b8353 100644 --- a/src/api/resources/connectors/client/requests/UpdateConnectorRequest.ts +++ b/src/api/resources/connectors/client/requests/UpdateConnectorRequest.ts @@ -4,6 +4,16 @@ import * as Cohere from "../../../.."; +/** + * @example + * { + * oauth: {}, + * serviceAuth: { + * type: Cohere.AuthTokenType.Bearer, + * token: "string" + * } + * } + */ export interface UpdateConnectorRequest { /** A human-readable name for the connector. */ name?: string; diff --git a/src/api/resources/datasets/client/Client.ts b/src/api/resources/datasets/client/Client.ts index 9788997..c7da8df 100644 --- a/src/api/resources/datasets/client/Client.ts +++ b/src/api/resources/datasets/client/Client.ts @@ -62,7 +62,7 @@ export class Datasets { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "datasets" + "v1/datasets" ), method: "GET", headers: { @@ -73,7 +73,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", queryParameters: _queryParams, @@ -116,55 +116,18 @@ export class Datasets { * Create a dataset by uploading a file. See ['Dataset Creation'](https://docs.cohere.com/docs/datasets#dataset-creation) for more information. */ public async create( - request: Cohere.DatasetsCreateRequest, data: File | fs.ReadStream, - evalData?: File | fs.ReadStream, + evalData: File | fs.ReadStream, requestOptions?: Datasets.RequestOptions ): Promise { const _request = new FormData(); _request.append("data", data); - if (evalData) { - _request.append("eval_data", evalData); - } - - const _queryParams: any = {} - - if (request.name != null) { - _queryParams["name"] = request.name; - } - - if (request.type != null) { - _queryParams["type"] = request.type; - } - - if (request.keepOriginalFile != null) { - _queryParams["keep_original_file"] = request.keepOriginalFile; - } - if (request.skipMalformedInput != null) { - _queryParams["skip_malformed_input"] = request.skipMalformedInput; - } - if (request.keepFields != null) { - _queryParams["keep_fields"] = request.keepFields; - } - - if (request.optionalFields != null) { - _queryParams["optional_fields"] = request.optionalFields; - } - - if (request.textSeparator != null) { - _queryParams["text_separator"] = request.textSeparator; - } - - if (request.csvDelimiter != null) { - _queryParams["csv_delimiter"] = request.csvDelimiter; - } - + _request.append("eval_data", evalData); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "datasets" + "v1/datasets" ), - queryParameters: _queryParams, method: "POST", headers: { Authorization: await this._getAuthorizationHeader(), @@ -174,7 +137,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "multipart/form-data; boundary=" + _request.getBoundary(), body: _request, @@ -223,7 +186,7 @@ export class Datasets { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "datasets/usage" + "v1/datasets/usage" ), method: "GET", headers: { @@ -234,7 +197,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -276,13 +239,13 @@ export class Datasets { * Retrieve a dataset by ID. See ['Datasets'](https://docs.cohere.com/docs/datasets) for more information. * * @example - * await cohere.datasets.get("id") + * await cohere.datasets.get("string") */ public async get(id: string, requestOptions?: Datasets.RequestOptions): Promise { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - `datasets/${id}` + `v1/datasets/${id}` ), method: "GET", headers: { @@ -293,7 +256,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -335,13 +298,13 @@ export class Datasets { * Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually. * * @example - * await cohere.datasets.delete("id") + * await cohere.datasets.delete("string") */ public async delete(id: string, requestOptions?: Datasets.RequestOptions): Promise> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - `datasets/${id}` + `v1/datasets/${id}` ), method: "DELETE", headers: { @@ -352,7 +315,7 @@ export class Datasets { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, diff --git a/src/api/resources/embedJobs/client/Client.ts b/src/api/resources/embedJobs/client/Client.ts index 41565c1..cfe9fb3 100644 --- a/src/api/resources/embedJobs/client/Client.ts +++ b/src/api/resources/embedJobs/client/Client.ts @@ -37,7 +37,7 @@ export class EmbedJobs { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "embed-jobs" + "v1/embed-jobs" ), method: "GET", headers: { @@ -48,7 +48,7 @@ export class EmbedJobs { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -97,6 +97,14 @@ export class EmbedJobs { * This API launches an async Embed job for a [Dataset](https://docs.cohere.com/docs/datasets) of type `embed-input`. The result of a completed embed job is new Dataset of type `embed-output`, which contains the original text entries and the corresponding embeddings. * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.InternalServerError} + * + * @example + * await cohere.embedJobs.create({ + * model: "string", + * datasetId: "string", + * inputType: Cohere.EmbedInputType.SearchDocument, + * truncate: Cohere.CreateEmbedJobRequestTruncate.Start + * }) */ public async create( request: Cohere.CreateEmbedJobRequest, @@ -105,7 +113,7 @@ export class EmbedJobs { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - "embed-jobs" + "v1/embed-jobs" ), method: "POST", headers: { @@ -116,7 +124,7 @@ export class EmbedJobs { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", body: await serializers.CreateEmbedJobRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -167,12 +175,15 @@ export class EmbedJobs { * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.InternalServerError} + * + * @example + * await cohere.embedJobs.get("string") */ public async get(id: string, requestOptions?: EmbedJobs.RequestOptions): Promise { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - `embed-jobs/${id}` + `v1/embed-jobs/${id}` ), method: "GET", headers: { @@ -183,7 +194,7 @@ export class EmbedJobs { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -237,13 +248,13 @@ export class EmbedJobs { * @throws {@link Cohere.InternalServerError} * * @example - * await cohere.embedJobs.cancel("id") + * await cohere.embedJobs.cancel("string") */ public async cancel(id: string, requestOptions?: EmbedJobs.RequestOptions): Promise { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, - `embed-jobs/${id}/cancel` + `v1/embed-jobs/${id}/cancel` ), method: "POST", headers: { @@ -254,7 +265,7 @@ export class EmbedJobs { : undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.7.3", + "X-Fern-SDK-Version": "7.7.4", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, diff --git a/src/api/resources/embedJobs/client/requests/CreateEmbedJobRequest.ts b/src/api/resources/embedJobs/client/requests/CreateEmbedJobRequest.ts index 634e249..b9b0a1e 100644 --- a/src/api/resources/embedJobs/client/requests/CreateEmbedJobRequest.ts +++ b/src/api/resources/embedJobs/client/requests/CreateEmbedJobRequest.ts @@ -4,6 +4,15 @@ import * as Cohere from "../../../.."; +/** + * @example + * { + * model: "string", + * datasetId: "string", + * inputType: Cohere.EmbedInputType.SearchDocument, + * truncate: Cohere.CreateEmbedJobRequestTruncate.Start + * } + */ export interface CreateEmbedJobRequest { /** * ID of the embedding model. diff --git a/src/api/types/ChatConnector.ts b/src/api/types/ChatConnector.ts index 1643fca..27190c8 100644 --- a/src/api/types/ChatConnector.ts +++ b/src/api/types/ChatConnector.ts @@ -6,7 +6,7 @@ * The connector used for fetching documents. */ export interface ChatConnector { - /** The identifier of the connector. Currently only 'web-search' is supported. */ + /** The identifier of the connector. */ id: string; /** An optional override to set the token that Cohere passes to the connector in the Authorization header. */ userAccessToken?: string; diff --git a/src/api/types/ChatRequestPromptOverride.ts b/src/api/types/ChatRequestPromptOverride.ts new file mode 100644 index 0000000..1f5f9d6 --- /dev/null +++ b/src/api/types/ChatRequestPromptOverride.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * (internal) Overrides specified parts of the default Chat or RAG preamble. It is recommended that these options only be used in specific scenarios where the defaults are not adequate. + */ +export interface ChatRequestPromptOverride { + preamble?: unknown; + taskDescription?: unknown; + styleGuide?: unknown; +} diff --git a/src/api/types/ChatRequestSearchOptions.ts b/src/api/types/ChatRequestSearchOptions.ts new file mode 100644 index 0000000..c771f9b --- /dev/null +++ b/src/api/types/ChatRequestSearchOptions.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * (internal) Sets inference and model options for RAG search query and tool use generations. Defaults are used when options are not specified here, meaning that other parameters outside of search_options are ignored (such as model= or temperature=). + */ +export interface ChatRequestSearchOptions { + model?: unknown; + temperature?: unknown; + maxTokens?: unknown; + preamble?: unknown; +} diff --git a/src/api/types/ChatSearchResult.ts b/src/api/types/ChatSearchResult.ts index 831d10d..dd40c11 100644 --- a/src/api/types/ChatSearchResult.ts +++ b/src/api/types/ChatSearchResult.ts @@ -7,7 +7,7 @@ import * as Cohere from ".."; export interface ChatSearchResult { searchQuery: Cohere.ChatSearchQuery; /** The connector from which this result comes from. */ - connector: Cohere.ChatConnector; + connector: Cohere.ChatSearchResultConnector; /** Identifiers of documents found by this search query. */ documentIds: string[]; } diff --git a/src/api/types/ChatSearchResultConnector.ts b/src/api/types/ChatSearchResultConnector.ts new file mode 100644 index 0000000..53c832e --- /dev/null +++ b/src/api/types/ChatSearchResultConnector.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The connector used for fetching documents. + */ +export interface ChatSearchResultConnector { + /** The identifier of the connector. */ + id: string; +} diff --git a/src/api/types/ChatStreamRequestPromptOverride.ts b/src/api/types/ChatStreamRequestPromptOverride.ts new file mode 100644 index 0000000..2a1288c --- /dev/null +++ b/src/api/types/ChatStreamRequestPromptOverride.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * (internal) Overrides specified parts of the default Chat or RAG preamble. It is recommended that these options only be used in specific scenarios where the defaults are not adequate. + */ +export interface ChatStreamRequestPromptOverride { + preamble?: unknown; + taskDescription?: unknown; + styleGuide?: unknown; +} diff --git a/src/api/types/ChatStreamRequestSearchOptions.ts b/src/api/types/ChatStreamRequestSearchOptions.ts new file mode 100644 index 0000000..db0c954 --- /dev/null +++ b/src/api/types/ChatStreamRequestSearchOptions.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * (internal) Sets inference and model options for RAG search query and tool use generations. Defaults are used when options are not specified here, meaning that other parameters outside of search_options are ignored (such as model= or temperature=). + */ +export interface ChatStreamRequestSearchOptions { + model?: unknown; + temperature?: unknown; + maxTokens?: unknown; + preamble?: unknown; +} diff --git a/src/api/types/DetectLanguageResponse.ts b/src/api/types/DetectLanguageResponse.ts deleted file mode 100644 index 86d1691..0000000 --- a/src/api/types/DetectLanguageResponse.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as Cohere from ".."; - -export interface DetectLanguageResponse { - /** List of languages, one per input text */ - results?: Cohere.DetectLanguageResponseResultsItem[]; - meta?: Cohere.ApiMeta; -} diff --git a/src/api/types/DetectLanguageResponseResultsItem.ts b/src/api/types/DetectLanguageResponseResultsItem.ts deleted file mode 100644 index b69d103..0000000 --- a/src/api/types/DetectLanguageResponseResultsItem.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -export interface DetectLanguageResponseResultsItem { - languageName?: string; - languageCode?: string; -} diff --git a/src/api/types/index.ts b/src/api/types/index.ts index 9d68c64..1e8e74c 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -1,7 +1,11 @@ export * from "./ChatStreamRequestPromptTruncation"; export * from "./ChatStreamRequestCitationQuality"; +export * from "./ChatStreamRequestSearchOptions"; +export * from "./ChatStreamRequestPromptOverride"; export * from "./ChatRequestPromptTruncation"; export * from "./ChatRequestCitationQuality"; +export * from "./ChatRequestSearchOptions"; +export * from "./ChatRequestPromptOverride"; export * from "./GenerateStreamRequestTruncate"; export * from "./GenerateStreamRequestReturnLikelihoods"; export * from "./GenerateRequestTruncate"; @@ -19,8 +23,6 @@ export * from "./ClassifyResponseClassificationsItemLabelsValue"; export * from "./ClassifyResponseClassificationsItemClassificationType"; export * from "./ClassifyResponseClassificationsItem"; export * from "./ClassifyResponse"; -export * from "./DetectLanguageResponseResultsItem"; -export * from "./DetectLanguageResponse"; export * from "./SummarizeRequestLength"; export * from "./SummarizeRequestFormat"; export * from "./SummarizeRequestExtractiveness"; @@ -33,6 +35,7 @@ export * from "./ChatConnector"; export * from "./ChatDocument"; export * from "./ChatCitation"; export * from "./ChatSearchQuery"; +export * from "./ChatSearchResultConnector"; export * from "./ChatSearchResult"; export * from "./NonStreamedChatResponse"; export * from "./ChatStreamEvent"; diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts index e25819a..19de5d4 100644 --- a/src/core/fetcher/Fetcher.ts +++ b/src/core/fetcher/Fetcher.ts @@ -2,10 +2,6 @@ import { default as FormData } from "form-data"; import qs from "qs"; import { APIResponse } from "./APIResponse"; -if (typeof window === "undefined") { - global.fetch = require("node-fetch"); -} - export type FetchFunction = (args: Fetcher.Args) => Promise>; export declare namespace Fetcher { @@ -77,18 +73,20 @@ async function fetcherImpl(args: Fetcher.Args): Promise => { const controller = new AbortController(); let abortId = undefined; if (args.timeoutMs != null) { abortId = setTimeout(() => controller.abort(), args.timeoutMs); } - const response = await fetch(url, { + const response = await fetchFn(url, { method: args.method, headers, body, signal: controller.signal, - credentials: args.withCredentials ? "same-origin" : undefined, + credentials: args.withCredentials ? "include" : undefined, }); if (abortId != null) { clearTimeout(abortId); @@ -119,18 +117,21 @@ async function fetcherImpl(args: Fetcher.Args): Promise 0) { + try { + body = JSON.parse(text); + } catch (err) { + return { + ok: false, + error: { + reason: "non-json", + statusCode: response.status, + rawBody: text, + }, + }; + } } } diff --git a/src/environments.ts b/src/environments.ts index e4b16e4..081ded8 100644 --- a/src/environments.ts +++ b/src/environments.ts @@ -3,7 +3,7 @@ */ export const CohereEnvironment = { - Production: "https://api.cohere.ai/v1", + Production: "https://api.cohere.ai", } as const; export type CohereEnvironment = typeof CohereEnvironment.Production; diff --git a/src/serialization/client/requests/ChatRequest.ts b/src/serialization/client/requests/ChatRequest.ts index e885eac..572e8c0 100644 --- a/src/serialization/client/requests/ChatRequest.ts +++ b/src/serialization/client/requests/ChatRequest.ts @@ -34,6 +34,8 @@ export const ChatRequest: core.serialization.Schema (await import("../..")).ChatRequestCitationQuality).optional() ), temperature: core.serialization.number().optional(), + frequencyPenalty: core.serialization.property("frequency_penalty", core.serialization.number().optional()), + presencePenalty: core.serialization.property("presence_penalty", core.serialization.number().optional()), }); export declare namespace ChatRequest { @@ -49,5 +51,7 @@ export declare namespace ChatRequest { documents?: serializers.ChatDocument.Raw[] | null; citation_quality?: serializers.ChatRequestCitationQuality.Raw | null; temperature?: number | null; + frequency_penalty?: number | null; + presence_penalty?: number | null; } } diff --git a/src/serialization/client/requests/ChatStreamRequest.ts b/src/serialization/client/requests/ChatStreamRequest.ts index 4c72310..b271cff 100644 --- a/src/serialization/client/requests/ChatStreamRequest.ts +++ b/src/serialization/client/requests/ChatStreamRequest.ts @@ -34,6 +34,8 @@ export const ChatStreamRequest: core.serialization.Schema (await import("../..")).ChatStreamRequestCitationQuality).optional() ), temperature: core.serialization.number().optional(), + frequencyPenalty: core.serialization.property("frequency_penalty", core.serialization.number().optional()), + presencePenalty: core.serialization.property("presence_penalty", core.serialization.number().optional()), }); export declare namespace ChatStreamRequest { @@ -49,5 +51,7 @@ export declare namespace ChatStreamRequest { documents?: serializers.ChatDocument.Raw[] | null; citation_quality?: serializers.ChatStreamRequestCitationQuality.Raw | null; temperature?: number | null; + frequency_penalty?: number | null; + presence_penalty?: number | null; } } diff --git a/src/serialization/client/requests/DetectLanguageRequest.ts b/src/serialization/client/requests/DetectLanguageRequest.ts deleted file mode 100644 index 0d7dd13..0000000 --- a/src/serialization/client/requests/DetectLanguageRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../.."; -import * as Cohere from "../../../api"; -import * as core from "../../../core"; - -export const DetectLanguageRequest: core.serialization.Schema< - serializers.DetectLanguageRequest.Raw, - Cohere.DetectLanguageRequest -> = core.serialization.object({ - texts: core.serialization.list(core.serialization.string()), - model: core.serialization.string().optional(), -}); - -export declare namespace DetectLanguageRequest { - interface Raw { - texts: string[]; - model?: string | null; - } -} diff --git a/src/serialization/client/requests/GenerateRequest.ts b/src/serialization/client/requests/GenerateRequest.ts index 620669b..8953736 100644 --- a/src/serialization/client/requests/GenerateRequest.ts +++ b/src/serialization/client/requests/GenerateRequest.ts @@ -35,6 +35,7 @@ export const GenerateRequest: core.serialization.Schema | null; + raw_prompting?: boolean | null; } } diff --git a/src/serialization/client/requests/GenerateStreamRequest.ts b/src/serialization/client/requests/GenerateStreamRequest.ts index 746999e..6b8f5d2 100644 --- a/src/serialization/client/requests/GenerateStreamRequest.ts +++ b/src/serialization/client/requests/GenerateStreamRequest.ts @@ -37,6 +37,7 @@ export const GenerateStreamRequest: core.serialization.Schema< "logit_bias", core.serialization.record(core.serialization.string(), core.serialization.number()).optional() ), + rawPrompting: core.serialization.property("raw_prompting", core.serialization.boolean().optional()), }); export declare namespace GenerateStreamRequest { @@ -56,5 +57,6 @@ export declare namespace GenerateStreamRequest { presence_penalty?: number | null; return_likelihoods?: serializers.GenerateStreamRequestReturnLikelihoods.Raw | null; logit_bias?: Record | null; + raw_prompting?: boolean | null; } } diff --git a/src/serialization/client/requests/index.ts b/src/serialization/client/requests/index.ts index 72d990c..20584c9 100644 --- a/src/serialization/client/requests/index.ts +++ b/src/serialization/client/requests/index.ts @@ -5,7 +5,6 @@ export { GenerateRequest } from "./GenerateRequest"; export { EmbedRequest } from "./EmbedRequest"; export { RerankRequest } from "./RerankRequest"; export { ClassifyRequest } from "./ClassifyRequest"; -export { DetectLanguageRequest } from "./DetectLanguageRequest"; export { SummarizeRequest } from "./SummarizeRequest"; export { TokenizeRequest } from "./TokenizeRequest"; export { DetokenizeRequest } from "./DetokenizeRequest"; diff --git a/src/serialization/types/ChatRequestPromptOverride.ts b/src/serialization/types/ChatRequestPromptOverride.ts new file mode 100644 index 0000000..add9a90 --- /dev/null +++ b/src/serialization/types/ChatRequestPromptOverride.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const ChatRequestPromptOverride: core.serialization.ObjectSchema< + serializers.ChatRequestPromptOverride.Raw, + Cohere.ChatRequestPromptOverride +> = core.serialization.object({ + preamble: core.serialization.unknown().optional(), + taskDescription: core.serialization.property("task_description", core.serialization.unknown().optional()), + styleGuide: core.serialization.property("style_guide", core.serialization.unknown().optional()), +}); + +export declare namespace ChatRequestPromptOverride { + interface Raw { + preamble?: unknown | null; + task_description?: unknown | null; + style_guide?: unknown | null; + } +} diff --git a/src/serialization/types/ChatRequestSearchOptions.ts b/src/serialization/types/ChatRequestSearchOptions.ts new file mode 100644 index 0000000..b6951bc --- /dev/null +++ b/src/serialization/types/ChatRequestSearchOptions.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const ChatRequestSearchOptions: core.serialization.ObjectSchema< + serializers.ChatRequestSearchOptions.Raw, + Cohere.ChatRequestSearchOptions +> = core.serialization.object({ + model: core.serialization.unknown().optional(), + temperature: core.serialization.unknown().optional(), + maxTokens: core.serialization.property("max_tokens", core.serialization.unknown().optional()), + preamble: core.serialization.unknown().optional(), +}); + +export declare namespace ChatRequestSearchOptions { + interface Raw { + model?: unknown | null; + temperature?: unknown | null; + max_tokens?: unknown | null; + preamble?: unknown | null; + } +} diff --git a/src/serialization/types/ChatSearchResult.ts b/src/serialization/types/ChatSearchResult.ts index 478dbc7..b872c9f 100644 --- a/src/serialization/types/ChatSearchResult.ts +++ b/src/serialization/types/ChatSearchResult.ts @@ -14,14 +14,14 @@ export const ChatSearchResult: core.serialization.ObjectSchema< "search_query", core.serialization.lazyObject(async () => (await import("..")).ChatSearchQuery) ), - connector: core.serialization.lazyObject(async () => (await import("..")).ChatConnector), + connector: core.serialization.lazyObject(async () => (await import("..")).ChatSearchResultConnector), documentIds: core.serialization.property("document_ids", core.serialization.list(core.serialization.string())), }); export declare namespace ChatSearchResult { interface Raw { search_query: serializers.ChatSearchQuery.Raw; - connector: serializers.ChatConnector.Raw; + connector: serializers.ChatSearchResultConnector.Raw; document_ids: string[]; } } diff --git a/src/serialization/types/ChatSearchResultConnector.ts b/src/serialization/types/ChatSearchResultConnector.ts new file mode 100644 index 0000000..577ef10 --- /dev/null +++ b/src/serialization/types/ChatSearchResultConnector.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const ChatSearchResultConnector: core.serialization.ObjectSchema< + serializers.ChatSearchResultConnector.Raw, + Cohere.ChatSearchResultConnector +> = core.serialization.object({ + id: core.serialization.string(), +}); + +export declare namespace ChatSearchResultConnector { + interface Raw { + id: string; + } +} diff --git a/src/serialization/types/ChatStreamRequestPromptOverride.ts b/src/serialization/types/ChatStreamRequestPromptOverride.ts new file mode 100644 index 0000000..a44aa2d --- /dev/null +++ b/src/serialization/types/ChatStreamRequestPromptOverride.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const ChatStreamRequestPromptOverride: core.serialization.ObjectSchema< + serializers.ChatStreamRequestPromptOverride.Raw, + Cohere.ChatStreamRequestPromptOverride +> = core.serialization.object({ + preamble: core.serialization.unknown().optional(), + taskDescription: core.serialization.property("task_description", core.serialization.unknown().optional()), + styleGuide: core.serialization.property("style_guide", core.serialization.unknown().optional()), +}); + +export declare namespace ChatStreamRequestPromptOverride { + interface Raw { + preamble?: unknown | null; + task_description?: unknown | null; + style_guide?: unknown | null; + } +} diff --git a/src/serialization/types/ChatStreamRequestSearchOptions.ts b/src/serialization/types/ChatStreamRequestSearchOptions.ts new file mode 100644 index 0000000..1f0e060 --- /dev/null +++ b/src/serialization/types/ChatStreamRequestSearchOptions.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const ChatStreamRequestSearchOptions: core.serialization.ObjectSchema< + serializers.ChatStreamRequestSearchOptions.Raw, + Cohere.ChatStreamRequestSearchOptions +> = core.serialization.object({ + model: core.serialization.unknown().optional(), + temperature: core.serialization.unknown().optional(), + maxTokens: core.serialization.property("max_tokens", core.serialization.unknown().optional()), + preamble: core.serialization.unknown().optional(), +}); + +export declare namespace ChatStreamRequestSearchOptions { + interface Raw { + model?: unknown | null; + temperature?: unknown | null; + max_tokens?: unknown | null; + preamble?: unknown | null; + } +} diff --git a/src/serialization/types/DetectLanguageResponse.ts b/src/serialization/types/DetectLanguageResponse.ts deleted file mode 100644 index 15e09d4..0000000 --- a/src/serialization/types/DetectLanguageResponse.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from ".."; -import * as Cohere from "../../api"; -import * as core from "../../core"; - -export const DetectLanguageResponse: core.serialization.ObjectSchema< - serializers.DetectLanguageResponse.Raw, - Cohere.DetectLanguageResponse -> = core.serialization.object({ - results: core.serialization - .list(core.serialization.lazyObject(async () => (await import("..")).DetectLanguageResponseResultsItem)) - .optional(), - meta: core.serialization.lazyObject(async () => (await import("..")).ApiMeta).optional(), -}); - -export declare namespace DetectLanguageResponse { - interface Raw { - results?: serializers.DetectLanguageResponseResultsItem.Raw[] | null; - meta?: serializers.ApiMeta.Raw | null; - } -} diff --git a/src/serialization/types/DetectLanguageResponseResultsItem.ts b/src/serialization/types/DetectLanguageResponseResultsItem.ts deleted file mode 100644 index 61653bc..0000000 --- a/src/serialization/types/DetectLanguageResponseResultsItem.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from ".."; -import * as Cohere from "../../api"; -import * as core from "../../core"; - -export const DetectLanguageResponseResultsItem: core.serialization.ObjectSchema< - serializers.DetectLanguageResponseResultsItem.Raw, - Cohere.DetectLanguageResponseResultsItem -> = core.serialization.object({ - languageName: core.serialization.property("language_name", core.serialization.string().optional()), - languageCode: core.serialization.property("language_code", core.serialization.string().optional()), -}); - -export declare namespace DetectLanguageResponseResultsItem { - interface Raw { - language_name?: string | null; - language_code?: string | null; - } -} diff --git a/src/serialization/types/index.ts b/src/serialization/types/index.ts index 9d68c64..1e8e74c 100644 --- a/src/serialization/types/index.ts +++ b/src/serialization/types/index.ts @@ -1,7 +1,11 @@ export * from "./ChatStreamRequestPromptTruncation"; export * from "./ChatStreamRequestCitationQuality"; +export * from "./ChatStreamRequestSearchOptions"; +export * from "./ChatStreamRequestPromptOverride"; export * from "./ChatRequestPromptTruncation"; export * from "./ChatRequestCitationQuality"; +export * from "./ChatRequestSearchOptions"; +export * from "./ChatRequestPromptOverride"; export * from "./GenerateStreamRequestTruncate"; export * from "./GenerateStreamRequestReturnLikelihoods"; export * from "./GenerateRequestTruncate"; @@ -19,8 +23,6 @@ export * from "./ClassifyResponseClassificationsItemLabelsValue"; export * from "./ClassifyResponseClassificationsItemClassificationType"; export * from "./ClassifyResponseClassificationsItem"; export * from "./ClassifyResponse"; -export * from "./DetectLanguageResponseResultsItem"; -export * from "./DetectLanguageResponse"; export * from "./SummarizeRequestLength"; export * from "./SummarizeRequestFormat"; export * from "./SummarizeRequestExtractiveness"; @@ -33,6 +35,7 @@ export * from "./ChatConnector"; export * from "./ChatDocument"; export * from "./ChatCitation"; export * from "./ChatSearchQuery"; +export * from "./ChatSearchResultConnector"; export * from "./ChatSearchResult"; export * from "./NonStreamedChatResponse"; export * from "./ChatStreamEvent"; diff --git a/yarn.lock b/yarn.lock index 7b8409b..1f7b12b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11,9 +11,9 @@ form-data "^4.0.0" "@types/node@*": - version "20.11.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.5.tgz#be10c622ca7fcaa3cf226cf80166abc31389d86e" - integrity sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w== + version "20.11.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.10.tgz#6c3de8974d65c362f82ee29db6b5adf4205462f9" + integrity sha512-rZEfe/hJSGYmdfX9tvcPMYeYPW2sNl50nsw4jZmRcaG0HIAb0WYEpsB05GOb53vjqpyE9GUhlDQ4jLSoB5q9kg== dependencies: undici-types "~5.26.4" From 93f95ce8bee5c98b41591ecc6b9fe664a8975abd Mon Sep 17 00:00:00 2001 From: billytrend-cohere <144115527+billytrend-cohere@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:39:16 +0000 Subject: [PATCH 2/3] Make evalData optional --- src/api/resources/datasets/client/Client.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/resources/datasets/client/Client.ts b/src/api/resources/datasets/client/Client.ts index c7da8df..ecad049 100644 --- a/src/api/resources/datasets/client/Client.ts +++ b/src/api/resources/datasets/client/Client.ts @@ -117,12 +117,14 @@ export class Datasets { */ public async create( data: File | fs.ReadStream, - evalData: File | fs.ReadStream, + evalData?: File | fs.ReadStream, requestOptions?: Datasets.RequestOptions ): Promise { const _request = new FormData(); _request.append("data", data); - _request.append("eval_data", evalData); + if (evalData) { + _request.append("eval_data", evalData); + } const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, From e227fcaa70d937b31323394fd613ce750dcf45e5 Mon Sep 17 00:00:00 2001 From: billytrend-cohere <144115527+billytrend-cohere@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:20:01 +0000 Subject: [PATCH 3/3] Add _queryParams --- src/api/resources/datasets/client/Client.ts | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/api/resources/datasets/client/Client.ts b/src/api/resources/datasets/client/Client.ts index ecad049..8743bb6 100644 --- a/src/api/resources/datasets/client/Client.ts +++ b/src/api/resources/datasets/client/Client.ts @@ -116,6 +116,7 @@ export class Datasets { * Create a dataset by uploading a file. See ['Dataset Creation'](https://docs.cohere.com/docs/datasets#dataset-creation) for more information. */ public async create( + request: Cohere.DatasetsCreateRequest, data: File | fs.ReadStream, evalData?: File | fs.ReadStream, requestOptions?: Datasets.RequestOptions @@ -125,11 +126,45 @@ export class Datasets { if (evalData) { _request.append("eval_data", evalData); } + + const _queryParams: any = {} + + if (request.name != null) { + _queryParams["name"] = request.name; + } + + if (request.type != null) { + _queryParams["type"] = request.type; + } + + if (request.keepOriginalFile != null) { + _queryParams["keep_original_file"] = request.keepOriginalFile; + } + if (request.skipMalformedInput != null) { + _queryParams["skip_malformed_input"] = request.skipMalformedInput; + } + if (request.keepFields != null) { + _queryParams["keep_fields"] = request.keepFields; + } + + if (request.optionalFields != null) { + _queryParams["optional_fields"] = request.optionalFields; + } + + if (request.textSeparator != null) { + _queryParams["text_separator"] = request.textSeparator; + } + + if (request.csvDelimiter != null) { + _queryParams["csv_delimiter"] = request.csvDelimiter; + } + const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, "v1/datasets" ), + queryParameters: _queryParams, method: "POST", headers: { Authorization: await this._getAuthorizationHeader(),