Git Product home page Git Product logo

interfaice's Introduction

Hi there ๐Ÿ‘‹

interfaice's People

Contributors

davin111 avatar mscheong01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

interfaice's Issues

Support Array types

I think we missed out Array types when adding support for collection types (currently, only List, Set and Map is supported)

Support object types for request/response

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,
)

Provide a way to close OkHttpClient when using `DefaultOkHttpOpenAiClient`

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 OpenAiApiClientdefined 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)
            }
        }
    })
}

Support Function calling

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()

Cache for Better Performance - Reflection & LLM

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.