Skip to content

Reject malformed JSON in LLM coercion - #161

Open
Fu Xiaonan (FU-max-boop) wants to merge 1 commit into
microsoft:mainfrom
FU-max-boop:fix/reject-malformed-empty-json
Open

Reject malformed JSON in LLM coercion#161
Fu Xiaonan (FU-max-boop) wants to merge 1 commit into
microsoft:mainfrom
FU-max-boop:fix/reject-malformed-empty-json

Conversation

@FU-max-boop

Copy link
Copy Markdown

Summary

  • accept an empty JSON object only when the complete LLM output is {} (allowing surrounding/interior whitespace)
  • reject malformed or mixed JSON that extract_json reports with its {} failure sentinel
  • add regression coverage for the reported mismatched-brace response and related malformed outputs

Validation

  • pytest tests/unit/test_llm_chat.py -k coerce_to_dict_or_list -q — 2 passed
  • pytest tests/unit/test_llm_chat.py -k coerce -q — 12 passed
  • pytest tests/unit/test_utils.py -k 'extract_json or name_or_empty or repeat_on_error' -q — 3 passed\n- black --check tests/unit/test_llm_chat.py --target-version py310\n- python -m py_compile tinytroupe/utils/llm.py tests/unit/test_llm_chat.py\n- git diff --check\n\nFixes utils.llm.LLMChat._coerce_to_dict_or_list allows misformatted JSONs through #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.

1 participant