Skip to content

Conversation

@psschwei
Copy link
Member

@psschwei psschwei commented Jan 27, 2026

Misc PR

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

Adds support for converting LangChain messages to Mellea Message types and validating LangChain agent outputs using Mellea's native validation API, addressing #255.

Changes

  • Added mellea/stdlib/components/chat_converters.py with conversion functions for LangChain message types (HumanMessage, AIMessage, SystemMessage, ToolMessage)
  • Supports multimodal content (images via base64 data URIs)
  • Provides two conversion strategies: direct parsing and via OpenAI intermediate format
  • Added langchain-core as optional dependency: pip install "mellea[langchain]"
  • Added Jupyter notebook docs/examples/library_interop/langchain_mellea_ivr.ipynb demonstrating validation of LangChain agent outputs

Usage

from langchain_core.messages import HumanMessage, AIMessage
from mellea.stdlib.components.chat_converters import langchain_messages_to_mellea
from mellea.core.base import ModelOutputThunk
from mellea.stdlib.context import ChatContext
import mellea

lc_messages = [HumanMessage(content="Hello!"), AIMessage(content="The answer is 7.")]
mellea_messages = langchain_messages_to_mellea(lc_messages[:-1])

# Validate LangChain output with Mellea's native API
ctx = ChatContext()
for msg in mellea_messages:
    ctx = ctx.add(msg)
ctx = ctx.add(ModelOutputThunk(value=lc_messages[-1].content))

m = mellea.start_session(ctx=ctx)
validations = m.validate([req("The answer must be greater than 5")])

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code as added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Signed-off-by: Paul S. Schweigert <paul@paulschweigert.com>
@github-actions
Copy link
Contributor

The PR description has been updated. Please fill out the template for your PR to be reviewed.

@mergify
Copy link

mergify bot commented Jan 27, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

@psschwei psschwei marked this pull request as draft January 27, 2026 16:14
Signed-off-by: Paul S. Schweigert <paul@paulschweigert.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant