redis / redis/redis-vl-python

Add ChatRole enum for message history schema

Open
#484 1 comment 0 reactions 0 assignees View on GitHub

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.role is currently a plain str in redisvl/extensions/message_history/schema.py.
  • Role handling is split between schema and base history validation logic.

Proposed Change

  • Add a ChatRole enum (user, assistant, system, tool).
  • Update ChatMessage to 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.