Conversation
…messages, since LLM should take the latest result of language identification, in case of mistakes
…t & accurate LLM translation
…onse, non-string response
bendnema
reviewed
Apr 3, 2026
bendnema
left a comment
There was a problem hiding this comment.
Great coverage of the code, and good variation in what the model recieves
pskodr
reviewed
Apr 3, 2026
There was a problem hiding this comment.
graceful fallbacks are well tested, parsing edge cases are covered, and HTML preservation is good for NodeBB site preservation tests.
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.
Objective
This PR introduces a robust suite of unit tests to validate our LLM parsing logic and ensure the microservice safely handles the unpredictability of local AI models.
Changes Made
Expanded test_translator.py to cover the following scenarios:
Multi-Language Support: Verified successful extraction and translation formatting for various non-English languages.
LLM Output Quirks: Ensured the parser safely ignores conversational filler, handles out-of-order keys, and strips extra whitespace.
Formatting Preservation: Confirmed that colons, emojis, and HTML/Markdown tags within the translated text are perfectly preserved for the NodeBB frontend.
Fallback Mechanisms: Tested try/except blocks against critical failures, including missing JSON keys, empty responses, invalid boolean text (e.g., "Not Sure"), and raw API crashes.
How to Verify
Run the following command locally or in the Dev Container to verify all tests pass:
Can also run the following for more details on the specific tests being run.
(All tests are currently passing locally with 100% success).