我可以在哪里找到projects.openaiClient的定义?

huangapple go评论67阅读模式
英文:

Where can I find the definition of projects.openaiClient?

问题

以下示例代码来自OpenAI API客户端Kotlin项目

你可以在https://github.com/aallam/openai-kotlin/tree/main/sample/native 上看到它。

我在Android Studio中打开了示例代码,但我找不到作者在哪里定义implementation(projects.openaiClient),我已经搜索了整个项目,你能告诉我吗?

build.gradle.kts

plugins {
    kotlin("multiplatform")
}

kotlin {
    val hostOs = System.getProperty("os.name")
    val isMingwX64 = hostOs.startsWith("Windows")
    val nativeTarget = when {
        hostOs == "Mac OS X" -> macosX64("native")
        hostOs == "Linux" -> linuxX64("native")
        isMingwX64 -> mingwX64("native")
        else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
    }
    nativeTarget.apply {
        binaries {
            executable {
                entryPoint = "main"
            }
        }
    }
    sourceSets {
        val nativeMain by getting {
            dependencies {
                implementation(projects.openaiClient)   // 这里是 projects.openaiClient
                implementation(libs.ktor.client.curl)   // 这里是 libs.ktor.client.curl
            }
        }
    }
}
英文:

The following sample code comes from OpenAI API client for Kotlin project.

You can see it at https://github.com/aallam/openai-kotlin/tree/main/sample/native

I open the sample code with Android Studio, but I can't find where the author define the implementation(projects.openaiClient), I have searched the whole project, could you tell me ?

build.gradle.kts

plugins {
    kotlin("multiplatform")
}

kotlin {
    val hostOs = System.getProperty("os.name")
    val isMingwX64 = hostOs.startsWith("Windows")
    val nativeTarget = when {
        hostOs == "Mac OS X" -> macosX64("native")
        hostOs == "Linux" -> linuxX64("native")
        isMingwX64 -> mingwX64("native")
        else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
    }
    nativeTarget.apply {
        binaries {
            executable {
                entryPoint = "main"
            }
        }
    }
    sourceSets {
        val nativeMain by getting {
            dependencies {
                //implementation("com.aallam.openai:openai-client:<version>")
                implementation(projects.openaiClient)   // Where is projects.openaiClient
                implementation(libs.ktor.client.curl)   // Where is libs.ktor.client.curl
            }
        }
    }
}

答案1

得分: 2

openai-client子项目位于此处。include 已添加到settings.gradle.kts中。

在示例代码中,作者使用了称为type-safe project accessor的内容:

> 以短横线式命名(some-lib)或蛇形命名(some_lib)的项目名称将在访问器中转换为驼峰式命名:projects.someLib。

这意味着可以使用projects.openaiClient添加依赖项。

英文:

The openai-client subproject is located here. The include was added in settings.gradle.kts.

In the sample code the author then used something called type-safe project accessor:

> A project name with kebab case (some-lib) or snake case (some_lib)
> will be converted to camel case in accessors: projects.someLib.

This means that the dependency can be added using projects.openaiClient.

huangapple
  • 本文由 发表于 2023年4月4日 15:29:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75926606.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定