With the results from the search at hand, it is now possible to generate a prompt to send to the LLM. The prompt must include the original question sent by the user, the relevant passages that were obtained in the retrieval phase, and instructions to the LLM stating that the answer should come from the included passages.
To render the prompt, the application uses Flask's render_template()
function:
The template file that is referenced in this call is in api/templates/rag_prompt.txt.
You can make changes to this template if you'd like to see their effect in the quality of the chatbot responses. But always make sure to preserve the for-loop that renders the retrieved passages.
Previously
Retrieval PhaseNext
Generation Phase