commonMain.com.xebia.functional.xef.AIEvent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xef-core Show documentation
Show all versions of xef-core Show documentation
Building applications with LLMs through composability in Kotlin
package com.xebia.functional.xef
sealed class AIEvent {
data object Start : AIEvent()
data class Result(val value: A) : AIEvent()
data class ToolExecutionRequest(val tool: Tool<*>, val input: Any?) : AIEvent()
data class ToolExecutionResponse(val tool: Tool<*>, val output: Any?) : AIEvent()
data class Stop(val usage: Usage) : AIEvent() {
data class Usage(
val llmCalls: Int,
val toolCalls: Int,
val inputTokens: Int,
val outputTokens: Int,
val totalTokens: Int,
)
}
fun debugPrint(): Unit =
when (this) {
// emoji for start is: 🚀
Start -> println("🚀 Starting...")
is Result -> println("🎉 $value")
is ToolExecutionRequest ->
println("🔧 Executing tool: ${tool.function.name} with input: $input")
is ToolExecutionResponse ->
println("🔨 Tool response: ${tool.function.name} resulted in: $output")
is Stop -> {
println("🛑 Stopping...")
println("📊 Usage: $usage")
}
}
}