commonMain.com.xebia.functional.openai.generated.api.FineTuning.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xef-openai-client Show documentation
Show all versions of xef-openai-client Show documentation
Building applications with LLMs through composability in Kotlin
The newest version!
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)
package com.xebia.functional.openai.generated.api
import com.xebia.functional.openai.generated.model.CreateFineTuningJobRequest
import com.xebia.functional.openai.generated.model.FineTuningJob
import com.xebia.functional.openai.generated.model.ListFineTuningJobCheckpointsResponse
import com.xebia.functional.openai.generated.model.ListFineTuningJobEventsResponse
import com.xebia.functional.openai.generated.model.ListPaginatedFineTuningJobsResponse
import com.xebia.functional.openai.Config
import com.xebia.functional.openai.UploadFile
import com.xebia.functional.openai.appendGen
import com.xebia.functional.openai.generated.api.FineTuning.*
import com.xebia.functional.openai.streamEvents
import com.xebia.functional.openai.errors.serializeOrThrowWithResponseInfo
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.plugins.timeout
import io.ktor.client.request.HttpRequestBuilder
import io.ktor.client.request.accept
import io.ktor.client.request.header
import io.ktor.client.request.forms.formData
import io.ktor.client.request.parameter
import io.ktor.client.request.prepareRequest
import io.ktor.client.request.request
import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.HttpStatement
import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpMethod
import io.ktor.http.contentType
import io.ktor.http.path
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlin.time.Duration.Companion.seconds
import kotlin.time.DurationUnit
/**
*
*/
interface FineTuning {
/**
* Immediately cancel a fine-tune job.
*
* @param fineTuningJobId The ID of the fine-tuning job to cancel.
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return FineTuningJob
*/
suspend fun cancelFineTuningJob(fineTuningJobId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): FineTuningJob
/**
* Creates a fine-tuning job which begins the process of creating a new model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about fine-tuning](/docs/guides/fine-tuning)
*
* @param createFineTuningJobRequest
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return FineTuningJob
*/
suspend fun createFineTuningJob(createFineTuningJobRequest: CreateFineTuningJobRequest, configure: HttpRequestBuilder.() -> Unit = {}): FineTuningJob
/**
* Get status updates for a fine-tuning job.
*
* @param fineTuningJobId The ID of the fine-tuning job to get events for.
* @param after Identifier for the last event from the previous pagination request. (optional)
* @param limit Number of events to retrieve. (optional, default to 20)
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return ListFineTuningJobEventsResponse
*/
suspend fun listFineTuningEvents(fineTuningJobId: kotlin.String, after: kotlin.String? = null, limit: kotlin.Int? = 20, configure: HttpRequestBuilder.() -> Unit = {}): ListFineTuningJobEventsResponse
/**
* List checkpoints for a fine-tuning job.
*
* @param fineTuningJobId The ID of the fine-tuning job to get checkpoints for.
* @param after Identifier for the last checkpoint ID from the previous pagination request. (optional)
* @param limit Number of checkpoints to retrieve. (optional, default to 10)
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return ListFineTuningJobCheckpointsResponse
*/
suspend fun listFineTuningJobCheckpoints(fineTuningJobId: kotlin.String, after: kotlin.String? = null, limit: kotlin.Int? = 10, configure: HttpRequestBuilder.() -> Unit = {}): ListFineTuningJobCheckpointsResponse
/**
* List your organization's fine-tuning jobs
*
* @param after Identifier for the last job from the previous pagination request. (optional)
* @param limit Number of fine-tuning jobs to retrieve. (optional, default to 20)
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return ListPaginatedFineTuningJobsResponse
*/
suspend fun listPaginatedFineTuningJobs(after: kotlin.String? = null, limit: kotlin.Int? = 20, configure: HttpRequestBuilder.() -> Unit = {}): ListPaginatedFineTuningJobsResponse
/**
* Get info about a fine-tuning job. [Learn more about fine-tuning](/docs/guides/fine-tuning)
*
* @param fineTuningJobId The ID of the fine-tuning job.
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return FineTuningJob
*/
suspend fun retrieveFineTuningJob(fineTuningJobId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): FineTuningJob
}
fun FineTuning(client: HttpClient, config: Config): com.xebia.functional.openai.generated.api.FineTuning = object : com.xebia.functional.openai.generated.api.FineTuning {
override suspend fun cancelFineTuningJob(fineTuningJobId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): FineTuningJob =
client.request {
configure()
method = HttpMethod.Post
contentType(ContentType.Application.Json)
url { path("fine_tuning/jobs/{fine_tuning_job_id}/cancel".replace("{" + "fine_tuning_job_id" + "}", "$fineTuningJobId")) }
setBody(
io.ktor.client.utils.EmptyContent
)
}.serializeOrThrowWithResponseInfo()
override suspend fun createFineTuningJob(createFineTuningJobRequest: CreateFineTuningJobRequest, configure: HttpRequestBuilder.() -> Unit): FineTuningJob =
client.request {
configure()
method = HttpMethod.Post
contentType(ContentType.Application.Json)
url { path("fine_tuning/jobs") }
setBody(createFineTuningJobRequest
)
}.serializeOrThrowWithResponseInfo()
override suspend fun listFineTuningEvents(fineTuningJobId: kotlin.String,after: kotlin.String?,limit: kotlin.Int?, configure: HttpRequestBuilder.() -> Unit): ListFineTuningJobEventsResponse =
client.request {
configure()
method = HttpMethod.Get
contentType(ContentType.Application.Json)
parameter("after", after)
parameter("limit", limit)
url { path("fine_tuning/jobs/{fine_tuning_job_id}/events".replace("{" + "fine_tuning_job_id" + "}", "$fineTuningJobId")) }
setBody(
io.ktor.client.utils.EmptyContent
)
}.serializeOrThrowWithResponseInfo()
override suspend fun listFineTuningJobCheckpoints(fineTuningJobId: kotlin.String,after: kotlin.String?,limit: kotlin.Int?, configure: HttpRequestBuilder.() -> Unit): ListFineTuningJobCheckpointsResponse =
client.request {
configure()
method = HttpMethod.Get
contentType(ContentType.Application.Json)
parameter("after", after)
parameter("limit", limit)
url { path("fine_tuning/jobs/{fine_tuning_job_id}/checkpoints".replace("{" + "fine_tuning_job_id" + "}", "$fineTuningJobId")) }
setBody(
io.ktor.client.utils.EmptyContent
)
}.serializeOrThrowWithResponseInfo()
override suspend fun listPaginatedFineTuningJobs(after: kotlin.String?,limit: kotlin.Int?, configure: HttpRequestBuilder.() -> Unit): ListPaginatedFineTuningJobsResponse =
client.request {
configure()
method = HttpMethod.Get
contentType(ContentType.Application.Json)
parameter("after", after)
parameter("limit", limit)
url { path("fine_tuning/jobs") }
setBody(
io.ktor.client.utils.EmptyContent
)
}.serializeOrThrowWithResponseInfo()
override suspend fun retrieveFineTuningJob(fineTuningJobId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): FineTuningJob =
client.request {
configure()
method = HttpMethod.Get
contentType(ContentType.Application.Json)
url { path("fine_tuning/jobs/{fine_tuning_job_id}".replace("{" + "fine_tuning_job_id" + "}", "$fineTuningJobId")) }
setBody(
io.ktor.client.utils.EmptyContent
)
}.serializeOrThrowWithResponseInfo()
}