This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is the generator function that streams back to the client with htmx SSE | |
async def process_and_stream_rag_response(user_query, search_terms, message_id, role="assistant"): | |
final_output = "" # Initialize an empty string to store the final output | |
async for text in retrieval_augmented_generation(user_query, search_terms): | |
# Convert the text from Markdown to HTML for each chunk | |
text_html = markdown.markdown(text, extensions=['tables', 'footnotes', 'fenced_code']) | |
# Apply nl2br_table to convert newlines to <br> tags in the HTML text |