Skip to content

Fix TypeError when faithfulness context chunk text is None - #76

Open
hadbiaghiles wants to merge 1 commit into
codepath:mainfrom
hadbiaghiles:fix/faithfulness-none-text
Open

Fix TypeError when faithfulness context chunk text is None#76
hadbiaghiles wants to merge 1 commit into
codepath:mainfrom
hadbiaghiles:fix/faithfulness-none-text

Conversation

@hadbiaghiles

Copy link
Copy Markdown

Summary

FaithfulnessChecker.check() concatenates context with chunk.get("text", ""). When a chunk has the text key set to None, .get() returns None (the default only applies to missing keys), and " ".join(...) raises:

TypeError: sequence item 0: expected str instance, NoneType found

Fix

Treat text: None like a missing/empty value by joining chunk.get("text") or "". That keeps missing keys, empty strings, and None all join-safe without changing scoring for real text.

Testing

  • Removed the xfail on test_none_context_chunk_text so the original crash case is expected to pass.
  • Extended that test with a mixed [{"text": None}, {"text": "Knows Python well"}] chunk list to confirm None alongside real text is also join-safe.

Fixes #60

Treat chunk text of None the same as a missing key so context join never receives None.
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.

Faithfulness checker crashes when a context chunk has text: None

1 participant