-
Notifications
You must be signed in to change notification settings - Fork 502
fix: use API key environment variables during model initialization #1250
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
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 addresses an issue where the API key environment variable was validated but ignored during LLM initialization. Key changes include:
- Adding the _prepare_model_kwargs() helper to extract the API key from environment variables.
- Refactoring _init_llms() to use the new helper and remove duplicated logic.
- Updating tests to verify correct API key handling in both main and non‐main models.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
tests/test_llmrails.py | Adds tests to validate API key extraction from environment variables and graceful handling when missing. |
nemoguardrails/rails/llm/llmrails.py | Introduces _prepare_model_kwargs(), removes duplicate env var lookup code in _init_llms(), and updates LLM initialization accordingly. |
fix related to #1221 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1250 +/- ##
===========================================
+ Coverage 69.51% 69.54% +0.02%
===========================================
Files 161 161
Lines 16013 16016 +3
===========================================
+ Hits 11132 11138 +6
+ Misses 4881 4878 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
efe792a
to
4be0ce0
Compare
- Add _prepare_model_kwargs() helper to handle API key env vars - Fix duplication in _init_llms() method - Update output parsers to return list instead of tuple - Update self-check actions for new parser interface - Add comprehensive tests for API key functionality Fixes issue where api_key_env_var was validated but ignored during LLM initializationix: use API key environment variables during model initialization- Add _prepare_model_kwargs() helper to handle API key env vars- Fix duplication in _init_llms() method- Update output parsers to return list instead of tuple- Update self-check actions for new parser interface- Add comprehensive tests for API key functionalityFixes issue where api_key_env_var was validated but ignored during LLM initialization
a8bb5cc
to
209cf9d
Compare
Fixes issue where api_key_env_var was validated but ignored during LLM initialization