/* tslint:disable */
/* eslint-disable */
/**
 * Montelo
 * Documentation for the Montelo API.
 *
 * The version of the OpenAPI document: 1.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  CreateFineTuneInput,
  FineTuneCohereInput,
  FineTuneDto,
  FineTuneOpenaiInput,
  FineTuneWithDatasetDto,
} from '../models/index';
import {
    CreateFineTuneInputFromJSON,
    CreateFineTuneInputToJSON,
    FineTuneCohereInputFromJSON,
    FineTuneCohereInputToJSON,
    FineTuneDtoFromJSON,
    FineTuneDtoToJSON,
    FineTuneOpenaiInputFromJSON,
    FineTuneOpenaiInputToJSON,
    FineTuneWithDatasetDtoFromJSON,
    FineTuneWithDatasetDtoToJSON,
} from '../models/index';

export interface FinetuneControllerCreateCohereFineTuneRequest {
    datasetId: string;
    fineTuneCohereInput: FineTuneCohereInput;
}

export interface FinetuneControllerCreateFineTuneRequest {
    datasetId: string;
    createFineTuneInput: CreateFineTuneInput;
}

export interface FinetuneControllerCreateOpenAIFineTuneRequest {
    datasetId: string;
    fineTuneOpenaiInput: FineTuneOpenaiInput;
}

export interface FinetuneControllerGetFineTunesForEnvRequest {
    envId: string;
}

/**
 * 
 */
export class FineTuningApi extends runtime.BaseAPI {

    /**
     */
    async finetuneControllerCreateCohereFineTuneRaw(requestParameters: FinetuneControllerCreateCohereFineTuneRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<FineTuneDto>> {
        if (requestParameters.datasetId === null || requestParameters.datasetId === undefined) {
            throw new runtime.RequiredError('datasetId','Required parameter requestParameters.datasetId was null or undefined when calling finetuneControllerCreateCohereFineTune.');
        }

        if (requestParameters.fineTuneCohereInput === null || requestParameters.fineTuneCohereInput === undefined) {
            throw new runtime.RequiredError('fineTuneCohereInput','Required parameter requestParameters.fineTuneCohereInput was null or undefined when calling finetuneControllerCreateCohereFineTune.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/dataset/{datasetId}/fine-tune/cohere`.replace(`{${"datasetId"}}`, encodeURIComponent(String(requestParameters.datasetId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: FineTuneCohereInputToJSON(requestParameters.fineTuneCohereInput),
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => FineTuneDtoFromJSON(jsonValue));
    }

    /**
     */
    async finetuneControllerCreateCohereFineTune(requestParameters: FinetuneControllerCreateCohereFineTuneRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FineTuneDto> {
        const response = await this.finetuneControllerCreateCohereFineTuneRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async finetuneControllerCreateFineTuneRaw(requestParameters: FinetuneControllerCreateFineTuneRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<FineTuneDto>> {
        if (requestParameters.datasetId === null || requestParameters.datasetId === undefined) {
            throw new runtime.RequiredError('datasetId','Required parameter requestParameters.datasetId was null or undefined when calling finetuneControllerCreateFineTune.');
        }

        if (requestParameters.createFineTuneInput === null || requestParameters.createFineTuneInput === undefined) {
            throw new runtime.RequiredError('createFineTuneInput','Required parameter requestParameters.createFineTuneInput was null or undefined when calling finetuneControllerCreateFineTune.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/dataset/{datasetId}/fine-tune`.replace(`{${"datasetId"}}`, encodeURIComponent(String(requestParameters.datasetId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: CreateFineTuneInputToJSON(requestParameters.createFineTuneInput),
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => FineTuneDtoFromJSON(jsonValue));
    }

    /**
     */
    async finetuneControllerCreateFineTune(requestParameters: FinetuneControllerCreateFineTuneRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FineTuneDto> {
        const response = await this.finetuneControllerCreateFineTuneRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async finetuneControllerCreateOpenAIFineTuneRaw(requestParameters: FinetuneControllerCreateOpenAIFineTuneRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<FineTuneDto>> {
        if (requestParameters.datasetId === null || requestParameters.datasetId === undefined) {
            throw new runtime.RequiredError('datasetId','Required parameter requestParameters.datasetId was null or undefined when calling finetuneControllerCreateOpenAIFineTune.');
        }

        if (requestParameters.fineTuneOpenaiInput === null || requestParameters.fineTuneOpenaiInput === undefined) {
            throw new runtime.RequiredError('fineTuneOpenaiInput','Required parameter requestParameters.fineTuneOpenaiInput was null or undefined when calling finetuneControllerCreateOpenAIFineTune.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/dataset/{datasetId}/fine-tune/openai`.replace(`{${"datasetId"}}`, encodeURIComponent(String(requestParameters.datasetId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: FineTuneOpenaiInputToJSON(requestParameters.fineTuneOpenaiInput),
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => FineTuneDtoFromJSON(jsonValue));
    }

    /**
     */
    async finetuneControllerCreateOpenAIFineTune(requestParameters: FinetuneControllerCreateOpenAIFineTuneRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FineTuneDto> {
        const response = await this.finetuneControllerCreateOpenAIFineTuneRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async finetuneControllerGetFineTunesForEnvRaw(requestParameters: FinetuneControllerGetFineTunesForEnvRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<FineTuneWithDatasetDto>>> {
        if (requestParameters.envId === null || requestParameters.envId === undefined) {
            throw new runtime.RequiredError('envId','Required parameter requestParameters.envId was null or undefined when calling finetuneControllerGetFineTunesForEnv.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/env/{envId}/fine-tune`.replace(`{${"envId"}}`, encodeURIComponent(String(requestParameters.envId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(FineTuneWithDatasetDtoFromJSON));
    }

    /**
     */
    async finetuneControllerGetFineTunesForEnv(requestParameters: FinetuneControllerGetFineTunesForEnvRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<FineTuneWithDatasetDto>> {
        const response = await this.finetuneControllerGetFineTunesForEnvRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
