diff --git a/lib/completions/anthropic_message_processor.rb b/lib/completions/anthropic_message_processor.rb index 14be04ec..1d1516fa 100644 --- a/lib/completions/anthropic_message_processor.rb +++ b/lib/completions/anthropic_message_processor.rb @@ -39,7 +39,8 @@ class DiscourseAi::Completions::AnthropicMessageProcessor ) params = JSON.parse(tool_call.raw_json, symbolize_names: true) - xml = params.map { |name, value| "<#{name}>#{CGI.escapeHTML(value)}" }.join("\n") + xml = + params.map { |name, value| "<#{name}>#{CGI.escapeHTML(value.to_s)}" }.join("\n") node.at("tool_name").content = tool_call.name node.at("tool_id").content = tool_call.id diff --git a/lib/completions/endpoints/gemini.rb b/lib/completions/endpoints/gemini.rb index f626e41a..ddf607b2 100644 --- a/lib/completions/endpoints/gemini.rb +++ b/lib/completions/endpoints/gemini.rb @@ -179,7 +179,7 @@ module DiscourseAi if partial[:args] argument_fragments = partial[:args].reduce(+"") do |memo, (arg_name, value)| - memo << "\n<#{arg_name}>#{CGI.escapeHTML(value)}" + memo << "\n<#{arg_name}>#{CGI.escapeHTML(value.to_s)}" end argument_fragments << "\n" diff --git a/lib/completions/endpoints/open_ai.rb b/lib/completions/endpoints/open_ai.rb index b3960568..92315ed5 100644 --- a/lib/completions/endpoints/open_ai.rb +++ b/lib/completions/endpoints/open_ai.rb @@ -173,7 +173,7 @@ module DiscourseAi argument_fragments = json_args.reduce(+"") do |memo, (arg_name, value)| - memo << "\n<#{arg_name}>#{CGI.escapeHTML(value)}" + memo << "\n<#{arg_name}>#{CGI.escapeHTML(value.to_s)}" end argument_fragments << "\n"