Skip to content

Commit

Permalink
Update royal_game_6_1.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Hutchinson committed Jun 25, 2023
1 parent 650cf25 commit 79f3d11
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions royal_game_6_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,32 +469,11 @@ def count_tokens(chain, query):
st.write(conversation_string)

# original code - don't delete
#with response_container:
# for speaker, msg in st.session_state['conversation']:
# message(msg, is_user=(speaker == 'User'))

def avatar_message(msg, is_user=True, avatar=None, key=None):
if avatar is None:
avatar = user_avatar if is_user else bot_avatar
avatar_tag = f'<img src="{avatar}" width="24" height="24" style="border-radius: 50%; margin-right: 6px" />'
msg_with_avatar = f"""{avatar_tag} {msg}"""
st.markdown(msg_with_avatar, unsafe_allow_html=True)
with response_container:
for speaker, msg in st.session_state['conversation']:
message(msg, is_user=(speaker == 'User'))

user_avatar = "http://danielhutchinson.org/wp-content/uploads/2023/06/adventurer-1687703427277.png"
bot_avatar = "http://danielhutchinson.org/wp-content/uploads/2023/06/king.png"
chatgpt_avatar = "http://danielhutchinson.org/wp-content/uploads/2022/11/cropped-DALL·E-2022-08-08-05.19.52-circular-logo-featuring-an-illustrated-profile-of-a-friendly-robot-wearing-academic-regalia-no-text.png"

with response_container:
for i, (speaker, msg) in enumerate(st.session_state['conversation']):
if speaker == 'User':
# Display User messages
message(msg, is_user=True, key=f"{i}_user")
elif speaker == 'Bot':
# Display Bot messages
message(msg, is_user=False, key=f"{i}_bot", style={"background-color": "#e0e0e0", "border-radius": "5px", "padding": "10px"})
elif speaker == 'ChatGPT':
# Display ChatGPT messages
message(msg, is_user=False, key=f"{i}_gpt", style={"background-color": "#f0f0f0", "border-radius": "5px", "padding": "10px"})

with st.form(key='quiz_form'):
st.header("Quiz Submission:")
Expand Down

0 comments on commit 79f3d11

Please sign in to comment.