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

commonTest.com.aallam.openai.client.TestOpenAI.kt Maven / Gradle / Ivy

There is a newer version: 4.0.0-beta01
Show newest version
package com.aallam.openai.client

import com.aallam.openai.api.http.Timeout
import com.aallam.openai.api.logging.LogLevel
import com.aallam.openai.client.internal.OpenAIApi
import com.aallam.openai.client.internal.createHttpClient
import com.aallam.openai.client.internal.env
import com.aallam.openai.client.internal.http.HttpTransport
import okio.fakefilesystem.FakeFileSystem
import kotlin.time.Duration.Companion.minutes

internal val token: String
    get() = requireNotNull(env("OPENAI_API_KEY")) { "OPENAI_API_KEY environment variable must be set." }

internal val transport = HttpTransport(
    createHttpClient(
        OpenAIConfig(
            token = token,
            logLevel = LogLevel.All,
            timeout = Timeout(socket = 1.minutes),
        )
    )
)

abstract class TestOpenAI {

    internal val fileSystem = FakeFileSystem()
    internal val openAI = OpenAIApi(transport, fileSystem)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy