mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-01-09 12:09:04 +01:00
UI: reduce the size of HTML sent to the UI during streaming
This commit is contained in:
parent
9f24885bd2
commit
0e673a7a42
@ -268,29 +268,24 @@ def generate_instruct_html(history):
|
|||||||
for i, _row in enumerate(history):
|
for i, _row in enumerate(history):
|
||||||
row = [convert_to_markdown_wrapped(entry, use_cache=i != len(history) - 1) for entry in _row]
|
row = [convert_to_markdown_wrapped(entry, use_cache=i != len(history) - 1) for entry in _row]
|
||||||
|
|
||||||
if row[0]: # don't display empty user messages
|
if row[0]: # Don't display empty user messages
|
||||||
output += f"""
|
output += (
|
||||||
<div class="user-message">
|
f'<div class="user-message">'
|
||||||
<div class="text">
|
f'<div class="text">'
|
||||||
<div class="message-body">
|
f'<div class="message-body">{row[0]}</div>'
|
||||||
{row[0]}
|
f'</div>'
|
||||||
</div>
|
f'</div>'
|
||||||
</div>
|
)
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
output += f"""
|
output += (
|
||||||
<div class="assistant-message">
|
f'<div class="assistant-message">'
|
||||||
<div class="text">
|
f'<div class="text">'
|
||||||
<div class="message-body">
|
f'<div class="message-body">{row[1]}</div>'
|
||||||
{row[1]}
|
f'</div>'
|
||||||
</div>
|
f'</div>'
|
||||||
</div>
|
)
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
output += "</div></div>"
|
output += "</div></div>"
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
@ -298,44 +293,39 @@ def generate_cai_chat_html(history, name1, name2, style, character, reset_cache=
|
|||||||
output = f'<style>{chat_styles[style]}</style><div class="chat" id="chat"><div class="messages">'
|
output = f'<style>{chat_styles[style]}</style><div class="chat" id="chat"><div class="messages">'
|
||||||
|
|
||||||
# We use ?character and ?time.time() to force the browser to reset caches
|
# We use ?character and ?time.time() to force the browser to reset caches
|
||||||
img_bot = f'<img src="file/cache/pfp_character_thumb.png?{character}" class="pfp_character">' if Path("cache/pfp_character_thumb.png").exists() else ''
|
img_bot = (
|
||||||
img_me = f'<img src="file/cache/pfp_me.png?{time.time() if reset_cache else ""}">' if Path("cache/pfp_me.png").exists() else ''
|
f'<img src="file/cache/pfp_character_thumb.png?{character}" class="pfp_character">'
|
||||||
|
if Path("cache/pfp_character_thumb.png").exists() else ''
|
||||||
|
)
|
||||||
|
|
||||||
|
img_me = (
|
||||||
|
f'<img src="file/cache/pfp_me.png?{time.time() if reset_cache else ""}">'
|
||||||
|
if Path("cache/pfp_me.png").exists() else ''
|
||||||
|
)
|
||||||
|
|
||||||
for i, _row in enumerate(history):
|
for i, _row in enumerate(history):
|
||||||
row = [convert_to_markdown_wrapped(entry, use_cache=i != len(history) - 1) for entry in _row]
|
row = [convert_to_markdown_wrapped(entry, use_cache=i != len(history) - 1) for entry in _row]
|
||||||
|
|
||||||
if row[0]: # don't display empty user messages
|
if row[0]: # Don't display empty user messages
|
||||||
output += f"""
|
output += (
|
||||||
<div class="message">
|
f'<div class="message">'
|
||||||
<div class="circle-you">
|
f'<div class="circle-you">{img_me}</div>'
|
||||||
{img_me}
|
f'<div class="text">'
|
||||||
</div>
|
f'<div class="username">{name1}</div>'
|
||||||
<div class="text">
|
f'<div class="message-body">{row[0]}</div>'
|
||||||
<div class="username">
|
f'</div>'
|
||||||
{name1}
|
f'</div>'
|
||||||
</div>
|
)
|
||||||
<div class="message-body">
|
|
||||||
{row[0]}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
output += f"""
|
output += (
|
||||||
<div class="message">
|
f'<div class="message">'
|
||||||
<div class="circle-bot">
|
f'<div class="circle-bot">{img_bot}</div>'
|
||||||
{img_bot}
|
f'<div class="text">'
|
||||||
</div>
|
f'<div class="username">{name2}</div>'
|
||||||
<div class="text">
|
f'<div class="message-body">{row[1]}</div>'
|
||||||
<div class="username">
|
f'</div>'
|
||||||
{name2}
|
f'</div>'
|
||||||
</div>
|
)
|
||||||
<div class="message-body">
|
|
||||||
{row[1]}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
output += "</div></div>"
|
output += "</div></div>"
|
||||||
return output
|
return output
|
||||||
@ -347,26 +337,22 @@ def generate_chat_html(history, name1, name2, reset_cache=False):
|
|||||||
for i, _row in enumerate(history):
|
for i, _row in enumerate(history):
|
||||||
row = [convert_to_markdown_wrapped(entry, use_cache=i != len(history) - 1) for entry in _row]
|
row = [convert_to_markdown_wrapped(entry, use_cache=i != len(history) - 1) for entry in _row]
|
||||||
|
|
||||||
if row[0]: # don't display empty user messages
|
if row[0]: # Don't display empty user messages
|
||||||
output += f"""
|
output += (
|
||||||
<div class="message">
|
f'<div class="message">'
|
||||||
<div class="text-you">
|
f'<div class="text-you">'
|
||||||
<div class="message-body">
|
f'<div class="message-body">{row[0]}</div>'
|
||||||
{row[0]}
|
f'</div>'
|
||||||
</div>
|
f'</div>'
|
||||||
</div>
|
)
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
output += f"""
|
output += (
|
||||||
<div class="message">
|
f'<div class="message">'
|
||||||
<div class="text-bot">
|
f'<div class="text-bot">'
|
||||||
<div class="message-body">
|
f'<div class="message-body">{row[1]}</div>'
|
||||||
{row[1]}
|
f'</div>'
|
||||||
</div>
|
f'</div>'
|
||||||
</div>
|
)
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
output += "</div></div>"
|
output += "</div></div>"
|
||||||
return output
|
return output
|
||||||
|
Loading…
Reference in New Issue
Block a user