-
Notifications
You must be signed in to change notification settings - Fork 19.6k
fix(core): applied secrets_map in load to plain string values
#33678
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
fix(core): applied secrets_map in load to plain string values
#33678
Conversation
CodSpeed Performance ReportMerging #33678 will not alter performanceComparing
|
|
Apologies for any confusion thanks to my last PR. Now, hopefully everything should be working fine. I'm still learning how to do open source contributions, so please let me know if there are any issues. |
secrets_map in load to plain string values
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 adds support for string-based secret placeholders in the load() function, allowing secrets to be referenced directly as string values (e.g., "__SECRET_API_KEY__") in addition to the existing structured secret format ({"lc": 1, "type": "secret", "id": ["KEY"]}).
Key Changes:
- Enhanced
_load()function to check if string values match keys insecrets_mapand replace them with the corresponding secret values - Added a test case demonstrating the new string secret replacement functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| libs/core/langchain_core/load/load.py | Adds string placeholder support by checking if any string value in the object tree matches a key in secrets_map and replacing it with the secret value |
| libs/langchain/tests/unit_tests/load/test_load.py | Adds basic test case for the new string secrets feature with a simple dictionary example |
Replaces #33618
Description: Fixes the bug in the
load()function where secret placeholders in plain dicts were not replaced, even if they match a key insecrets_map, and adds a test case.Example:
Before this change, printing
api_keyinresultwould output"__SECRET_API_KEY__". Now, it will properly output"secret_key_1234".Issue: Fixes #31804
Dependencies: None
make format,make lint, andmake testhave all passed on my machine.