🐛 fix(utils.py): handle_partial_variables now filters out partial variables with None values to prevent errors in LangChain

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-10-03 21:33:45 -03:00
commit f25e390e8c

View file

@ -49,7 +49,7 @@ def handle_format_kwargs(prompt, params: Dict):
def handle_partial_variables(prompt, format_kwargs: Dict): def handle_partial_variables(prompt, format_kwargs: Dict):
partial_variables = format_kwargs.copy() partial_variables = format_kwargs.copy()
partial_variables = { partial_variables = {
key: value for key, value in partial_variables.items() if value key: value for key, value in partial_variables.items() if value is not None
} }
# Remove handle_keys otherwise LangChain raises an error # Remove handle_keys otherwise LangChain raises an error
partial_variables.pop("handle_keys", None) partial_variables.pop("handle_keys", None)