Add: Filter out think tags in bot message (#190)

This commit is contained in:
Kevin Dang
2025-10-04 20:17:26 -07:00
committed by GitHub
parent c00ea5de98
commit 32137dacb0
4 changed files with 12 additions and 4 deletions
+8
View File
@@ -56,6 +56,10 @@ export async function normalMessage(
response = await blockResponse(params)
result = response.message.content
// check if there is a <think>...</think> sequence from the bot.
if (hasThinking(result))
result = result.replace(/<think>[\s\S]*?<\/think>/g, '').trim()
// check if message length > discord max for normal messages
if (result.length > 2000) {
sentMessage.edit(result.slice(0, 2000))
@@ -85,3 +89,7 @@ export async function normalMessage(
// return the string representation of ollama query response
return result
}
function hasThinking(message: string): boolean {
return /<think>[\s\S]*?<\/think>/i.test(message)
}