Hywel Bennett
10/24/2025, 12:59 PM```json
code fences. This is also a problem when I try to call requestLLMStructured() as the deserialization fails and requires a fixing model to correct it. I wonder if it might be worth anticipating this pattern as a pre-deserialization step (either just as a sensible default or a hook for callers to pre-proccess the LLM output to remove the code fences). I understand that the fixing model exists, but this seems like a reasonably common problem case that could be pre-empted and save on additional model calls.
Would love to hear if anyone has any other strategies for handling code fenced outputsAnastasiia Zarechneva
10/24/2025, 2:20 PMHywel Bennett
10/24/2025, 2:21 PMVadim Briliantov
10/24/2025, 3:28 PMEl Anthony
10/24/2025, 4:13 PMfun mySimpleQwenLLMPromptExecutor(baseUrl: String = "<http://localhost:11434>") : SingleLLMPromptExecutor =
MySimpleQwenLLMPromptExecutor( baseUrl)
class MySimpleQwenLLMPromptExecutor(baseUrl: String = "<http://localhost:11434>") : SingleLLMPromptExecutor( OllamaClient(baseUrl))
{
override suspend fun execute(prompt: Prompt, model: LLModel, tools: List<ToolDescriptor>): List<Message.Response> {
val response = super.execute( prompt, model, tools)
val res = response.mapNotNull { msg ->
if( msg is Message.Assistant) {
val newContent = msg.content.replace(emptyThinkContent, "")
if( newContent.isEmpty()) null
else msg.copy( content = newContent)
}
else msg
}
return res
}
companion object {
val emptyThinkContent = Regex("[ \n]*<think>[ \t\n]*</think>[ \n]*", setOf(RegexOption.MULTILINE, RegexOption.DOT_MATCHES_ALL))
}
}Hywel Bennett
10/24/2025, 4:15 PM