Final Response
The response from the tool used to process the final instruction may not be human-friendly, only containing a single number or such.
Therefore, the response must be passed through another tool to format it properly.
def final(llm, query, answer):
template = """
You have been given the following query and you know its answer as well. Formulate an appropriate response to the query based on this answer.
---
##Instructions
1. Correct any spelling and grammatical (punctuation, etc) errors.
<any other instructions>
---
---
##Examples
<appropriate examples>
---
##Query
{query}
##Answer
{answer}
---
"""
prompt_template = PromptTemplate(input_variables=["query", "answer"], template=template)
return llm.invoke(prompt_template.format(query=query, answer=answer)).content