All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.xebia.functional.openai.generated.api.Models.kt Maven / Gradle / Ivy

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.DeleteModelResponse
import com.xebia.functional.openai.generated.model.ListModelsResponse
import com.xebia.functional.openai.generated.model.Model
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.Models.*
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 Models {

    /**
    * Delete a fine-tuned model. You must have the Owner role in your organization to delete a model.
    * 
     * @param model The model to delete
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return DeleteModelResponse
    */
    suspend fun deleteModel(model: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): DeleteModelResponse


    /**
    * Lists the currently available models, and provides basic information about each one such as the owner and availability.
    * 
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ListModelsResponse
    */
    suspend fun listModels(configure: HttpRequestBuilder.() -> Unit = {}): ListModelsResponse


    /**
    * Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
    * 
     * @param model The ID of the model to use for this request
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return Model
    */
    suspend fun retrieveModel(model: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): Model

}

fun Models(client: HttpClient, config: Config): com.xebia.functional.openai.generated.api.Models = object : com.xebia.functional.openai.generated.api.Models {
    override suspend fun deleteModel(model: kotlin.String, configure: HttpRequestBuilder.() -> Unit): DeleteModelResponse =
      client.request {
        configure()
        method = HttpMethod.Delete
        contentType(ContentType.Application.Json)
        url { path("models/{model}".replace("{" + "model" + "}", "$model")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun listModels( configure: HttpRequestBuilder.() -> Unit): ListModelsResponse =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
        url { path("models") }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun retrieveModel(model: kotlin.String, configure: HttpRequestBuilder.() -> Unit): Model =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
        url { path("models/{model}".replace("{" + "model" + "}", "$model")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy