All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.frtu.kotlin.llm.os.tool.FunctionRegistryBuilder.kt Maven / Gradle / Ivy

package com.github.frtu.kotlin.llm.os.tool

import com.github.frtu.kotlin.llm.os.builder.BuilderMarker
import kotlin.reflect.KFunction2

class FunctionRegistryBuilder(
    private val functionRegistry: FunctionRegistry = FunctionRegistry()
) {
    fun function(
        name: String,
        description: String,
        kFunction2: KFunction2,
        parameterClass: Class<*>,
        returnClass: Class<*>,
    ) = functionRegistry.registerFunction(
        name = name,
        description = description,
        kFunction2 = kFunction2,
        parameterClass = parameterClass,
        returnClass = returnClass,
    )

    fun function(
        name: String,
        description: String,
        kFunction2: KFunction2,
        parameterJsonSchema: String,
        returnJsonSchema: String,
    ) = functionRegistry.registerFunction(
        name = name,
        description = description,
        kFunction2 = kFunction2,
        parameterJsonSchema = parameterJsonSchema,
        returnJsonSchema = returnJsonSchema,
    )

    fun register(function: Function) = functionRegistry.registerFunction(function)

    fun build(): FunctionRegistry = functionRegistry
}


@BuilderMarker
fun registry(actions: FunctionRegistryBuilder.() -> Unit): FunctionRegistry =
    FunctionRegistryBuilder().apply(actions).build()




© 2015 - 2024 Weber Informatics LLC | Privacy Policy