ogegadavis254
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,20 @@ def reset_conversation():
|
|
12 |
st.session_state.messages = []
|
13 |
return None
|
14 |
|
15 |
-
# Define model
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
all_messages = []
|
21 |
|
22 |
if not messages: # If history is empty
|
@@ -56,7 +65,9 @@ def interact_with_together_api(messages):
|
|
56 |
|
57 |
return assistant_response
|
58 |
|
59 |
-
# Create sidebar with reset button
|
|
|
|
|
60 |
st.sidebar.button('Reset Chat', on_click=reset_conversation)
|
61 |
|
62 |
# Initialize chat history
|
@@ -69,15 +80,15 @@ for message in st.session_state.messages:
|
|
69 |
st.markdown(message[1])
|
70 |
|
71 |
# Accept user input
|
72 |
-
if prompt := st.chat_input("Hi, I'm
|
73 |
# Display user message in chat message container
|
74 |
with st.chat_message("user"):
|
75 |
st.markdown(prompt)
|
76 |
# Add user message to chat history
|
77 |
st.session_state.messages.append(("user", prompt))
|
78 |
|
79 |
-
# Interact with the
|
80 |
-
assistant_response = interact_with_together_api(st.session_state.messages)
|
81 |
|
82 |
# Display assistant response in chat message container
|
83 |
with st.empty():
|
|
|
12 |
st.session_state.messages = []
|
13 |
return None
|
14 |
|
15 |
+
# Define model links for the Addiction Recovery and Mental Health models
|
16 |
+
model_links = {
|
17 |
+
"Addiction recovery AI": "NousResearch/Nous-Hermes-2-Yi-34B",
|
18 |
+
"Mental health AI": "NousResearch/Nous-Hermes-2-Yi-34B"
|
19 |
+
}
|
20 |
+
|
21 |
+
# Define pre-instructions for each model
|
22 |
+
model_pre_instructions = {
|
23 |
+
"Addiction recovery AI": "This AI is trained to provide support and guidance related to addiction recovery.",
|
24 |
+
"Mental health AI": "This AI is trained to provide support and guidance related to mental health."
|
25 |
+
}
|
26 |
+
|
27 |
+
# Function to interact with the selected model via the Together API
|
28 |
+
def interact_with_together_api(messages, model_link):
|
29 |
all_messages = []
|
30 |
|
31 |
if not messages: # If history is empty
|
|
|
65 |
|
66 |
return assistant_response
|
67 |
|
68 |
+
# Create sidebar with model selection dropdown and reset button
|
69 |
+
selected_model = st.sidebar.selectbox("Select Model", list(model_links.keys()))
|
70 |
+
st.sidebar.write(f"Pre-Instructions: {model_pre_instructions[selected_model]}")
|
71 |
st.sidebar.button('Reset Chat', on_click=reset_conversation)
|
72 |
|
73 |
# Initialize chat history
|
|
|
80 |
st.markdown(message[1])
|
81 |
|
82 |
# Accept user input
|
83 |
+
if prompt := st.chat_input(f"Hi, I'm {selected_model}, ask me a question"):
|
84 |
# Display user message in chat message container
|
85 |
with st.chat_message("user"):
|
86 |
st.markdown(prompt)
|
87 |
# Add user message to chat history
|
88 |
st.session_state.messages.append(("user", prompt))
|
89 |
|
90 |
+
# Interact with the selected model
|
91 |
+
assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])
|
92 |
|
93 |
# Display assistant response in chat message container
|
94 |
with st.empty():
|