Spaces:
Sleeping
Sleeping
Commit ·
d2acb08
1
Parent(s): 73e3152
Update app.py
Browse files
app.py
CHANGED
|
@@ -70,7 +70,41 @@ def reverse_name_to_role(name):
|
|
| 70 |
|
| 71 |
st.sidebar.title("Sidebar")
|
| 72 |
|
| 73 |
-
if st.sidebar.button('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
with st.chat_message(name_to_role('tutor')): # tutor
|
| 75 |
# assistant == tutor
|
| 76 |
message_placeholder = st.empty()
|
|
|
|
| 70 |
|
| 71 |
st.sidebar.title("Sidebar")
|
| 72 |
|
| 73 |
+
if st.sidebar.button('Introduction/Conversation'):
|
| 74 |
+
with st.chat_message(name_to_role('tutor')): # tutor
|
| 75 |
+
# assistant == tutor
|
| 76 |
+
message_placeholder = st.empty()
|
| 77 |
+
full_response = ""
|
| 78 |
+
for response in openai.ChatCompletion.create(
|
| 79 |
+
model=st.session_state["openai_model"],
|
| 80 |
+
messages=[ st.session_state.tutor_message_system_prompt ] + [
|
| 81 |
+
{ "role": name_to_role(m["name"]), "content": m["content"] }
|
| 82 |
+
for m in st.session_state.messages
|
| 83 |
+
],
|
| 84 |
+
stream=True,
|
| 85 |
+
api_key=API_KEY
|
| 86 |
+
):
|
| 87 |
+
full_response += response.choices[0].delta.get("content", "")
|
| 88 |
+
st.sidebar.success(full_response)
|
| 89 |
+
|
| 90 |
+
if st.sidebar.button('Encouragement'):
|
| 91 |
+
with st.chat_message(name_to_role('tutor')): # tutor
|
| 92 |
+
# assistant == tutor
|
| 93 |
+
message_placeholder = st.empty()
|
| 94 |
+
full_response = ""
|
| 95 |
+
for response in openai.ChatCompletion.create(
|
| 96 |
+
model=st.session_state["openai_model"],
|
| 97 |
+
messages=[ st.session_state.tutor_message_system_prompt ] + [
|
| 98 |
+
{ "role": name_to_role(m["name"]), "content": m["content"] }
|
| 99 |
+
for m in st.session_state.messages
|
| 100 |
+
],
|
| 101 |
+
stream=True,
|
| 102 |
+
api_key=API_KEY
|
| 103 |
+
):
|
| 104 |
+
full_response += response.choices[0].delta.get("content", "")
|
| 105 |
+
st.sidebar.success(full_response)
|
| 106 |
+
|
| 107 |
+
if st.sidebar.button('Conclude Session'):
|
| 108 |
with st.chat_message(name_to_role('tutor')): # tutor
|
| 109 |
# assistant == tutor
|
| 110 |
message_placeholder = st.empty()
|