Skip to content

Proposal: Add id field to Message struct for easier stream management #281

@nallwhy

Description

@nallwhy

I’d like to propose adding an id field to the Message struct.

When using LangChain to build chat interfaces, it’s common to integrate with LiveView streams for real-time updates. However, the current Message struct doesn’t include an id, which forces developers to manually assign and manage IDs when using streams. This results in extra boilerplate, even though LangChain is intended to provide an abstraction layer.

Given that some providers (e.g., OpenAI) already include message IDs in their responses, we could directly use those IDs where available. For user-generated messages or cases where an ID is missing, a randomly generated UUID could be used to ensure all messages consistently have IDs.

This addition would make it easier to use LiveView streams without additional effort, while keeping LangChain’s abstractions clean and developer-friendly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions