Skip to content

Instantly share code, notes, and snippets.

View halfprice06's full-sized avatar

gooby_esq halfprice06

View GitHub Profile
import timeit
def original():
for i in range(1, 101):
fizz = i % 3
buzz = i % 5
fizzbuzz = i % 15
if fizzbuzz == 0:
print(f"{i} = fizzbuzz")
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