fix: added conditions to check for attributes
This commit is contained in:
parent
d4ed1eb629
commit
808e702b30
1 changed files with 7 additions and 9 deletions
|
|
@ -115,12 +115,10 @@ def fix_memory_inputs(langchain_object):
|
||||||
object's input variables. If so, it does nothing. Otherwise, it gets a possible new memory key using the
|
object's input variables. If so, it does nothing. Otherwise, it gets a possible new memory key using the
|
||||||
get_memory_key function and updates the memory keys using the update_memory_keys function.
|
get_memory_key function and updates the memory keys using the update_memory_keys function.
|
||||||
"""
|
"""
|
||||||
if (
|
if hasattr(langchain_object, "memory") and langchain_object.memory is not None:
|
||||||
hasattr(langchain_object, "memory")
|
if langchain_object.memory.memory_key in langchain_object.input_variables:
|
||||||
and langchain_object.memory is not None
|
|
||||||
and langchain_object.memory.memory_key in langchain_object.input_variables
|
|
||||||
):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
possible_new_mem_key = get_memory_key(langchain_object)
|
possible_new_mem_key = get_memory_key(langchain_object)
|
||||||
if possible_new_mem_key is not None:
|
if possible_new_mem_key is not None:
|
||||||
update_memory_keys(langchain_object, possible_new_mem_key)
|
update_memory_keys(langchain_object, possible_new_mem_key)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue