-
Notifications
You must be signed in to change notification settings - Fork 548
feat(runnable-rails): implement AIMessage metadata parity in RunnableRails #1369
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8309931
to
8e1033c
Compare
1c5837e
to
6a6050b
Compare
7ae2f3a
to
68f438e
Compare
ce4d6c1
to
0b114ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements AIMessage metadata parity in RunnableRails by ensuring that LLM metadata (response_metadata, usage_metadata, additional_kwargs, id) from the underlying LLM is preserved and passed through to the final AIMessage responses. This enables consistent behavior when using RunnableRails within LangChain chains.
- Adds metadata preservation infrastructure to capture and store LLM response metadata
- Updates RunnableRails output formatting to include preserved metadata in AIMessage responses
- Adds comprehensive test coverage for metadata preservation scenarios
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/runnable_rails/test_runnable_rails.py | Adds integration test to verify metadata preservation through RunnableRails |
tests/runnable_rails/test_metadata.py | Comprehensive test suite for metadata preservation with various input/output formats |
nemoguardrails/rails/llm/options.py | Adds llm_metadata field to GenerationResponse to store LLM metadata |
nemoguardrails/rails/llm/llmrails.py | Updates to include llm_metadata in generation responses |
nemoguardrails/integrations/langchain/runnable_rails.py | Updates output formatting methods to include metadata in AIMessage creation |
nemoguardrails/context.py | Adds context variable for storing LLM response metadata |
nemoguardrails/actions/llm/utils.py | Adds function to store and retrieve LLM response metadata |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
feb4447
to
0c2a65e
Compare
0b114ba
to
0e0ea4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
0c2a65e
to
a223dc3
Compare
…Rails Ensure AIMessage responses from RunnableRails contain the same metadata fields (response_metadata, usage_metadata, additional_kwargs, id) as direct LLM calls, enabling consistent LangChain integration behavior.
0e0ea4f
to
00589c2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…Rails (#1369) Ensure AIMessage responses from RunnableRails contain the same metadata fields (response_metadata, usage_metadata, additional_kwargs, id) as direct LLM calls, enabling consistent LangChain integration behavior.
…Rails (#1369) Ensure AIMessage responses from RunnableRails contain the same metadata fields (response_metadata, usage_metadata, additional_kwargs, id) as direct LLM calls, enabling consistent LangChain integration behavior.
…Rails (#1369) Ensure AIMessage responses from RunnableRails contain the same metadata fields (response_metadata, usage_metadata, additional_kwargs, id) as direct LLM calls, enabling consistent LangChain integration behavior.
Ensure AIMessage responses from RunnableRails contain the same metadata fields (response_metadata, usage_metadata, additional_kwargs, id) as direct LLM calls, enabling consistent LangChain integration behavior.