FIX: we must properly encode objects prior to escaping (#891)
in cases of arrays escapeHTML will not work) *
This commit is contained in:
parent
c352054d4e
commit
bffe9dfa07
|
@ -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)}</#{name}>" }.join("\n")
|
||||
xml =
|
||||
params.map { |name, value| "<#{name}>#{CGI.escapeHTML(value.to_s)}</#{name}>" }.join("\n")
|
||||
|
||||
node.at("tool_name").content = tool_call.name
|
||||
node.at("tool_id").content = tool_call.id
|
||||
|
|
|
@ -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)}</#{arg_name}>"
|
||||
memo << "\n<#{arg_name}>#{CGI.escapeHTML(value.to_s)}</#{arg_name}>"
|
||||
end
|
||||
argument_fragments << "\n"
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ module DiscourseAi
|
|||
|
||||
argument_fragments =
|
||||
json_args.reduce(+"") do |memo, (arg_name, value)|
|
||||
memo << "\n<#{arg_name}>#{CGI.escapeHTML(value)}</#{arg_name}>"
|
||||
memo << "\n<#{arg_name}>#{CGI.escapeHTML(value.to_s)}</#{arg_name}>"
|
||||
end
|
||||
argument_fragments << "\n"
|
||||
|
||||
|
|
Loading…
Reference in New Issue