Skip to content

Commit

Permalink
Add better JSON parsing check (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
krschacht authored Jan 27, 2025
1 parent a576403 commit b963887
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/helpers/messages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def thinking_html(message, thinking)
end

def message_to_user_from_tool_call?(message)
JSON.parse(message.content_text)["message_to_user"].present? if message.content_text.present?
return false if message.content_text.blank?
msg_hash = JSON.parse(message.content_text)
msg_hash.is_a?(Hash) && msg_hash["message_to_user"].present?
rescue JSON::ParserError
false
end
Expand Down

0 comments on commit b963887

Please sign in to comment.