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 860122a commit 416747b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion royal_game_6_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,31 @@ def count_tokens(chain, query):
st.write("Condition: Else")
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(text: str, is_user: bool = False, key: str = None, avatar: str = None):
if avatar:
msg_with_avatar = f'<img src="{avatar}" style="width: 24px; height: 24px;"> {text}'
message(msg_with_avatar, is_user=is_user, key=key, allow_html=True)
else:
message(text, is_user=is_user, key=key)

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 speaker, msg in st.session_state['conversation']:
message(msg, is_user=(speaker == 'User'))
if speaker == 'User':
avatar_message(msg, is_user=True, avatar=user_avatar)
elif speaker == 'Bot':
avatar_message(msg, is_user=False, avatar=bot_avatar)
else: #speaker == 'ChatGPT'
avatar_message(msg, is_user=False, avatar=chatgpt_avatar)



with st.form(key='quiz_form'):
Expand Down

0 comments on commit 416747b

Please sign in to comment.