🐛 fix(utils.py): add condition to check if langchain_object.prompt has a template attribute before adding it to input_keys_response

The code now checks if the langchain_object.prompt has a template attribute before adding it to the input_keys_response. This prevents potential errors if the template attribute is not present in the prompt object.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-30 18:27:56 -03:00
commit 47f9d78a86

View file

@ -51,7 +51,9 @@ def build_input_keys_response(langchain_object, artifacts):
# Add memory variables to memory_keys
input_keys_response["memory_keys"] = langchain_object.memory.memory_variables
if hasattr(langchain_object, "prompt"):
if hasattr(langchain_object, "prompt") and hasattr(
langchain_object.prompt, "template"
):
input_keys_response["template"] = langchain_object.prompt.template
return input_keys_response