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