-
Notifications
You must be signed in to change notification settings - Fork 538
feat(runnable_rails): complete rewrite of RunnableRails with full LangChain Runnable protocol support #1366
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
base: develop
Are you sure you want to change the base?
Conversation
Documentation preview |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1366 +/- ##
===========================================
- Coverage 71.66% 71.65% -0.01%
===========================================
Files 171 171
Lines 17015 17313 +298
===========================================
+ Hits 12193 12406 +213
- Misses 4822 4907 +85
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
34dba2b
to
7ae2f3a
Compare
7ae2f3a
to
68f438e
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 completes a full rewrite of RunnableRails with comprehensive LangChain Runnable protocol support, providing async/sync operations, streaming capabilities, tool calling functionality, and enhanced input/output handling.
- Implemented complete LangChain Runnable protocol including invoke, batch, stream, and async variants
- Added tool calling support with proper context variable management across the pipeline
- Enhanced streaming functionality with proper chunk formatting and state management
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 9 comments.
Show a summary per file
File | Description |
---|---|
tests/utils.py | Added streaming support to FakeLLM with _stream and _astream methods |
tests/test_tool_calls_context.py | New test file for tool calls context variable functionality |
tests/test_tool_calling_utils.py | New comprehensive tests for tool calling utility functions |
tests/test_tool_calling_passthrough_integration.py | Integration tests for tool calling in passthrough mode |
tests/runnable_rails/*.py | 14 new test files covering streaming, batching, composition, and tool calling |
nemoguardrails/rails/llm/options.py | Added tool_calls field to GenerationResponse model |
nemoguardrails/rails/llm/llmrails.py | Enhanced to extract and include tool calls in responses |
nemoguardrails/logging/verbose.py | Fixed potential AttributeError with missing record attributes |
nemoguardrails/integrations/langchain/runnable_rails.py | Complete rewrite implementing full Runnable protocol |
nemoguardrails/context.py | Added tool_calls_var context variable |
nemoguardrails/actions/llm/utils.py | Refactored llm_call with tool calling support and improved message handling |
examples/configs/nemoguards/* | New example configuration demonstrating NeMoGuard safety rails |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
68f438e
to
942772d
Compare
Implements tool call extraction and passthrough functionality in LLMRails: - Add tool_calls_var context variable for storing LLM tool calls - Refactor llm_call utils to extract and store tool calls from responses - Support tool calls in both GenerationResponse and dict message formats - Add ToolMessage support for langchain message conversion - Comprehensive test coverage for tool calling integration
Add example configuration and documentation for using NVIDIA NeMoGuard NIMs, including content moderation, topic control, and jailbreak detection.
Update verbose logging to safely handle cases where log records may not have 'id' or 'task' attributes. Prevents potential AttributeError and improves robustness of LLM and prompt log output formatting.
Implements tool call extraction and passthrough functionality in LLMRails: - Add tool_calls_var context variable for storing LLM tool calls - Refactor llm_call utils to extract and store tool calls from responses - Support tool calls in both GenerationResponse and dict message formats - Add ToolMessage support for langchain message conversion - Comprehensive test coverage for tool calling integration
942772d
to
a33a388
Compare
… Runnable protocol support - Implement comprehensive async/sync invoke, batch, and streaming support - Add robust input/output transformation for all LangChain formats (ChatPromptValue, BaseMessage, dict, string) - Enhance chaining behavior with intelligent __or__ method handling RunnableBinding and complex chains - Add concurrency controls, error handling, and configurable blocking messages - Implement proper tool calling support with tool call passthrough - Add extensive test suite (14 test files, 2800+ lines) covering all major functionality including batching, streaming, composition, piping, and tool calling - Reorganize and expand test structure for better maintainability apply review suggestions
feb4447
to
0c2a65e
Compare
Description
requires #1364 and #1343 and #1289