discourse-ai/lib
Roman Rizzi d72ad84f8f
FIX: Retry parsing escaped inner JSON to handle control chars. (#1357)
The structured output JSON comes embedded inside the API response, which is also a JSON. Since we have to parse the response to process it, any control characters inside the structured output are unescaped into regular characters, leading to invalid JSON and breaking during parsing. This change adds a retry mechanism that escapes
the string again if parsing fails, preventing the parser from breaking on malformed input and working around this issue.

For example:

```
  original = '{ "a": "{\\"key\\":\\"value with \\n newline\\"}" }'
  JSON.parse(original) => { "a" => "{\"key\":\"value with \n newline\"}" }
  # At this point, the inner JSON string contains an actual newline.
```
2025-05-21 11:25:59 -03:00
..
ai_bot FIX: add safe navigation to serializer include conditions (#1349) 2025-05-19 18:55:55 -03:00
ai_helper DEV: Temporarily suppress diff animation as we fix issues (#1341) 2025-05-15 14:55:30 -07:00
ai_moderation FEATURE: flexible image handling within messages (#1214) 2025-03-31 12:39:07 -03:00
automation FEATURE: Triage can hide posts after adding them to the review queue (#1348) 2025-05-20 08:19:00 +10:00
completions FIX: Retry parsing escaped inner JSON to handle control chars. (#1357) 2025-05-21 11:25:59 -03:00
configuration FEATURE: New setting to control model for translations (#1333) 2025-05-12 12:12:30 -03:00
database DEV: port directory structure to Zeitwerk (#319) 2023-11-29 15:17:46 +11:00
discord/bot FEATURE: forum researcher persona for deep research (#1313) 2025-05-14 12:36:16 +10:00
embeddings FIX: Ensure that we shutdown thread pool (#1207) 2025-03-21 11:08:36 +08:00
inference FEATURE: forum researcher persona for deep research (#1313) 2025-05-14 12:36:16 +10:00
personas DEV: prompt engineering to improve citations (#1351) 2025-05-20 13:01:35 +10:00
sentiment FIX: Ensure category badging present in sentiment reports (#1222) 2025-03-26 12:37:41 -07:00
summarization FIX: Structured output discrepancies. (#1340) 2025-05-15 11:32:10 -03:00
tasks DEV: rake task to populate sentiment in dev env (#1176) 2025-03-10 14:21:00 -03:00
tokenizer FEATURE: Gemini Tokenizer (#1088) 2025-01-23 18:20:35 -03:00
utils DEV: Improve diff streaming accuracy with safety checker (#1338) 2025-05-15 11:38:46 -07:00
automation.rb FEATURE: Triage can hide posts after adding them to the review queue (#1348) 2025-05-20 08:19:00 +10:00
embeddings.rb DEV: Robust check for embeddings enabled (#1116) 2025-02-06 12:18:55 -03:00
engine.rb DEV: port directory structure to Zeitwerk (#319) 2023-11-29 15:17:46 +11:00
features.rb FEATURE: Configure persona backed features in admin panel (#1245) 2025-04-10 08:16:31 -07:00
guardian_extensions.rb FIX: Restore gists previous group access behavior. (#1247) 2025-04-07 12:04:30 -03:00
multisite_hash.rb FIX: properly cache user locale (#593) 2024-04-26 09:28:35 -03:00
post_extensions.rb FEATURE: Backfill posts sentiment. (#982) 2024-12-03 10:27:03 -03:00
summarization.rb FEATURE: Personas powered summaries. (#1232) 2025-04-02 12:54:47 -03:00
topic_extensions.rb PERF: Preload only gists when including summaries in topic list (#948) 2024-11-25 12:24:02 -03:00