-
Notifications
You must be signed in to change notification settings - Fork 16.8k
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
Deprecate direct access to globals like debug
and verbose
.
#11311
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Still needs:
|
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.
seems reasonable, lets update all the docs (and internal usage) that do langchain.verbose=True
to use these
debug
and verbose
to their own module.debug
and verbose
.
…langchain into pg/move_globals_to_own_module
libs/langchain/langchain/__init__.py
Outdated
def __setattr__(name, value): | ||
print("foo") | ||
if name == 'debug' and value is True: | ||
warnings.warn("Debug mode is enabled in LangChain", UserWarning) | ||
globals()[name] = value |
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.
I also tried this sort of thing and hoped it would work, but no luck.
PEP 562 which defines the module-level __getattr__()
doesn't allow for a __setattr__()
so I don't think this ever gets called: https://peps.python.org/pep-0562/
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.
ah whoops i tried this out, it didnt work, and i forgot to remove 🤦
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.
Thanks for updating the docs, I completely forgot they are in the same repo. Will keep in mind for the future.
Any idea how to remove this warning, it appear after each message:
|
I believe this might have been fixed in a subsequent PR, though I'm not exactly sure if it was already released or not yet. Please try upgrading langchain, and if the problem persists consider opening a new issue for it. |
…hain-ai#11311) Instead of accessing `langchain.debug`, `langchain.verbose`, or `langchain.llm_cache`, please use the new getter/setter functions in `langchain.globals`: - `langchain.globals.set_debug()` and `langchain.globals.get_debug()` - `langchain.globals.set_verbose()` and `langchain.globals.get_verbose()` - `langchain.globals.set_llm_cache()` and `langchain.globals.get_llm_cache()` Using the old globals directly will now raise a warning. --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
Instead of accessing
langchain.debug
,langchain.verbose
, orlangchain.llm_cache
, please use the new getter/setter functions inlangchain.globals
:langchain.globals.set_debug()
andlangchain.globals.get_debug()
langchain.globals.set_verbose()
andlangchain.globals.get_verbose()
langchain.globals.set_llm_cache()
andlangchain.globals.get_llm_cache()
Using the old globals directly will now raise a warning.