aallam / openai-kotlin

OpenAI API client for Kotlin with multiplatform and coroutines capabilities.
MIT License
1.49k stars 179 forks source link

Ktor 3.0.0 future migration, can't instantiate OpenAI client #384

Closed Komdosh closed 1 month ago

Komdosh commented 2 months ago

Description

Can't instantiate OpenAI client with ktor 3.0.0-rc-1.

Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/client/plugins/contentnegotiation/ContentNegotiation
    at com.aallam.openai.client.internal.HttpClientKt$createHttpClient$configuration$1.invoke(HttpClient.kt:34)
    at com.aallam.openai.client.internal.HttpClientKt$createHttpClient$configuration$1.invoke(HttpClient.kt:24)
    at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:42)
    at io.ktor.client.HttpClientJvmKt.HttpClient(HttpClientJvm.kt:23)
    at com.aallam.openai.client.internal.HttpClientKt.createHttpClient(HttpClient.kt:89)
    at com.aallam.openai.client.OpenAIKt.OpenAI(OpenAI.kt:60)

    at com.example.app.ChatGPTAIService.<init>(ChatGPTAIService.kt:58)

Steps to Reproduce

  1. Add ktor 3.0.0-rc-1 dependencies
  2. Use simple code
    val config =
    OpenAIConfig(
        chatGptToken,
        organization = organization,
        logging = LoggingConfig(logger = Empty),
    )
    OpenAI(config)
  3. Run code, you will get

Environment

Additional Info

PR https://github.com/aallam/openai-kotlin/pull/345 may help

DenisV94 commented 1 month ago

Same issue here, the ktor API of that library must be updated to 3.0 soon.

aallam commented 1 month ago

Waiting for the official release of Ktor 3.0, but I will make a beta release in preparation for it.

DenisV94 commented 1 month ago

Waiting for the official release of Ktor 3.0, but I will make a beta release in preparation for it.

Thx! Waiting for it :D

DenisV94 commented 1 month ago

Ktor 3.0 just released. Waiting for the lib update ^^