Skip to content

Add ChatRole enum for message history schema #484

@tylerhutcherson

Description

@tylerhutcherson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions