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

commonMain.com.xebia.functional.openai.generated.api.Moderations.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.CreateModerationRequest
import com.xebia.functional.openai.generated.model.CreateModerationResponse
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.Moderations.*
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 Moderations {

    /**
    * Classifies if text is potentially harmful.
    * 
     * @param createModerationRequest 
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return CreateModerationResponse
    */
    suspend fun createModeration(createModerationRequest: CreateModerationRequest, configure: HttpRequestBuilder.() -> Unit = {}): CreateModerationResponse

}

fun Moderations(client: HttpClient, config: Config): com.xebia.functional.openai.generated.api.Moderations = object : com.xebia.functional.openai.generated.api.Moderations {
    override suspend fun createModeration(createModerationRequest: CreateModerationRequest, configure: HttpRequestBuilder.() -> Unit): CreateModerationResponse =
      client.request {
        configure()
        method = HttpMethod.Post
        contentType(ContentType.Application.Json)
        url { path("moderations") }
        setBody(createModerationRequest
)
      }.serializeOrThrowWithResponseInfo()

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy