FIX: avoid using structured outputs for report runs (#1502)
Structured outputs are prone to formatting issue, especially around newlines and custom pieces of text that need escaping. This avoids using it for the automation reporting. Particularly previous to this fix o4-mini based reports were broken
This commit is contained in:
parent
8c069490f0
commit
1b16fc876c
|
@ -154,12 +154,10 @@ module DiscourseAi
|
|||
result = +""
|
||||
bot = DiscourseAi::Personas::Bot.as(Discourse.system_user, persona: @persona, model: @model)
|
||||
json_summary_schema_key = @persona.response_format&.first.to_h
|
||||
output = nil
|
||||
|
||||
buffer_blk =
|
||||
Proc.new do |partial, _, type|
|
||||
if type == :structured_output
|
||||
output = partial.dup
|
||||
read_chunk = partial.read_buffered_property(json_summary_schema_key["key"]&.to_sym)
|
||||
|
||||
print read_chunk if Rails.env.development? && @debug_mode
|
||||
|
|
|
@ -17,18 +17,9 @@ module DiscourseAi
|
|||
|
||||
Follow the provided writing composition instructions carefully and precisely step-by-step.
|
||||
|
||||
Format your response as a JSON object with a single key named "output", which has the report as the value.
|
||||
Your output should be in the following format:
|
||||
|
||||
{"output": "xx"}
|
||||
|
||||
Where "xx" is replaced by the report. Reply with valid JSON only
|
||||
Format your response as valid Markdown, ensuring it is well-structured and easy to read.
|
||||
PROMPT
|
||||
end
|
||||
|
||||
def response_format
|
||||
[{ "key" => "output", "type" => "string" }]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue