openai-kotlin
openai-kotlin copied to clipboard
Unable to integrate the library in a Kotlin springboot project
Description
Trying to setup a Kotlin sprint boot project. Added the required libraries as dependencies. Unable to import the OpenAI class in my class. The IDE cannot find the class.
Steps to Reproduce
- Create a basic Sprint project from https://start.spring.io/ . Choose Gradle - Kotlin, Kotlin Language, Jar Packaging and Java 17
- Import the required libraries in the gradle script. Here is the gradle script
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "3.2.1"
id("io.spring.dependency-management") version "1.1.4"
kotlin("jvm") version "1.9.21"
kotlin("plugin.spring") version "1.9.21"
}
group = "com.ultgpts.rechargegpt"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("com.aallam.openai:openai-client:3.6.2")
implementation("io.ktor:ktor-client-java:2.3.2")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
- Create a new class and try to import the
OpenAI
class. Unless to import the calls
Environment
- openai-kotlin version 3.6.2
- Kotlin version: 1.9.21
- OS: macOS
Additional Info
Not sure what am I missing here.
I've followed the same steps and didn't encounter any issues. I believe this might be related to your IDE, possibly involving the cache, Gradle cache, etc.