Skip to content

Commit

Permalink
add parameters to welcome message
Browse files Browse the repository at this point in the history
  • Loading branch information
jianchuanqi committed Oct 27, 2023
1 parent 3731d6e commit 3a5112f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ui/tiangong-en.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"current_chat_title": "Chat History :",
"chat_ai_avatar": "src/static/logo.png",
"chat_user_avatar": "src/static/user.png",
"chat_ai_welcome": "How can I help you?",
"chat_ai_welcome": "Hi {username}! You are on {subscription} plan. What do you want to know?",
"chat_human_placeholder": "Ask me anything, in any language you like!",
"sidebar_newchat_button_label": "New Chat",
"sidebar_delete_button_label": "Delete Chat",
Expand Down
13 changes: 12 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,13 +1346,24 @@ def your_function():
)
# to show chat history on ui
if "messages" not in st.session_state:
if "subscription" in st.session_state:
welcome_message = ui.chat_ai_welcome.format(
username=st.session_state["username"].split("@")[0],
subscription=st.session_state["subsription"],
)
else:
welcome_message = ui.chat_ai_welcome.format(
username="there", subscription="free"
)

st.session_state["messages"] = [
{
"role": "assistant",
"avatar": ui.chat_ai_avatar,
"content": ui.chat_ai_welcome,
"content": welcome_message,
}
]

for msg in st.session_state["messages"]:
st.chat_message(msg["role"], avatar=msg["avatar"]).write(msg["content"])

Expand Down

0 comments on commit 3a5112f

Please sign in to comment.