Fix ENTITY_TYPES Environment Variable Handling #2034
Merged
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.
Fix ENTITY_TYPES Environment Variable Handling
🐛 Problem Description
The
ENTITY_TYPES
environment variable was incorrectly processed when provided as a JSON array string, causing entity extraction to fail completely. Instead of parsing the JSON string into a proper Python list, the system was converting it character-by-character, resulting in unusable single-character tokens being passed to the LLM.Before Fix:
Impact:
🔧 Solution
Modified the
get_env_value
function inlightrag/utils.py
to properly handle JSON parsing for list-type environment variables.Key Changes:
list
type environment variables✅ After Fix
Now Works Correctly:
🧪 Testing
📋 Usage
Users can now set custom entity types using standard JSON array syntax:
The system will properly parse this into a Python list and use it in entity extraction prompts, allowing the LLM to correctly classify entities according to the specified custom types.
🔄 Backward Compatibility
This fix maintains 100% backward compatibility:
ENTITY_TYPES
is not set