Result post-processing
After receiving the response from the language model, it is often desirable to present the output in a more structured and visually appealing format. Markdown is a lightweight markup language that allows you to add formatting elements such as headings, lists, code blocks, and more. In this example, we use Markdown formatting to enhance the presentation of the question, answer, and context:
#In this section you can format the answer for example with markdown
formatted_result = f"###Question:\n{question}\n\n###Answer:\n{result.text}\n\n<details><summary>Context</summary>{context}</details>"
The breakdown of the components of this formatting is:
"###Question:\n{question}"
This part adds a level 3 Markdown heading (###
) for the Question
section, followed by the user’s original query ({question}
) on a new line (\n
).
"\n\n###Answer:\n{result.text}"
After adding...