mscheong01 / interfaice Goto Github PK
View Code? Open in Web Editor NEWDefine an interface, and use LLM as your implementation!
License: Apache License 2.0
Define an interface, and use LLM as your implementation!
License: Apache License 2.0
ex)
interface TestInterface {
@OpenAiChat
fun randomCityNameInCountryOrNull(cityName: String?): String?
}
I think we missed out Array types when adding support for collection types (currently, only List, Set and Map is supported)
I think some users want to enrich auto generated prompt for user-defined classes.
Maybe we can add an annotation for it. I will work on it right away after the PR about ObjectRule
is merged.
Because the gradle script of spring-boot-starter-interfAIce
doesn't include from(components["java"])
, it doesn't generate jar file. And I think it's better to include sources and javadocs for the module.
Also, I think we should rename the module to interfAIce-spring-boot-starter
, because the official doc of Spring Boot says 'Do not start your module names with spring-boot, even if you use a different Maven groupId.'.
ex)
interface TestInterface {
@OpenAiChat
fun getGreetingCard(person: Person): GreetingCard
}
class Person(
val name: String,
val age: Int,
val locale: String,
)
class GreetingCard(
val message: String,
)
When executing a Test where an error occurs in InvocationHandler, it takes a while for the system to exit after the exception is thrown. It looks like the probable cause is that the background thread that calls the openai api is not cleaned up and runs regardless of the error. This did not happen when I used OpenAiApiClient
defined in the spring boot starter that uses a spring webclient.
suspicious code:
https://github.com/mscheong01/interfAIce/blob/main/core/src/main/kotlin/io/github/mscheong01/interfaice/openai/DefaultOkHttpOpenAiClient.kt
Mono.create { sink ->
client.newCall(httpRequest).enqueue(object : com.squareup.okhttp.Callback {
override fun onFailure(request: Request, e: java.io.IOException) {
sink.error(e)
}
override fun onResponse(response: com.squareup.okhttp.Response) {
try {
if (!response.isSuccessful) {
throw IOException("Error: ${response.code()} ${response.message()}")
} else {
sink.success(mapper.readValue(response.body().string()))
}
} catch (e: Exception) {
sink.error(e)
}
}
})
}
OpenAI has added "function calling" feature to the Chat api
https://openai.com/blog/function-calling-and-other-api-updates
We could leverage this feature to allow interfAIce proxies to call upon other methods
ex)
interface FunctionAware<T> {
fun withFunction( ... ): T
fun withFunctions( ... ): T
}
interface WeatherService : FunctionAware<WeatherService> {
fun getWeather(): Weather
}
val proxy = OpenAiProxyFactory.of("sk-****").create<WeatherService>()
proxy
.withFunction(weatherClient::greet)
.getWeather()
I think we can utilize internal caches for not executing reflection and many logic every time. This is surely optional feature, I think we can add it after the initial release. I'm interested in the implementation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.