chore: Convert result to string in LLMCheckerChain, LLMMathChain, RetrievalQA, RetrievalQAWithSourcesChain, and SQLExecutor components

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-06-22 13:52:52 -03:00
commit 789bdbb27e
5 changed files with 5 additions and 5 deletions

View file

@ -26,6 +26,6 @@ class LLMCheckerChainComponent(CustomComponent):
chain = LLMCheckerChain.from_llm(llm=llm)
response = chain.invoke({chain.input_key: input_value})
result = response.get(chain.output_key, "")
result_str = Text(result)
result_str = str(result)
self.status = result_str
return result_str

View file

@ -42,6 +42,6 @@ class LLMMathChainComponent(CustomComponent):
)
response = chain.invoke({input_key: input_value})
result = response.get(output_key)
result_str = Text(result)
result_str = str(result)
self.status = result_str
return result_str

View file

@ -63,6 +63,6 @@ class RetrievalQAComponent(CustomComponent):
references_str = self.create_references_from_data(data)
result_str = result.get("result", "")
final_result = "\n".join([Text(result_str), references_str])
final_result = "\n".join([str(result_str), references_str])
self.status = final_result
return final_result # OK

View file

@ -57,7 +57,7 @@ class RetrievalQAWithSourcesChainComponent(CustomComponent):
references_str = ""
if return_source_documents:
references_str = self.create_references_from_data(data)
result_str = Text(result.get("answer", ""))
result_str = str(result.get("answer", ""))
final_result = "\n".join([result_str, references_str])
self.status = final_result
return final_result

View file

@ -53,7 +53,7 @@ class SQLExecutorComponent(CustomComponent):
result = tool.run(query, include_columns=include_columns)
self.status = result
except Exception as e:
result = Text(e)
result = str(e)
self.status = result
if not passthrough:
raise e