🐛 fix(prompt_runner.py): fix issue with accessing result content when invoking chain with an empty dict input

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-04 00:20:16 -03:00
commit 0cf1fb09a9

View file

@ -25,7 +25,9 @@ class PromptRunner(CustomComponent):
prompt: PromptTemplate,
) -> Document:
chain = prompt | llm
result = chain.invoke()
result = result[chain.output_key]
# The input is an empty dict because the prompt is already filled
result = chain.invoke({})
if hasattr(result, "content"):
result = result.content
self.repr_value = result
return Document(page_content=str(result))