Skip to content

fix: robust JSON extraction for mixed LLM responses#124

Open
SergioChan wants to merge 1 commit into666ghj:mainfrom
SergioChan:fix/issue-64
Open

fix: robust JSON extraction for mixed LLM responses#124
SergioChan wants to merge 1 commit into666ghj:mainfrom
SergioChan:fix/issue-64

Conversation

@SergioChan
Copy link

SummarynnHarden backend JSON parsing for LLM responses so mixed outputs (markdown fences, pre/post text) are handled more robustly, reducing 500 errors reported during ontology generation.nn## Changesnn- Updated LLMClient.chat() to remove <think ...>...</think> tags case-insensitivelyn- Added LLMClient._extract_json_payload() to normalize and extract JSON from noisy model responsesn- Updated chat_json() to parse extracted payload instead of raw contentn- Added unit tests in backend/tests/test_llm_client_json_extract.py for fenced JSON and mixed-text extractionnn## Testingnn- Added targeted unit tests for extraction behaviorn- Could not execute tests in this environment because backend dev dependencies are not installed (pytest, flask missing)nnFixes #64

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. LLM API Any questions regarding the LLM API labels Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM API Any questions regarding the LLM API size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant