mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-22 02:45:49 +00:00
core[patch]: substantially speed up @deprecated (#29016)
Resolves https://github.com/langchain-ai/langchain/issues/26918 Unit tests don't raise any additional `LangChainDeprecationWarning`. Would like guidance on how to test this more thoroughly if needed. Note: speed up for `bind_tools` path is shown below. This is **redundant** with the speedup in https://github.com/langchain-ai/langchain/pull/29015. I include it for demonstration purposes. Before:  After: 
This commit is contained in:
parent
4bb391fd4e
commit
85403bfa99
@ -14,10 +14,9 @@ def is_caller_internal(depth: int = 2) -> bool:
|
|||||||
frame = frame.f_back
|
frame = frame.f_back
|
||||||
if frame is None:
|
if frame is None:
|
||||||
return False
|
return False
|
||||||
caller_module = inspect.getmodule(frame)
|
# Directly access the module name from the frame's global variables
|
||||||
if caller_module is None:
|
module_globals = frame.f_globals
|
||||||
return False
|
caller_module_name = module_globals.get("__name__", "")
|
||||||
caller_module_name = caller_module.__name__
|
|
||||||
return caller_module_name.startswith("langchain")
|
return caller_module_name.startswith("langchain")
|
||||||
finally:
|
finally:
|
||||||
del frame
|
del frame
|
||||||
|
Loading…
Reference in New Issue
Block a user