interfAIce
1.0.1
查看我介绍接口的博客文章
在项目的build.gradle.kts
文件中,添加以下内容:
dependencies {
implementation( " io.github.mscheong01:interfAIce-core:1.0.0 " )
}
// This option is currently required for reflection to work
// Later releases will remove this requirement for Kotlin projects
tasks.withType< KotlinCompile > {
this .kotlinOptions {
freeCompilerArgs = listOf ( " -Xjsr305=strict " )
javaParameters = true
}
}
dependencies {
implementation( " io.github.mscheong01:interfAIce-core:1.0.0 " )
}
// This option is currently required for reflection to work
// If all your classes have a no-arg constructor, you can remove this option
tasks.withType< JavaCompile > {
options.compilerArgs.add( " -parameters " )
}
dependencies {
implementation( " io.github.mscheong01:interfAIce-spring-boot-starter:1.0.0 " )
}
@EnableInterfaiceProxies
注解添加到您的 Spring Boot 应用程序类或其任何配置类@EnableInterfaiceProxies(
basePackages = [ " io.github.mscheong01.interfaice.examples " ]
)
@SpringBootApplication
open class ExampleApplication
application.yml
文件中指定您的 OpenAi api 密钥 spring :
interfaice :
openai :
api-key : ${OPENAI_API_KEY}
chat :
default-model : gpt-3.5-turbo # optional, defaults to gpt-3.5-turbo
@OpenAiInterface
注释添加到您的界面@OpenAiInterface
interface ExampleInterface {
fun greet ( name : String ): String
}
@RestController
class ExampleController (
private val exampleInterface : ExampleInterface
) {
@GetMapping( " /greet " )
fun greet (@RequestParam name : String ): String {
return exampleInterface.greet(name)
}
}
interfAIce 提供快照版本,当更改推送到主分支时,快照版本会自动发布。当前快照版本是当前发行版本的下一个次要版本,带有 -SNAPSHOT 后缀。例如,如果当前版本是 1.2.3,则快照版本将为 1.3.0-SNAPSHOT。
要使用快照版本,请将 Maven 快照存储库添加到您的构建配置中
repositories {
maven {
url = uri( " https://s01.oss.sonatype.org/content/repositories/snapshots/ " )
}
}
欢迎贡献!请参阅我们的贡献指南以获取更多信息。
该项目根据 Apache 2.0 许可证获得许可。