🐛 fix(loading.py): convert retriever to retriever object if it has "as_retriever" method
The code now checks if the "retriever" key exists in the params dictionary and if the value has an "as_retriever" method. If it does, the value is replaced with the result of calling the "as_retriever" method. This change ensures that the "retriever" parameter is always an instance of the retriever object, preventing potential attribute errors later in the code.
This commit is contained in:
parent
45dfa30851
commit
d39bea6e85
1 changed files with 2 additions and 0 deletions
|
|
@ -100,6 +100,8 @@ def instantiate_llm(node_type, class_object, params: Dict):
|
|||
|
||||
def instantiate_memory(node_type, class_object, params):
|
||||
try:
|
||||
if "retriever" in params and hasattr(params["retriever"], "as_retriever"):
|
||||
params["retriever"] = params["retriever"].as_retriever()
|
||||
return class_object(**params)
|
||||
# I want to catch a specific attribute error that happens
|
||||
# when the object does not have a cursor attribute
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue