From edec3bf3b0dadaf78342479659e0c7711eab347b Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Wed, 13 Mar 2024 08:14:34 -0700 Subject: [PATCH] UI: avoid caching convert_to_markdown calls during streaming --- modules/html_generator.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/html_generator.py b/modules/html_generator.py index 86771dcf..902ffcc7 100644 --- a/modules/html_generator.py +++ b/modules/html_generator.py @@ -101,6 +101,17 @@ def convert_to_markdown(string): return html_output +def convert_to_markdown_wrapped(string, use_cache=True): + ''' + Used to avoid caching convert_to_markdown calls during streaming. + ''' + + if use_cache: + return convert_to_markdown(string) + + return convert_to_markdown.__wrapped__(string) + + def generate_basic_html(string): string = convert_to_markdown(string) string = f'