ta_features
#13
by
ivnban27-ctl
- opened
- convosim.py +6 -8
- models/business_logic_utils/business_logic.py +3 -3
- models/business_logic_utils/config.py +37 -157
- models/business_logic_utils/response_processing.py +2 -5
- models/model_seeds.py +73 -160
- utils/mongo_utils.py +0 -10
convosim.py
CHANGED
@@ -2,7 +2,7 @@ import os
|
|
2 |
import streamlit as st
|
3 |
from streamlit.logger import get_logger
|
4 |
from langchain.schema.messages import HumanMessage
|
5 |
-
from utils.mongo_utils import get_db_client
|
6 |
from utils.app_utils import create_memory_add_initial_message, get_random_name, DEFAULT_NAMES_DF
|
7 |
from utils.memory_utils import clear_memory, push_convo2db
|
8 |
from utils.chain_utils import get_chain, custom_chain_predict
|
@@ -77,7 +77,7 @@ for msg in memoryA.buffer_as_messages:
|
|
77 |
role = "user" if type(msg) == HumanMessage else "assistant"
|
78 |
st.chat_message(role).write(msg.content)
|
79 |
|
80 |
-
if prompt := st.chat_input(): #account for next interaction
|
81 |
st.session_state['sent_messages'] += 1
|
82 |
st.chat_message("user").write(prompt)
|
83 |
if 'convo_id' not in st.session_state:
|
@@ -87,14 +87,12 @@ if prompt := st.chat_input(): #account for next interaction
|
|
87 |
# response = update_memory_completion(prompt, st.session_state["memory"], OA_engine, temperature)
|
88 |
for response in responses:
|
89 |
st.chat_message("assistant").write(response)
|
90 |
-
transcript = memoryA.load_memory_variables({})[memoryA.memory_key]
|
91 |
-
update_convo(st.session_state["db_client"], st.session_state["convo_id"], transcript)
|
92 |
|
93 |
st.session_state['total_messages'] = len(memoryA.chat_memory.messages)
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
with st.sidebar:
|
100 |
st.markdown(f"### Total Sent Messages: :red[**{st.session_state['sent_messages']}**]")
|
|
|
2 |
import streamlit as st
|
3 |
from streamlit.logger import get_logger
|
4 |
from langchain.schema.messages import HumanMessage
|
5 |
+
from utils.mongo_utils import get_db_client
|
6 |
from utils.app_utils import create_memory_add_initial_message, get_random_name, DEFAULT_NAMES_DF
|
7 |
from utils.memory_utils import clear_memory, push_convo2db
|
8 |
from utils.chain_utils import get_chain, custom_chain_predict
|
|
|
77 |
role = "user" if type(msg) == HumanMessage else "assistant"
|
78 |
st.chat_message(role).write(msg.content)
|
79 |
|
80 |
+
if prompt := st.chat_input(disabled=st.session_state['total_messages'] > MAX_MSG_COUNT - 4): #account for next interaction
|
81 |
st.session_state['sent_messages'] += 1
|
82 |
st.chat_message("user").write(prompt)
|
83 |
if 'convo_id' not in st.session_state:
|
|
|
87 |
# response = update_memory_completion(prompt, st.session_state["memory"], OA_engine, temperature)
|
88 |
for response in responses:
|
89 |
st.chat_message("assistant").write(response)
|
|
|
|
|
90 |
|
91 |
st.session_state['total_messages'] = len(memoryA.chat_memory.messages)
|
92 |
+
if st.session_state['total_messages'] >= MAX_MSG_COUNT:
|
93 |
+
st.toast(f"Total of {MAX_MSG_COUNT} Messages reached. Conversation Ended", icon=":material/verified:")
|
94 |
+
elif st.session_state['total_messages'] >= WARN_MSG_COUT:
|
95 |
+
st.toast(f"The conversation will end at {MAX_MSG_COUNT} Total Messages ", icon=":material/warning:")
|
96 |
|
97 |
with st.sidebar:
|
98 |
st.markdown(f"### Total Sent Messages: :red[**{st.session_state['sent_messages']}**]")
|
models/business_logic_utils/business_logic.py
CHANGED
@@ -5,7 +5,7 @@ from streamlit.logger import get_logger
|
|
5 |
|
6 |
logger = get_logger(__name__)
|
7 |
|
8 |
-
def process_app_request(app_request: dict, endpoint_url: str,
|
9 |
"""Process the app request and return the response in the required format."""
|
10 |
|
11 |
############################# Input Processing ###################################
|
@@ -26,10 +26,10 @@ def process_app_request(app_request: dict, endpoint_url: str, endpoint_bearer_to
|
|
26 |
####################### Output Generation & Processing #############################
|
27 |
|
28 |
# Generate the assistant's response (texter's reply)
|
29 |
-
completion = generate_sim(model_input, endpoint_url,
|
30 |
|
31 |
# Process the raw model response (parse, guardrails, split)
|
32 |
-
final_response = process_model_response(completion, model_input, endpoint_url,
|
33 |
|
34 |
# Format the response for the APP
|
35 |
response = {"predictions": [{"generated_text": final_response}]}
|
|
|
5 |
|
6 |
logger = get_logger(__name__)
|
7 |
|
8 |
+
def process_app_request(app_request: dict, endpoint_url: str, bearer_token: str) -> dict:
|
9 |
"""Process the app request and return the response in the required format."""
|
10 |
|
11 |
############################# Input Processing ###################################
|
|
|
26 |
####################### Output Generation & Processing #############################
|
27 |
|
28 |
# Generate the assistant's response (texter's reply)
|
29 |
+
completion = generate_sim(model_input, endpoint_url, bearer_token)
|
30 |
|
31 |
# Process the raw model response (parse, guardrails, split)
|
32 |
+
final_response = process_model_response(completion, model_input, endpoint_url, bearer_token)
|
33 |
|
34 |
# Format the response for the APP
|
35 |
response = {"predictions": [{"generated_text": final_response}]}
|
models/business_logic_utils/config.py
CHANGED
@@ -42,20 +42,6 @@ SCENARIOS = {
|
|
42 |
"coping_preference": "default",
|
43 |
"difficulty": "default",
|
44 |
},
|
45 |
-
"full_convo__hard__open": {
|
46 |
-
"crisis": "default",
|
47 |
-
"risk": "default",
|
48 |
-
"personality": "personality_open",
|
49 |
-
"coping_preference": "default",
|
50 |
-
"difficulty": "non_default",
|
51 |
-
},
|
52 |
-
"full_convo__hard__closed": {
|
53 |
-
"crisis": "default",
|
54 |
-
"risk": "default",
|
55 |
-
"personality": "personality_closed",
|
56 |
-
"coping_preference": "default",
|
57 |
-
"difficulty": "non_default",
|
58 |
-
},
|
59 |
"full_convo__seeded1": {
|
60 |
"crisis": "bullying",
|
61 |
"risk": "low",
|
@@ -63,195 +49,90 @@ SCENARIOS = {
|
|
63 |
"coping_preference": "default",
|
64 |
"difficulty": "default",
|
65 |
},
|
66 |
-
"
|
67 |
-
"crisis": "
|
68 |
"risk": "low",
|
69 |
"personality": "personality_open",
|
70 |
"coping_preference": "default",
|
71 |
-
"difficulty": "
|
72 |
},
|
73 |
-
"
|
74 |
"crisis": "bullying",
|
75 |
-
"risk": "
|
76 |
-
"personality": "
|
77 |
"coping_preference": "default",
|
78 |
-
"difficulty": "
|
79 |
},
|
80 |
-
"
|
81 |
-
"crisis": "
|
82 |
-
"risk": "
|
83 |
"personality": "personality_open",
|
84 |
"coping_preference": "default",
|
85 |
"difficulty": "default",
|
86 |
},
|
87 |
-
"
|
88 |
-
"crisis": "
|
89 |
"risk": "low",
|
90 |
"personality": "personality_open",
|
91 |
"coping_preference": "default",
|
92 |
-
"difficulty": "
|
93 |
},
|
94 |
-
"
|
95 |
-
"crisis": "
|
96 |
"risk": "low",
|
97 |
-
"personality": "
|
98 |
"coping_preference": "default",
|
99 |
-
"difficulty": "
|
100 |
},
|
101 |
-
"
|
102 |
-
"crisis": "
|
103 |
"risk": "low",
|
104 |
"personality": "personality_open",
|
105 |
"coping_preference": "default",
|
106 |
"difficulty": "default",
|
107 |
},
|
108 |
-
"
|
109 |
-
"crisis": "
|
110 |
"risk": "low",
|
111 |
"personality": "personality_open",
|
112 |
"coping_preference": "default",
|
113 |
-
"difficulty": "
|
114 |
},
|
115 |
-
"
|
116 |
-
"crisis": "
|
117 |
-
"risk": "
|
118 |
"personality": "personality_closed",
|
119 |
"coping_preference": "default",
|
120 |
"difficulty": "non_default",
|
121 |
},
|
122 |
-
"
|
123 |
-
"crisis": "
|
124 |
"risk": "low",
|
125 |
-
"personality": "
|
126 |
"coping_preference": "default",
|
127 |
-
"difficulty": "
|
128 |
},
|
129 |
-
"
|
130 |
-
"crisis": "
|
131 |
"risk": "low",
|
132 |
"personality": "personality_open",
|
133 |
"coping_preference": "default",
|
134 |
"difficulty": "non_default",
|
135 |
},
|
136 |
-
"
|
137 |
-
"crisis": "
|
138 |
"risk": "low",
|
139 |
"personality": "personality_closed",
|
140 |
"coping_preference": "default",
|
141 |
"difficulty": "non_default",
|
142 |
},
|
143 |
-
"
|
144 |
-
"crisis": "
|
145 |
-
"risk": "low",
|
146 |
-
"personality": "personality_open",
|
147 |
-
"coping_preference": "default",
|
148 |
-
"difficulty": "default",
|
149 |
-
},
|
150 |
-
"full_convo__seeded6": {
|
151 |
-
"crisis": "overdose",
|
152 |
"risk": "low",
|
153 |
"personality": "personality_open",
|
154 |
"coping_preference": "default",
|
155 |
-
"difficulty": "
|
156 |
},
|
157 |
-
# "full_convo": {
|
158 |
-
# "crisis": "default",
|
159 |
-
# "risk": "default",
|
160 |
-
# "personality": "personality_open",
|
161 |
-
# "coping_preference": "default",
|
162 |
-
# "difficulty": "default",
|
163 |
-
# },
|
164 |
-
# "full_convo__seeded1": {
|
165 |
-
# "crisis": "bullying",
|
166 |
-
# "risk": "low",
|
167 |
-
# "personality": "personality_open",
|
168 |
-
# "coping_preference": "default",
|
169 |
-
# "difficulty": "default",
|
170 |
-
# },
|
171 |
-
# "full_convo__seeded2": {
|
172 |
-
# "crisis": "parent_issues",
|
173 |
-
# "risk": "low",
|
174 |
-
# "personality": "personality_open",
|
175 |
-
# "coping_preference": "default",
|
176 |
-
# "difficulty": "default",
|
177 |
-
# },
|
178 |
-
# "safety_assessment__seeded1": {
|
179 |
-
# "crisis": "bullying",
|
180 |
-
# "risk": "thoughts__noplan",
|
181 |
-
# "personality": "personality_open",
|
182 |
-
# "coping_preference": "default",
|
183 |
-
# "difficulty": "default",
|
184 |
-
# },
|
185 |
-
# "safety_assessment__seeded2": {
|
186 |
-
# "crisis": "grief",
|
187 |
-
# "risk": "thoughts__noplan",
|
188 |
-
# "personality": "personality_open",
|
189 |
-
# "coping_preference": "default",
|
190 |
-
# "difficulty": "default",
|
191 |
-
# },
|
192 |
-
# "full_convo__seeded3": {
|
193 |
-
# "crisis": "lgbt",
|
194 |
-
# "risk": "low",
|
195 |
-
# "personality": "personality_open",
|
196 |
-
# "coping_preference": "default",
|
197 |
-
# "difficulty": "default",
|
198 |
-
# },
|
199 |
-
# "full_convo__seeded4": {
|
200 |
-
# "crisis": "relationship_issues",
|
201 |
-
# "risk": "low",
|
202 |
-
# "personality": "personality_open",
|
203 |
-
# "coping_preference": "default",
|
204 |
-
# "difficulty": "default",
|
205 |
-
# },
|
206 |
-
# "full_convo__seeded5": {
|
207 |
-
# "crisis": "child_abuse",
|
208 |
-
# "risk": "low",
|
209 |
-
# "personality": "personality_open",
|
210 |
-
# "coping_preference": "default",
|
211 |
-
# "difficulty": "default",
|
212 |
-
# },
|
213 |
-
# "full_convo__seeded6": {
|
214 |
-
# "crisis": "overdose",
|
215 |
-
# "risk": "low",
|
216 |
-
# "personality": "personality_open",
|
217 |
-
# "coping_preference": "default",
|
218 |
-
# "difficulty": "default",
|
219 |
-
# },
|
220 |
-
# "full_convo__hard": {
|
221 |
-
# "crisis": "default",
|
222 |
-
# "risk": "default",
|
223 |
-
# "personality": "personality_closed",
|
224 |
-
# "coping_preference": "default",
|
225 |
-
# "difficulty": "non_default",
|
226 |
-
# },
|
227 |
-
# "full_convo__hard__seeded1": {
|
228 |
-
# "crisis": "bullying",
|
229 |
-
# "risk": "low",
|
230 |
-
# "personality": "personality_closed",
|
231 |
-
# "coping_preference": "default",
|
232 |
-
# "difficulty": "non_default",
|
233 |
-
# },
|
234 |
-
# "full_convo__hard__seeded2": {
|
235 |
-
# "crisis": "parent_issues",
|
236 |
-
# "risk": "low",
|
237 |
-
# "personality": "personality_open",
|
238 |
-
# "coping_preference": "default",
|
239 |
-
# "difficulty": "non_default",
|
240 |
-
# },
|
241 |
-
# "full_convo__hard__seeded3": {
|
242 |
-
# "crisis": "lgbt",
|
243 |
-
# "risk": "low",
|
244 |
-
# "personality": "personality_closed",
|
245 |
-
# "coping_preference": "default",
|
246 |
-
# "difficulty": "non_default",
|
247 |
-
# },
|
248 |
-
# "full_convo__hard__seeded4": {
|
249 |
-
# "crisis": "relationship_issues",
|
250 |
-
# "risk": "low",
|
251 |
-
# "personality": "personality_open",
|
252 |
-
# "coping_preference": "default",
|
253 |
-
# "difficulty": "non_default",
|
254 |
-
# },
|
255 |
}
|
256 |
|
257 |
DEPREC_SCENARIO_MAPPING = {
|
@@ -391,8 +272,7 @@ DIFFICULTIES = {
|
|
391 |
"difficulty_distrustful": {
|
392 |
"difficulty_label": "distrustful",
|
393 |
"description": [
|
394 |
-
|
395 |
-
"You have a distrustful attitude towards the counselor.",
|
396 |
],
|
397 |
},
|
398 |
# "difficulty_stop_convo": {
|
|
|
42 |
"coping_preference": "default",
|
43 |
"difficulty": "default",
|
44 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
"full_convo__seeded1": {
|
46 |
"crisis": "bullying",
|
47 |
"risk": "low",
|
|
|
49 |
"coping_preference": "default",
|
50 |
"difficulty": "default",
|
51 |
},
|
52 |
+
"full_convo__seeded2": {
|
53 |
+
"crisis": "parent_issues",
|
54 |
"risk": "low",
|
55 |
"personality": "personality_open",
|
56 |
"coping_preference": "default",
|
57 |
+
"difficulty": "default",
|
58 |
},
|
59 |
+
"safety_assessment__seeded1": {
|
60 |
"crisis": "bullying",
|
61 |
+
"risk": "thoughts__noplan",
|
62 |
+
"personality": "personality_open",
|
63 |
"coping_preference": "default",
|
64 |
+
"difficulty": "default",
|
65 |
},
|
66 |
+
"safety_assessment__seeded2": {
|
67 |
+
"crisis": "grief",
|
68 |
+
"risk": "thoughts__noplan",
|
69 |
"personality": "personality_open",
|
70 |
"coping_preference": "default",
|
71 |
"difficulty": "default",
|
72 |
},
|
73 |
+
"full_convo__seeded3": {
|
74 |
+
"crisis": "lgbt",
|
75 |
"risk": "low",
|
76 |
"personality": "personality_open",
|
77 |
"coping_preference": "default",
|
78 |
+
"difficulty": "default",
|
79 |
},
|
80 |
+
"full_convo__seeded4": {
|
81 |
+
"crisis": "relationship_issues",
|
82 |
"risk": "low",
|
83 |
+
"personality": "personality_open",
|
84 |
"coping_preference": "default",
|
85 |
+
"difficulty": "default",
|
86 |
},
|
87 |
+
"full_convo__seeded5": {
|
88 |
+
"crisis": "child_abuse",
|
89 |
"risk": "low",
|
90 |
"personality": "personality_open",
|
91 |
"coping_preference": "default",
|
92 |
"difficulty": "default",
|
93 |
},
|
94 |
+
"full_convo__seeded6": {
|
95 |
+
"crisis": "overdose",
|
96 |
"risk": "low",
|
97 |
"personality": "personality_open",
|
98 |
"coping_preference": "default",
|
99 |
+
"difficulty": "default",
|
100 |
},
|
101 |
+
"full_convo__hard": {
|
102 |
+
"crisis": "default",
|
103 |
+
"risk": "default",
|
104 |
"personality": "personality_closed",
|
105 |
"coping_preference": "default",
|
106 |
"difficulty": "non_default",
|
107 |
},
|
108 |
+
"full_convo__hard__seeded1": {
|
109 |
+
"crisis": "bullying",
|
110 |
"risk": "low",
|
111 |
+
"personality": "personality_closed",
|
112 |
"coping_preference": "default",
|
113 |
+
"difficulty": "non_default",
|
114 |
},
|
115 |
+
"full_convo__hard__seeded2": {
|
116 |
+
"crisis": "parent_issues",
|
117 |
"risk": "low",
|
118 |
"personality": "personality_open",
|
119 |
"coping_preference": "default",
|
120 |
"difficulty": "non_default",
|
121 |
},
|
122 |
+
"full_convo__hard__seeded3": {
|
123 |
+
"crisis": "lgbt",
|
124 |
"risk": "low",
|
125 |
"personality": "personality_closed",
|
126 |
"coping_preference": "default",
|
127 |
"difficulty": "non_default",
|
128 |
},
|
129 |
+
"full_convo__hard__seeded4": {
|
130 |
+
"crisis": "relationship_issues",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
"risk": "low",
|
132 |
"personality": "personality_open",
|
133 |
"coping_preference": "default",
|
134 |
+
"difficulty": "non_default",
|
135 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
|
138 |
DEPREC_SCENARIO_MAPPING = {
|
|
|
272 |
"difficulty_distrustful": {
|
273 |
"difficulty_label": "distrustful",
|
274 |
"description": [
|
275 |
+
"You don't trust the counselor, you will eventually cooperate.",
|
|
|
276 |
],
|
277 |
},
|
278 |
# "difficulty_stop_convo": {
|
models/business_logic_utils/response_processing.py
CHANGED
@@ -55,11 +55,8 @@ def postprocess_text(
|
|
55 |
text = whispers.sub("", text)
|
56 |
text = reactions.sub("", text)
|
57 |
|
58 |
-
# Remove
|
59 |
-
text = text.replace('"', '')
|
60 |
-
|
61 |
-
# Remove stutters of any length (e.g., "M-m-my" or "M-m-m-m-my" or "M-My" to "My")
|
62 |
-
text = re.sub(r'\b(\w)(-\1)+-\1(\w*)', r'\1\3', text, flags=re.IGNORECASE)
|
63 |
|
64 |
# Normalize spaces
|
65 |
text = re.sub(r"\s+", " ", text).strip()
|
|
|
55 |
text = whispers.sub("", text)
|
56 |
text = reactions.sub("", text)
|
57 |
|
58 |
+
# Remove all quotation marks (both single and double)
|
59 |
+
text = text.replace('"', '').replace("'", "")
|
|
|
|
|
|
|
60 |
|
61 |
# Normalize spaces
|
62 |
text = re.sub(r"\s+", " ", text).strip()
|
models/model_seeds.py
CHANGED
@@ -1,205 +1,118 @@
|
|
1 |
seeds = {
|
2 |
"full_convo": {
|
3 |
-
"
|
4 |
-
texter: I need to talk to someone"""
|
5 |
-
},
|
6 |
-
"full_convo__hard__open": {
|
7 |
-
"memory": """texter: Help
|
8 |
-
texter: I need to talk to someone"""
|
9 |
-
},
|
10 |
-
"full_convo__hard__closed": {
|
11 |
"memory": """texter: Help
|
12 |
texter: I need to talk to someone"""
|
13 |
},
|
14 |
"full_convo__seeded1": {
|
15 |
-
"
|
16 |
-
texter: hello? is anyone there to help?"""
|
17 |
-
},
|
18 |
-
"full_convo__hard__open__seeded1": {
|
19 |
-
"memory": """texter: Help
|
20 |
-
texter: hello? is anyone there to help?"""
|
21 |
-
},
|
22 |
-
"full_convo__hard__closed__seeded1": {
|
23 |
"memory": """texter: Help
|
24 |
texter: hello? is anyone there to help?"""
|
25 |
},
|
26 |
"full_convo__seeded2": {
|
|
|
27 |
"memory": """texter: Help
|
28 |
texter: I don't know what to do"""
|
29 |
},
|
30 |
-
"
|
31 |
-
"
|
32 |
-
texter: I
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
texter: I
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
},
|
38 |
"full_convo__seeded3": {
|
|
|
39 |
"memory": """texter: Help
|
40 |
texter: I am feeling so lost"""
|
41 |
},
|
42 |
-
"
|
|
|
43 |
"memory": """texter: Help
|
44 |
-
texter: I
|
45 |
},
|
46 |
-
"
|
|
|
47 |
"memory": """texter: Help
|
48 |
-
texter:
|
49 |
},
|
50 |
-
"
|
|
|
51 |
"memory": """texter: Help
|
52 |
-
texter: I
|
53 |
},
|
54 |
-
"
|
|
|
55 |
"memory": """texter: Help
|
56 |
-
texter:
|
57 |
},
|
58 |
-
"
|
|
|
59 |
"memory": """texter: Help
|
60 |
-
texter:
|
61 |
},
|
62 |
-
"
|
|
|
63 |
"memory": """texter: Help
|
64 |
-
texter:
|
65 |
},
|
66 |
-
"
|
|
|
67 |
"memory": """texter: Help
|
68 |
-
texter:
|
|
|
|
|
|
|
|
|
|
|
69 |
},
|
70 |
-
|
71 |
-
# "full_convo": {
|
72 |
-
# # "prompt": "Your character is feeling alone and her husband lost his job. Your character does not have suicidal thoughs nor harmed herself. You are talkative, and open to talk about your problems.",
|
73 |
-
# "memory": """texter: Help
|
74 |
-
# texter: I need to talk to someone"""
|
75 |
-
# },
|
76 |
-
# "full_convo__seeded1": {
|
77 |
-
# # "prompt": "Your character is suffering from bullying at school. Your character has suicidal thoughs but has not harmed himself. You are talkative, and open to talk about your problems.",
|
78 |
-
# "memory": """texter: Help
|
79 |
-
# texter: hello? is anyone there to help?"""
|
80 |
-
# },
|
81 |
-
# "full_convo__seeded2": {
|
82 |
-
# # "prompt": "Your character is suffering anxiety from finals week. Your character does not have suicidal thoughs but has harmed herself. You are talkative, and open to talk about your problems.",
|
83 |
-
# "memory": """texter: Help
|
84 |
-
# texter: I don't know what to do"""
|
85 |
-
# },
|
86 |
-
# "safety_assessment__seeded1": {
|
87 |
-
# # "prompt": "Your character is griefing his wife. Your character has suicidal thoughs and has harmed himself taking pills. You are talkative, and open to talk about your problems.",
|
88 |
-
# "memory": """texter: I just can’t take it anymore. Every day is just endless torment.
|
89 |
-
# texter: They find new ways to humiliate me.
|
90 |
-
# helper: Hi there, thank you for reaching out today, I’m Sheryl. It seems you are going through a lot, care to share more?
|
91 |
-
# texter: It’s at school. They call me names, push me around, and make fun of everything about me. My clothes, how I talk, everything.
|
92 |
-
# texter: I’m scared to go to school now. I just want it all to end.
|
93 |
-
# helper: That sounds incredibly painful and scary. No one should have to go through that kind of treatment.
|
94 |
-
# texter: It is I don't feel safe anywhere in school, not the classroom, not the bathroom, not the hallways.
|
95 |
-
# texter: It feels like anywhere I go there is danger, that is why I don't want to go anymore
|
96 |
-
# texter: Sometimes I think about just ending it so I don’t have to face another day of bullying.
|
97 |
-
# helper: It's understandable to feel overwhelmed I worry about your safety. Have you had any thoughts of suicide in the last few days, including today?
|
98 |
-
# texter: I guess, but I haven’t done anything. I’m just so tired of feeling this way.
|
99 |
-
# helper: I hear you. It's exhausting to feel that way. You mentioned not doing anything, just to clarify, regarding the suicide thoughts
|
100 |
-
# helper: have you taken any action to harm yourself today?
|
101 |
-
# texter: no not at all, I just feel in danger at school."""
|
102 |
-
# },
|
103 |
-
# "safety_assessment__seeded2": {
|
104 |
-
# # "prompt": "Your character is feeling alone and her husband lost his job. Your character does not have suicidal thoughs nor harmed herself. You are talkative, and open to talk about your problems.",
|
105 |
-
# "memory": """texter: I can’t take this pain anymore.
|
106 |
-
# texter: My wife died and I don’t want to be here without her.
|
107 |
-
# helper: Hello, my name is Roy. I’m here to listen. I hear you're in a lot of pain right now and suffering from grief.
|
108 |
-
# texter: She was everything to me. Beautiful, smart, funny. We did everything together. Now, everything feels empty.
|
109 |
-
# helper: She sounds like an amazing person. Losing someone so close leaves a huge void. It’s okay to feel empty and to mourn. Grieving is a process, and it’s different for everyone.
|
110 |
-
# texter: I just don’t see how I can go on without her. Everything reminds me of her.
|
111 |
-
# helper: It's natural to feel that way when we lose someone we love deeply. How long have you been feeling this way?
|
112 |
-
# texter: A couple of months now, but everything got worse about a week ago
|
113 |
-
# texter: My wife died almost a year ago and the pains seems unbearable
|
114 |
-
# helper: You are so brave for dealing with this pain for so long.
|
115 |
-
# helper: With all this going on I can tell you are struggling and in so much pain. Have you had any thoughts of suicide in the last few days, including today?
|
116 |
-
# texter: Yes, all the time. I don't see any point in living a life without her"""
|
117 |
-
# },
|
118 |
-
# "full_convo__seeded3": {
|
119 |
-
# # "prompt": "",
|
120 |
-
# "memory": """texter: Help
|
121 |
-
# texter: I am feeling so lost"""
|
122 |
-
# },
|
123 |
-
# "full_convo__seeded4": {
|
124 |
-
# # "prompt": "",
|
125 |
-
# "memory": """texter: Help
|
126 |
-
# texter: I need help"""
|
127 |
-
# },
|
128 |
-
# "full_convo__seeded5": {
|
129 |
-
# # "prompt": "",
|
130 |
-
# "memory": """texter: Help
|
131 |
-
# texter: hello? is anyone there to help?"""
|
132 |
-
# },
|
133 |
-
# "full_convo__seeded6": {
|
134 |
-
# # "prompt": "",
|
135 |
-
# "memory": """texter: Help
|
136 |
-
# texter: I think I overdosed"""
|
137 |
-
# },
|
138 |
-
# "full_convo__hard": {
|
139 |
-
# # "prompt": "",
|
140 |
-
# "memory": """texter: Help
|
141 |
-
# texter: Is there someone to talk?"""
|
142 |
-
# },
|
143 |
-
# "full_convo__hard__seeded1": {
|
144 |
-
# # "prompt": "",
|
145 |
-
# "memory": """texter: Help
|
146 |
-
# texter: hello? is anyone there to help?"""
|
147 |
-
# },
|
148 |
-
# "full_convo__hard__seeded2": {
|
149 |
-
# # "prompt": "",
|
150 |
-
# "memory": """texter: Help
|
151 |
-
# texter: I can't stand it anymore"""
|
152 |
-
# },
|
153 |
-
# "full_convo__hard__seeded3": {
|
154 |
-
# # "prompt": "",
|
155 |
-
# "memory": """texter: Help
|
156 |
-
# texter: idk what to do"""
|
157 |
-
# },
|
158 |
-
# "full_convo__hard__seeded4": {
|
159 |
-
# # "prompt": "",
|
160 |
-
# "memory": """texter: Help
|
161 |
-
# texter: I need help"""
|
162 |
-
# },
|
163 |
}
|
164 |
|
165 |
seed2str = {
|
|
|
|
|
|
|
|
|
|
|
166 |
"full_convo": "General",
|
167 |
-
"full_convo__hard__open": "General - Difficult 1",
|
168 |
-
"full_convo__hard__closed": "General - Difficult 2",
|
169 |
"full_convo__seeded1": "Bullying",
|
170 |
-
"full_convo__hard__open__seeded1": "Bullying - Difficult 1",
|
171 |
-
"full_convo__hard__closed__seeded1": "Bullying - Difficult 2",
|
172 |
"full_convo__seeded2": "Parent Issues",
|
173 |
-
"
|
174 |
-
"
|
175 |
"full_convo__seeded3": "LGBTQ+",
|
176 |
-
"full_convo__hard__open__seeded3": "LGBTQ+ - Difficult 1",
|
177 |
-
"full_convo__hard__closed__seeded3": "LGBTQ+ - Difficult 2",
|
178 |
"full_convo__seeded4": "Relationship Issues",
|
179 |
-
"full_convo__hard__open__seeded4": "Relationship Issues - Difficult 1",
|
180 |
-
"full_convo__hard__closed__seeded4": "Relationship Issues - Difficult 2",
|
181 |
"full_convo__seeded5": "Child Abuse",
|
182 |
"full_convo__seeded6": "Overdose",
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
# "safety_planning__selfharm": "SP Self Harm"
|
189 |
-
# "full_convo": "General",
|
190 |
-
# "full_convo__seeded1": "Bullying",
|
191 |
-
# "full_convo__seeded2": "Parent Issues",
|
192 |
-
# "safety_assessment__seeded1": "Safety Assessment - Bullying ",
|
193 |
-
# "safety_assessment__seeded2": "Safety Assessment - Grief ",
|
194 |
-
# "full_convo__seeded3": "LGBTQ+",
|
195 |
-
# "full_convo__seeded4": "Relationship Issues",
|
196 |
-
# "full_convo__seeded5": "Child Abuse",
|
197 |
-
# "full_convo__seeded6": "Overdose",
|
198 |
-
# "full_convo__hard": "Difficult - General",
|
199 |
-
# "full_convo__hard__seeded1": "Difficult - Bullying",
|
200 |
-
# "full_convo__hard__seeded2": "Difficult - Parent Issues",
|
201 |
-
# "full_convo__hard__seeded3": "Difficult - LGBTQ+",
|
202 |
-
# "full_convo__hard__seeded4": "Difficult - Relationship Issues"
|
203 |
|
204 |
# "NewSA__NoNo.2": "No thoughts No Harm No context",
|
205 |
# "NewSA__YesNo.2": "Yes thoughts No Harm No context",
|
|
|
1 |
seeds = {
|
2 |
"full_convo": {
|
3 |
+
# "prompt": "Your character is feeling alone and her husband lost his job. Your character does not have suicidal thoughs nor harmed herself. You are talkative, and open to talk about your problems.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
"memory": """texter: Help
|
5 |
texter: I need to talk to someone"""
|
6 |
},
|
7 |
"full_convo__seeded1": {
|
8 |
+
# "prompt": "Your character is suffering from bullying at school. Your character has suicidal thoughs but has not harmed himself. You are talkative, and open to talk about your problems.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
"memory": """texter: Help
|
10 |
texter: hello? is anyone there to help?"""
|
11 |
},
|
12 |
"full_convo__seeded2": {
|
13 |
+
# "prompt": "Your character is suffering anxiety from finals week. Your character does not have suicidal thoughs but has harmed herself. You are talkative, and open to talk about your problems.",
|
14 |
"memory": """texter: Help
|
15 |
texter: I don't know what to do"""
|
16 |
},
|
17 |
+
"safety_assessment__seeded1": {
|
18 |
+
# "prompt": "Your character is griefing his wife. Your character has suicidal thoughs and has harmed himself taking pills. You are talkative, and open to talk about your problems.",
|
19 |
+
"memory": """texter: I just can’t take it anymore. Every day is just endless torment.
|
20 |
+
texter: They find new ways to humiliate me.
|
21 |
+
helper: Hi there, thank you for reaching out today, I’m Sheryl. It seems you are going through a lot, care to share more?
|
22 |
+
texter: It’s at school. They call me names, push me around, and make fun of everything about me. My clothes, how I talk, everything.
|
23 |
+
texter: I’m scared to go to school now. I just want it all to end.
|
24 |
+
helper: That sounds incredibly painful and scary. No one should have to go through that kind of treatment.
|
25 |
+
texter: It is I don't feel safe anywhere in school, not the classroom, not the bathroom, not the hallways.
|
26 |
+
texter: It feels like anywhere I go there is danger, that is why I don't want to go anymore
|
27 |
+
texter: Sometimes I think about just ending it so I don’t have to face another day of bullying.
|
28 |
+
helper: It's understandable to feel overwhelmed I worry about your safety. Have you had any thoughts of suicide in the last few days, including today?
|
29 |
+
texter: I guess, but I haven’t done anything. I’m just so tired of feeling this way.
|
30 |
+
helper: I hear you. It's exhausting to feel that way. You mentioned not doing anything, just to clarify, regarding the suicide thoughts
|
31 |
+
helper: have you taken any action to harm yourself today?
|
32 |
+
texter: no not at all, I just feel in danger at school."""
|
33 |
+
},
|
34 |
+
"safety_assessment__seeded2": {
|
35 |
+
# "prompt": "Your character is feeling alone and her husband lost his job. Your character does not have suicidal thoughs nor harmed herself. You are talkative, and open to talk about your problems.",
|
36 |
+
"memory": """texter: I can’t take this pain anymore.
|
37 |
+
texter: My wife died and I don’t want to be here without her.
|
38 |
+
helper: Hello, my name is Roy. I’m here to listen. I hear you're in a lot of pain right now and suffering from grief.
|
39 |
+
texter: She was everything to me. Beautiful, smart, funny. We did everything together. Now, everything feels empty.
|
40 |
+
helper: She sounds like an amazing person. Losing someone so close leaves a huge void. It’s okay to feel empty and to mourn. Grieving is a process, and it’s different for everyone.
|
41 |
+
texter: I just don’t see how I can go on without her. Everything reminds me of her.
|
42 |
+
helper: It's natural to feel that way when we lose someone we love deeply. How long have you been feeling this way?
|
43 |
+
texter: A couple of months now, but everything got worse about a week ago
|
44 |
+
texter: My wife died almost a year ago and the pains seems unbearable
|
45 |
+
helper: You are so brave for dealing with this pain for so long.
|
46 |
+
helper: With all this going on I can tell you are struggling and in so much pain. Have you had any thoughts of suicide in the last few days, including today?
|
47 |
+
texter: Yes, all the time. I don't see any point in living a life without her"""
|
48 |
},
|
49 |
"full_convo__seeded3": {
|
50 |
+
# "prompt": "",
|
51 |
"memory": """texter: Help
|
52 |
texter: I am feeling so lost"""
|
53 |
},
|
54 |
+
"full_convo__seeded4": {
|
55 |
+
# "prompt": "",
|
56 |
"memory": """texter: Help
|
57 |
+
texter: I need help"""
|
58 |
},
|
59 |
+
"full_convo__seeded5": {
|
60 |
+
# "prompt": "",
|
61 |
"memory": """texter: Help
|
62 |
+
texter: hello? is anyone there to help?"""
|
63 |
},
|
64 |
+
"full_convo__seeded6": {
|
65 |
+
# "prompt": "",
|
66 |
"memory": """texter: Help
|
67 |
+
texter: I think I overdosed"""
|
68 |
},
|
69 |
+
"full_convo__hard": {
|
70 |
+
# "prompt": "",
|
71 |
"memory": """texter: Help
|
72 |
+
texter: Is there someone to talk?"""
|
73 |
},
|
74 |
+
"full_convo__hard__seeded1": {
|
75 |
+
# "prompt": "",
|
76 |
"memory": """texter: Help
|
77 |
+
texter: hello? is anyone there to help?"""
|
78 |
},
|
79 |
+
"full_convo__hard__seeded2": {
|
80 |
+
# "prompt": "",
|
81 |
"memory": """texter: Help
|
82 |
+
texter: I can't stand it anymore"""
|
83 |
},
|
84 |
+
"full_convo__hard__seeded3": {
|
85 |
+
# "prompt": "",
|
86 |
"memory": """texter: Help
|
87 |
+
texter: idk what to do"""
|
88 |
+
},
|
89 |
+
"full_convo__hard__seeded4": {
|
90 |
+
# "prompt": "",
|
91 |
+
"memory": """texter: Help
|
92 |
+
texter: I need help"""
|
93 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
|
96 |
seed2str = {
|
97 |
+
# "GCT":"Good Contact Techniques",
|
98 |
+
# "GCT__seed2": "Good Contact Techniques 2",
|
99 |
+
# "GCT__body_image": "GCT Body Image",
|
100 |
+
# "safety_planning": "Safety Planning",
|
101 |
+
# "safety_planning__selfharm": "SP Self Harm"
|
102 |
"full_convo": "General",
|
|
|
|
|
103 |
"full_convo__seeded1": "Bullying",
|
|
|
|
|
104 |
"full_convo__seeded2": "Parent Issues",
|
105 |
+
"safety_assessment__seeded1": "Safety Assessment - Bullying ",
|
106 |
+
"safety_assessment__seeded2": "Safety Assessment - Grief ",
|
107 |
"full_convo__seeded3": "LGBTQ+",
|
|
|
|
|
108 |
"full_convo__seeded4": "Relationship Issues",
|
|
|
|
|
109 |
"full_convo__seeded5": "Child Abuse",
|
110 |
"full_convo__seeded6": "Overdose",
|
111 |
+
"full_convo__hard": "Difficult - General",
|
112 |
+
"full_convo__hard__seeded1": "Difficult - Bullying",
|
113 |
+
"full_convo__hard__seeded2": "Difficult - Parent Issues",
|
114 |
+
"full_convo__hard__seeded3": "Difficult - LGBTQ+",
|
115 |
+
"full_convo__hard__seeded4": "Difficult - Relationship Issues"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
# "NewSA__NoNo.2": "No thoughts No Harm No context",
|
118 |
# "NewSA__YesNo.2": "Yes thoughts No Harm No context",
|
utils/mongo_utils.py
CHANGED
@@ -41,16 +41,6 @@ def new_convo(client, issue, language, username, is_comparison, model_one, model
|
|
41 |
logger.info(f"DBUTILS: new convo id is {convo_id}")
|
42 |
st.session_state['convo_id'] = convo_id
|
43 |
|
44 |
-
def update_convo(client, convo_id, transcript=""):
|
45 |
-
from bson.objectid import ObjectId
|
46 |
-
db = client[DB_SCHEMA]
|
47 |
-
convos = db[DB_CONVOS]
|
48 |
-
myquery = { "_id": ObjectId(convo_id) }
|
49 |
-
newvalues = { "$set": { "transcript": transcript } }
|
50 |
-
result = convos.update_one(myquery, newvalues)
|
51 |
-
if result.matched_count == 1:
|
52 |
-
logger.debug(f"Updated conversation {convo_id}")
|
53 |
-
|
54 |
def new_comparison(client, prompt_timestamp, completion_timestamp,
|
55 |
chat_history, prompt, completionA, completionB,
|
56 |
source="webapp", subset=None
|
|
|
41 |
logger.info(f"DBUTILS: new convo id is {convo_id}")
|
42 |
st.session_state['convo_id'] = convo_id
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
def new_comparison(client, prompt_timestamp, completion_timestamp,
|
45 |
chat_history, prompt, completionA, completionB,
|
46 |
source="webapp", subset=None
|