mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-12-06 07:12:10 +01:00
UI: Add a greeting when the chat history is empty
This commit is contained in:
parent
8f2493cc60
commit
a90df27ff5
|
|
@ -1299,3 +1299,12 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
|
|||
.dark .tgw-accordion {
|
||||
border: 1px solid var(--border-color-dark);
|
||||
}
|
||||
|
||||
.welcome-greeting {
|
||||
text-align: center;
|
||||
margin-top: 35vh;
|
||||
font-size: 24px;
|
||||
opacity: 0.6;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import datetime
|
||||
import functools
|
||||
import html
|
||||
import os
|
||||
|
|
@ -389,8 +390,21 @@ def generate_chat_html(history, name1, name2, reset_cache=False):
|
|||
return output
|
||||
|
||||
|
||||
def time_greeting():
|
||||
current_hour = datetime.datetime.now().hour
|
||||
if 5 <= current_hour < 12:
|
||||
return "Good morning!"
|
||||
elif 12 <= current_hour < 18:
|
||||
return "Good afternoon!"
|
||||
else:
|
||||
return "Good evening!"
|
||||
|
||||
|
||||
def chat_html_wrapper(history, name1, name2, mode, style, character, reset_cache=False):
|
||||
if mode == 'instruct':
|
||||
if len(history['visible']) == 0:
|
||||
greeting = f"<div class=\"welcome-greeting\">{time_greeting()} How can I help you today?</div>"
|
||||
result = f'<div class="chat" id="chat">{greeting}</div>'
|
||||
elif mode == 'instruct':
|
||||
result = generate_instruct_html(history)
|
||||
elif style == 'wpp':
|
||||
result = generate_chat_html(history, name1, name2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue