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

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

There is a newer version: 0.0.5-alpha.119
Show 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.CreateEmbeddingRequest
import com.xebia.functional.openai.generated.model.CreateEmbeddingResponse
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.Embeddings.*
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 Embeddings {

    /**
    * Creates an embedding vector representing the input text.
    * 
     * @param createEmbeddingRequest 
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return CreateEmbeddingResponse
    */
    suspend fun createEmbedding(createEmbeddingRequest: CreateEmbeddingRequest, configure: HttpRequestBuilder.() -> Unit = {}): CreateEmbeddingResponse

}

fun Embeddings(client: HttpClient, config: Config): com.xebia.functional.openai.generated.api.Embeddings = object : com.xebia.functional.openai.generated.api.Embeddings {
    override suspend fun createEmbedding(createEmbeddingRequest: CreateEmbeddingRequest, configure: HttpRequestBuilder.() -> Unit): CreateEmbeddingResponse =
      client.request {
        configure()
        method = HttpMethod.Post
        contentType(ContentType.Application.Json)
        url { path("embeddings") }
        setBody(createEmbeddingRequest
)
      }.serializeOrThrowWithResponseInfo()

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy