Skip to content

Commit

Permalink
only swallow tool exceptions if they are not assertion errors (#769)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulraja committed Jul 8, 2024
1 parent 0123ea1 commit 9de65ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Assistant(
Json.encodeToJsonElement(toolSerializer.outputSerializer as KSerializer<Any?>, output)
ToolOutput(schema, result)
} catch (e: Exception) {
if (e is AssertionError) throw e
val message = "Error calling to tool registered $name: ${e.message}"
val logger = KtorSimpleLogger("Functions")
logger.error(message, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import com.xebia.functional.xef.llm.addMetrics
import com.xebia.functional.xef.metrics.Metric
import io.ktor.client.request.*
import kotlin.jvm.JvmName
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
Expand Down Expand Up @@ -186,6 +189,7 @@ class AssistantThread(
} else null
} else null
} catch (e: Throwable) {
if (e is AssertionError) throw e
toolCall.id to
Assistant.Companion.ToolOutput(
schema = JsonObject(emptyMap()),
Expand Down

0 comments on commit 9de65ae

Please sign in to comment.