discourse-ai/lib/completions
Roman Rizzi ff2e18f9ca
FIX: Structured output discrepancies. (#1340)
This change fixes two bugs and adds a safeguard.

The first issue is that the schema Gemini expected differed from the one sent, resulting in 400 errors when performing completions.

The second issue was that creating a new persona won't define a method
for `response_format`. This has to be explicitly defined when we wrap it inside the Persona class. Also, There was a mismatch between the default value and what we stored in the DB. Some parts of the code expected symbols as keys and others as strings.

Finally, we add a safeguard when, even if asked to, the model refuses to reply with a valid JSON. In this case, we are making a best-effort to recover and stream the raw response.
2025-05-15 11:32:10 -03:00
..
dialects DEV: use a proper object for tool definition (#1337) 2025-05-15 17:32:39 +10:00
endpoints FIX: Structured output discrepancies. (#1340) 2025-05-15 11:32:10 -03:00
anthropic_message_processor.rb DEV: Use structured responses for summaries (#1252) 2025-05-06 10:09:39 -03:00
cancel_manager.rb FEATURE: forum researcher persona for deep research (#1313) 2025-05-14 12:36:16 +10:00
json_stream_decoder.rb FEATURE: improve tool support (#904) 2024-11-12 08:14:30 +11:00
json_streaming_parser.rb FEATURE: partial tool call support for OpenAI and Anthropic (#908) 2024-11-14 06:58:24 +11:00
json_streaming_tracker.rb FIX: Structured output discrepancies. (#1340) 2025-05-15 11:32:10 -03:00
llm.rb FEATURE: forum researcher persona for deep research (#1313) 2025-05-14 12:36:16 +10:00
nova_message_processor.rb DEV: Use structured responses for summaries (#1252) 2025-05-06 10:09:39 -03:00
open_ai_message_processor.rb DEV: Use structured responses for summaries (#1252) 2025-05-06 10:09:39 -03:00
prompt.rb DEV: use a proper object for tool definition (#1337) 2025-05-15 17:32:39 +10:00
prompt_messages_builder.rb FEATURE: forum researcher persona for deep research (#1313) 2025-05-14 12:36:16 +10:00
report.rb FEATURE: Allow for persona & llm selection in bot conversations page (#1276) 2025-04-24 11:17:24 -05:00
structured_output.rb FIX: Structured output discrepancies. (#1340) 2025-05-15 11:32:10 -03:00
thinking.rb FEATURE: implement thinking token support (#1155) 2025-03-04 12:22:30 +11:00
tool_call.rb FEATURE: AI artifacts (#898) 2024-11-19 09:22:39 +11:00
tool_definition.rb DEV: use a proper object for tool definition (#1337) 2025-05-15 17:32:39 +10:00
upload_encoder.rb FEATURE: enforce jpg/png for all images (#1309) 2025-05-05 17:46:37 +10:00
xml_tag_stripper.rb FIX: display search correctly, bug when stripping XML (#668) 2024-06-14 15:28:40 +10:00
xml_tool_processor.rb DEV: use a proper object for tool definition (#1337) 2025-05-15 17:32:39 +10:00