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

commonMain.com.xebia.functional.xef.AIEvent.kt Maven / Gradle / Ivy

The newest version!
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")
      }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy