UI: Add a greeting when the chat history is empty

This commit is contained in:
oobabooga 2025-04-24 20:33:40 -07:00
parent 8f2493cc60
commit a90df27ff5
2 changed files with 24 additions and 1 deletions

View file

@ -1299,3 +1299,12 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
.dark .tgw-accordion { .dark .tgw-accordion {
border: 1px solid var(--border-color-dark); 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;
}

View file

@ -1,3 +1,4 @@
import datetime
import functools import functools
import html import html
import os import os
@ -389,8 +390,21 @@ def generate_chat_html(history, name1, name2, reset_cache=False):
return output 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): 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) result = generate_instruct_html(history)
elif style == 'wpp': elif style == 'wpp':
result = generate_chat_html(history, name1, name2) result = generate_chat_html(history, name1, name2)