Add ChatRole enum for message history schema
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Python
- Stars
- 427
- Forks
- 101
- Avg merge
- 6d 3h
- Merged PRs (30d)
- 20
Description
Summary
Introduce a ChatRole enum for message history while preserving backward compatibility with string role inputs.
Level: Beginner
Current State
ChatMessage.roleis currently a plainstrinredisvl/extensions/message_history/schema.py.- Role handling is split between schema and base history validation logic.
Proposed Change
- Add a
ChatRoleenum (user,assistant,system,tool). - Update
ChatMessageto accept enum values and coerce valid strings. - Align checks in
redisvl/extensions/message_history/base_history.py. - Export the enum from the message history module.
Definition of Done
- Enum-based role validation is in place.
- Existing string-based behavior remains valid (non-breaking).
- Unit tests cover valid coercion and invalid role errors.
make format,make check-types, and tests pass.
Out of Scope
- Redesigning message history schemas beyond the role type.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with redisvl/extensions/message_history/schema.py and then compare the role validation in redisvl/extensions/message_history/base_history.py. Check the existing message-history tests, add coverage for valid coercion and invalid roles, and confirm backward-compatible string inputs with make format, make check-types, and the test suite.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100