fix(sentiment): stripCodeFences before JSON.parse (closes #296)#315
Open
iPLAYCAFE-dev wants to merge 1 commit into
Open
fix(sentiment): stripCodeFences before JSON.parse (closes #296)#315iPLAYCAFE-dev wants to merge 1 commit into
iPLAYCAFE-dev wants to merge 1 commit into
Conversation
…#296) Mirror summary.service.ts:146 and merge-assessment.service.ts which already strip fences. Without it, any model that wraps json_object output in ```fences``` (e.g. claude-haiku-4.5, deepseek-chat via OpenRouter) breaks analyzeSentiment's bare JSON.parse.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #296.
analyzeSentimentinsentiment.service.tsdoes a bareJSON.parseon the chat response, unlikesummary.service.ts:146andmerge-assessment.service.tswhich both wrap it instripCodeFences(...). Any provider/model that wraps thejson_objectoutput in```json ... ```fences — even withresponse_format: { type: 'json_object' }— therefore throwsJSON Parse error: Unrecognized token ''` and sentiment is dropped.Verified live via OpenRouter:
anthropic/claude-haiku-4.5anddeepseek/deepseek-chatfence the output; OpenAI models,claude-sonnet-4.6,google/gemini-3.1-flash-lite, andmeta-llama/llama-3.3-70b-instructreturn clean JSON.This is the minimal fix: import the existing
stripCodeFenceshelper and apply it beforeJSON.parse, exactly as the sibling summary/merge services already do. One-line behavior change, no new dependency.