Skip to content

Commit

Permalink
Add _queryParams
Browse files Browse the repository at this point in the history
  • Loading branch information
billytrend-cohere committed Jan 18, 2024
1 parent 0929826 commit d5e7d55
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/api/resources/datasets/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -125,11 +126,45 @@ export class Datasets {
if (evalData) {
_request.append("eval_data", evalData);
}

const _queryParams: any = {}

if (request.name != null) {
_queryParams["name"] = request.name;
}

if (request.type != null) {
_queryParams["type"] = request.type;
}

if (request.keepOriginalFile != null) {
_queryParams["keep_original_file"] = request.keepOriginalFile;
}
if (request.skipMalformedInput != null) {
_queryParams["skip_malformed_input"] = request.skipMalformedInput;
}
if (request.keepFields != null) {
_queryParams["keep_fields"] = request.keepFields;
}

if (request.optionalFields != null) {
_queryParams["optional_fields"] = request.optionalFields;
}

if (request.textSeparator != null) {
_queryParams["text_separator"] = request.textSeparator;
}

if (request.csvDelimiter != null) {
_queryParams["csv_delimiter"] = request.csvDelimiter;
}

const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production,
"datasets"
),
queryParameters: _queryParams,
method: "POST",
headers: {
Authorization: await this._getAuthorizationHeader(),
Expand Down

0 comments on commit d5e7d55

Please sign in to comment.