Skip to content

Reject malformed JSON instead of treating it as empty - #164

Open
primorLee wants to merge 1 commit into
microsoft:mainfrom
primorLee:fix/reject-malformed-empty-json
Open

Reject malformed JSON instead of treating it as empty#164
primorLee wants to merge 1 commit into
microsoft:mainfrom
primorLee:fix/reject-malformed-empty-json

Conversation

@primorLee

Copy link
Copy Markdown

Summary

  • distinguish a valid empty JSON object from extract_json's failure sentinel
  • reject malformed model output that merely contains opening and closing braces
  • cover valid empty objects and malformed object/list shapes with regression tests

Testing

  • uv run --isolated --with pytest python -m pytest tests/unit/test_llm_chat.py -k coerce_to_dict_or_list -o addopts= -q (3 passed)
  • python -m compileall -q tinytroupe/utils/llm.py

Fixes #159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

utils.llm.LLMChat._coerce_to_dict_or_list allows misformatted JSONs through

1 participant