Skip to content

Commit

Permalink
Fix problem with deserializer (#80)
Browse files Browse the repository at this point in the history
* Fix never-ending deserialization agent

* Fix never-ending deserialization agent
  • Loading branch information
serras authored May 21, 2023
1 parent 6405f84 commit a176736
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,12 @@ suspend fun <A> AIScope.tryDeserialize(
while (currentAttempts < maxDeserializationAttempts) {
currentAttempts++
val result = ensureNotNull(agent().firstOrNull()) { AIError.NoResponse }
catch({ json.decodeFromString(serializationConfig.deserializationStrategy, result) }) {
e: IllegalArgumentException ->
catch({
return@tryDeserialize json.decodeFromString(
serializationConfig.deserializationStrategy,
result
)
}) { e: IllegalArgumentException ->
if (currentAttempts == maxDeserializationAttempts)
raise(AIError.JsonParsing(result, maxDeserializationAttempts, e))
// else continue with the next attempt
Expand Down

0 comments on commit a176736

Please sign in to comment.