fix: convert dict entities to text strings for highlights field (Fixes #386)#667
Conversation
…ritesh-1918#386) entities from ner_service.extract_entities() returns list[dict] with keys {"text", "label", "confidence"}, not EntityInfo objects. The highlights field expects list[str]. Changed highlights=[e.text for e in entities] to highlights=[e.get("text", "") for e in entities] to properly extract text from dict entries.
|
@lb1192176991-lab is attempting to deploy a commit to the ritesh Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Superb implementation, @lb1192176991-lab! I've successfully resolved all conflicts in your PR and queued it for merging into
Keep up the outstanding work! Let's build together! 🔥 |
|
Hi @lb1192176991-lab! 🙌 Thank you so much for your excellent contribution: "fix: convert dict entities to text strings for highlights field (Fixes #386)"! We really appreciate the high-quality code and effort you have put into the platform. Just a quick, friendly heads-up as we prepare our manual merging and verification queues—please make sure to complete all the mandatory community steps listed below. Once those manual steps are verified, we'll get your PR officially merged into the Let's build something amazing together! 🚀🔥 🌟 Community Support & Network Steps (Take 10 Seconds!)As we prepare our manual verification and merging queues, please make sure you have taken a moment to complete these required steps to finalize your points:
Note: Having these steps completed manually is required before your PR points are officially cleared. |
What
The
/ai/analyzeendpoint crashes with a 500 error because thehighlightsfield inTicketResponseis typed aslist[str]but receiveslist[dict]objects.Root cause:
ner_service.extract_entities()returnslist[dict]with keys{"text", "label", "confidence"}. When this list is passed tohighlights=[e.text for e in entities], it crashes withAttributeError: dict object has no attribute textbecause the entities variable is stilllist[dict]at that point in the code (it is only converted tolist[EntityInfo]in the separateentities=parameter).Fix: Changed line 1855 from:
to:
The
analyze_stream()endpoint already had the correct form (e.get("text", "")) on line 2019 — it was only theanalyze_only()function that had the wrong access pattern.Why
Users hitting the
/ai/analyzeendpoint get a 500 error when NER entities are present, making the AI analysis feature completely broken whenever entities are detected. Pydantic v2 cannot coercedictobjects intostr.Testing
entities = [{"text": "Python", "label": "tech", "confidence": 0.95}], highlights becomes["Python"]✓entities = [], highlights becomes[]✓entities = [{"label": "tech"}](missing text key), highlights becomes[""]✓ (graceful fallback)