openai-kotlin icon indicating copy to clipboard operation
openai-kotlin copied to clipboard

Unable to integrate the library in a Kotlin springboot project

Open swapnilgt opened this issue 1 year ago • 1 comments

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

  1. Create a basic Sprint project from https://start.spring.io/ . Choose Gradle - Kotlin, Kotlin Language, Jar Packaging and Java 17
  2. 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()
}
  1. 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.

swapnilgt avatar Dec 23 '23 08:12 swapnilgt

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.

aallam avatar Dec 26 '23 14:12 aallam