Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(core): add as_message_state and to_message_state utilities with tests#34089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Emmanuel-Arokiaraj wants to merge2 commits intolangchain-ai:master
base:master
Choose a base branch
Loading
fromEmmanuel-Arokiaraj:emman/message-state-helpers

Conversation

@Emmanuel-Arokiaraj
Copy link

Description

This PR introduces two new utility helpers,as_message_state andto_message_state,
to normalize LangChainBaseMessage objects into a consistent message-state format.
These helpers simplify handling of different return types from LLM calls (e.g.,
strings, lists, AIMessage, SystemMessage, dict forms, etc.) and ensure that
message state is returned in a structured list format.

Additionally, this PR includes accompanying unit tests validating conversions
across all supported message types.

Key additions

  • as_message_state andto_message_state utility functions
  • Normalization support for:
    • AIMessage,HumanMessage,SystemMessage
    • Rawstr
    • BaseMessage
    • list of mixed message objects
    • dict containing amessages key
  • Unit tests covering typical and edge cases

Issue

Fixes#34061 (message normalization utilities discussion)

Dependencies

None

@github-actionsgithub-actionsbot added feature coreRelated to the package `langchain-core` and removed feature labelsNov 24, 2025
@codspeed-hq
Copy link

CodSpeed Performance Report

Merging#34089 willnot alter performance

ComparingEmmanuel-Arokiaraj:emman/message-state-helpers (7ac5a24) withmaster (eb0545a)

⚠️Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend usingCodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched
⏩ 21 skipped1

Footnotes

  1. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase,click here and archive them to remove them from the performance reports.

@davicaetano
Copy link

Thanks for the effort here.

Just for context: the intended workflow is usually to discuss the problem and the proposed approach in the issue before jumping into an implementation. I already have a working implementation locally and was waiting for feedback or approval from the maintainers on the design direction before opening my PR.

To keep the conversation structured, it would be best to move the technical discussion back to the issue so we can align on the expected behavior and API before finalizing any implementation.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@eyurtseveyurtsevAwaiting requested review from eyurtseveyurtsev is a code owner

Assignees

No one assigned

Labels

coreRelated to the package `langchain-core`

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Feature Request:to_message_state() andas_message_state() helpers

3 participants

@Emmanuel-Arokiaraj@davicaetano@Emmanuel-A-SDE

[8]ページ先頭

©2009-2025 Movatter.jp