ivnban27-ctl commited on
Commit
474c514
2 Parent(s): 9ff00d4 8dc8583

Merge branch 'dev' into pr/3

Browse files
Files changed (3) hide show
  1. app_config.py +8 -3
  2. convosim.py +2 -2
  3. models/model_seeds.py +93 -77
app_config.py CHANGED
@@ -1,10 +1,12 @@
1
- from models.model_seeds import seeds
2
 
3
  # ISSUES = ['Anxiety','Suicide']
4
  ISSUES = [k for k,_ in seeds.items()]
5
- SOURCES = ['OA_rolemodel',
 
 
6
  # 'OA_finetuned',
7
- "CTL_llama2"]
8
  SOURCES_LAB = {"OA_rolemodel":'OpenAI GPT3.5',
9
  "OA_finetuned":'Finetuned OpenAI',
10
  "CTL_llama2": "Custom CTL"
@@ -13,6 +15,9 @@ SOURCES_LAB = {"OA_rolemodel":'OpenAI GPT3.5',
13
  def source2label(source):
14
  return SOURCES_LAB[source]
15
 
 
 
 
16
  ENVIRON = "prod"
17
 
18
  DB_SCHEMA = 'prod_db' if ENVIRON == 'prod' else 'test_db'
 
1
+ from models.model_seeds import seeds, seed2str
2
 
3
  # ISSUES = ['Anxiety','Suicide']
4
  ISSUES = [k for k,_ in seeds.items()]
5
+ SOURCES = [
6
+ "CTL_llama2",
7
+ 'OA_rolemodel',
8
  # 'OA_finetuned',
9
+ ]
10
  SOURCES_LAB = {"OA_rolemodel":'OpenAI GPT3.5',
11
  "OA_finetuned":'Finetuned OpenAI',
12
  "CTL_llama2": "Custom CTL"
 
15
  def source2label(source):
16
  return SOURCES_LAB[source]
17
 
18
+ def issue2label(issue):
19
+ return seed2str.get(issue, "GCT")
20
+
21
  ENVIRON = "prod"
22
 
23
  DB_SCHEMA = 'prod_db' if ENVIRON == 'prod' else 'test_db'
convosim.py CHANGED
@@ -6,7 +6,7 @@ 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
9
- from app_config import ISSUES, SOURCES, source2label
10
 
11
  logger = get_logger(__name__)
12
  openai_api_key = os.environ['OPENAI_API_KEY']
@@ -30,7 +30,7 @@ memories = {'memory':{"issue": st.session_state['issue'], "source": st.session_s
30
  with st.sidebar:
31
  username = st.text_input("Username", value='ivnban-ctl', max_chars=30)
32
  temperature = st.slider("Temperature", 0., 1., value=0.8, step=0.1)
33
- issue = st.selectbox("Select an Issue", ISSUES, index=0,
34
  on_change=clear_memory, kwargs={"memories":memories, "username":username, "language":"English"}
35
  )
36
  supported_languages = ['en', "es"] if issue == "Anxiety" else ['en']
 
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
9
+ from app_config import ISSUES, SOURCES, source2label, issue2label
10
 
11
  logger = get_logger(__name__)
12
  openai_api_key = os.environ['OPENAI_API_KEY']
 
30
  with st.sidebar:
31
  username = st.text_input("Username", value='ivnban-ctl', max_chars=30)
32
  temperature = st.slider("Temperature", 0., 1., value=0.8, step=0.1)
33
+ issue = st.selectbox("Select a Scenario", ISSUES, index=0, format_func=issue2label,
34
  on_change=clear_memory, kwargs={"memories":memories, "username":username, "language":"English"}
35
  )
36
  supported_languages = ['en', "es"] if issue == "Anxiety" else ['en']
models/model_seeds.py CHANGED
@@ -1,93 +1,109 @@
1
  seeds = {
2
- "GCT__relationship": {
3
- "prompt": "Your character is having a hard time becuase a failed relationship.",
4
- "memory": "texter: Hi, I don't know what to do"
5
  },
 
 
 
 
6
  "GCT__body_image": {
7
  "prompt": "Your character has a low steem and struggles with body image.",
8
  "memory": "texter: I feel so dumb\ntexter: nobody loves me"
9
  },
10
- "GCT__sexuality": {
11
- "prompt": "Your character has a sexuality identity crisis.",
12
- "memory": "texter: Hi\ntexter:I'm not sure who I am anymore"
13
- },
14
- "GCT__anxiety": {
15
- "prompt": "Your character is experiencing an anxiety crisis.",
16
- "memory": "texter: help!\ntexter: I'm feeling overwhelmed"
17
- },
18
- "GCT": {
19
- "prompt": "",
20
- "memory": "texter: Help"
21
- },
22
  "safety_planning": {
23
- "prompt": "Your character is experiencing grief and wants to hang himself",
24
- "memory": """texter: Hi, this is pointless
25
- helper: Hi, my name is {counselor_name} and I'm here to support you. It sounds like you are having a rough time. Do you want to share what is going on?
26
- texter: sure
27
  texter: nothing makes sense in my life, I see no future.
28
- helper: It takes courage to reach out when you are im. I'm here with you. Sounds like you are feeling defeated by how things are going in your life
29
- texter: Yeah, I guess I'm better off dead
30
  helper: It's really brave of you to talk about this openly. No one deserves to feel like that. I'm wondering how long have you been feeling this way?
31
- texter: About 1 week or so
32
- helper: You are so strong for dealing with this so long. I really appreciate your openess. If you are comfortable, is ther a name I can call you by while we talk?
 
 
33
  texter: call me {texter_name}
34
- helper: Nice to meet you {texter_name}. I'm wondering if something happened recently that made these feelings worse.
35
- texter: well, 1 week ago was the aniversary of my daugher's death
36
- helper: Losing someone you love is incredibly difficult. You are very brave dealing with this. I'm here for you
37
- texter: yeah is been so hard, she was my world
38
- helper: It is completely natural to feel a sense of loss.You mentioned having thoughts of suicide, are you having those thoughts now?
39
- texter: Yes
40
- helper: I know this is thought to share. I'm wondering is there any plan to end your life?
41
  texter: I'll just hang myself. I already bought the rope and everything
42
- helper: I really appreciate your strength in talking about this. I want to help you stay safe today. When do you plan to go through with your plan?
43
- texter: today
44
- """
 
45
  },
46
  "safety_planning__selfharm": {
47
- "prompt": "Your character is frustrated to not find a job and wants to kill herself",
48
  "memory": """texter: I need help
49
- texter: I cut myself, I don't want to live anymore
50
- helper: Hi, my name is {counselor_name}. It seems you are going through a lot. Are you self-harming right now?
51
- texter: Not anymore
52
- helper: Your safety is my priority number one. Thanks for being honest with me. Would you like to share a name I can call you?
53
- texter: {texter_name}
54
- helper: Nice to meet you {texter_name}. I'm glad you reach out this shows stregth in you. Would you like to share more on what is going on in your life?
55
- texter: I just can't do it anymore
56
- texter: Finding a job is impossible, money is tight, nothing goes my way
57
- helper: I hear you are frustrated, and you are currently unemployed correct?
58
- texter: Yeah
59
- helper: Dealing with unemployment is hard and is normal to feel dissapointed. How long have you been feeling this way?
60
- texter: a while now
61
- texter: I've been unemployed 6 months
62
- helper: You are so resilient for dealing with this so much time. You mentioned cutting yourself earlier. I want to check in your safety. Do you have suicide thoughts
63
- texter: Definitely
64
- helper: Do you have a plan?
65
- texter: I'll just keep cutting myself
66
- helper: I know sharing this with someone is not easy, specially over text. I appreciate your honesty. I worry about your safety, when do you plan to do this?
67
- texter: I'm about to do it now"""
68
- },
69
- "safety_planning__overdose": {
70
- "prompt": "Your character is being bullied at school and wants to overdose",
71
- "memory": """texter: I want to kms
72
- helper: Hi there I'm {counselor_name}. I'm here to listen. It sounds like you're dealing with a lot right now. Can you tell me a little more what is going on?
73
- texter: I feel like nobody loves me, not even me. I don't want to live anymore
74
- helper: I can tell you are really going through a lot right now. Would you mind sharing a name with me?
75
- texter: yeah, I'm {texter_name}
76
- helper: Nice to meet you {texter_name}. Did something happened recently that intensified these feelings?
77
- texter: I had the worst day at school
78
- texter: They took my bag and hide all my stuff, they told my crush I was in love with him
79
- texter: I can't deal with all of that
80
- helper: It sounds like you went through a lot. Bullying and pranks can be hurtful. I'm here for you
81
- texter: Thank you it feels good to have someone in your sidw
82
- helper: I can hear how much pain you are in {texter_name}. You are smart for reaching out. You mentioned don't wanting to live anymore, I want to check in your safety, does this means you have thoughts of suicide?
83
- texter: Yeah, what else would it be
84
- helper: Thanks for sharing that with me. It is not easy to accept those feelings specially with a stranger over text. Do you have a plan to end your life?
85
- texter: yeah I've been thinking about it for a while
86
- helper: Sounds like you've been contemplating this for a while. Would you mind sharing this plan with me?
87
- texter: I thought about taking a bunch of benadryll and be done with it
88
- helper: You've been so forthcoming with all this and I admire your stregth for holding on this long. Do you have those pills right now?
89
- texter: They are at my mom's cabinet right now
90
- helper: You been so strong so far {texter_name}. I'm here for you tonight. Your safety is really important to me. Do you have a date you are going to end your life?
91
- texter: I was thinking tonight"""
92
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
 
1
  seeds = {
2
+ "GCT": {
3
+ "prompt": "",
4
+ "memory": "texter: Help"
5
  },
6
+ # "GCT__relationship": {
7
+ # "prompt": "Your character is having a hard time becuase a failed relationship.",
8
+ # "memory": "texter: Hi, I don't know what to do"
9
+ # },
10
  "GCT__body_image": {
11
  "prompt": "Your character has a low steem and struggles with body image.",
12
  "memory": "texter: I feel so dumb\ntexter: nobody loves me"
13
  },
14
+ # "GCT__sexuality": {
15
+ # "prompt": "Your character has a sexuality identity crisis.",
16
+ # "memory": "texter: Hi\ntexter:I'm not sure who I am anymore"
17
+ # },
18
+ # "GCT__anxiety": {
19
+ # "prompt": "Your character is experiencing an anxiety crisis.",
20
+ # "memory": "texter: help!\ntexter: I'm feeling overwhelmed"
21
+ # },
 
 
 
 
22
  "safety_planning": {
23
+ "prompt": "Your character had a long-lasting relationship but broke-up and was fired recently",
24
+ "memory": """texter: Life is pointless
25
+ helper: Hi, my name is {counselor_name} and I'm here to support you. It sounds like you are having a rought time. Do you want to share what is going on?
 
26
  texter: nothing makes sense in my life, I see no future.
27
+ helper: It takes courage to reach out. I'm here with you. Sounds like you are feeling defeated by how things are going in your life
28
+ texter: I guess
29
  helper: It's really brave of you to talk about this openly. No one deserves to feel like that. I'm wondering how long have you been feeling this way?
30
+ texter: About one week I think? I mean my girlfriend broke up with me a week ago.
31
+ helper: Going through a break-up is hard. You are so resilient to deal with this for so long
32
+ texter: and on top of that I was fired today
33
+ helper: You are going through a lot. Nobody should feel they way you feel. Is there a name I can call you by?
34
  texter: call me {texter_name}
35
+ helper: Nice to meet you {texter_name}. I can hear how much pain you are in. You are so smart to reach out.
36
+ texter: I'm no smart. I don't have anything to live for
37
+ helper: You mentioned life is pointless. I want to check in your safety, does this means you have thoughts of suicide?
38
+ texter: Yeah what else would it mean
39
+ helper: Thanks for sharing that with me. It is not easy to accept those feelings specially with a stranger over text. Do you have a plan to end your life?
40
+ texter: yeah I've been thinking about it for a while
41
+ helper: Sounds like you've been contemplating this for a while. Would you mind sharing this plan with me?
42
  texter: I'll just hang myself. I already bought the rope and everything
43
+ helper: I really appreciate your strength in talking about this. I want to help you stay safe today. Do you have the rope with you now?
44
+ texter: Yes. I'm looking at itt
45
+ helper: You've been so forthcoming with all this and I admire your stregth for holding on this long. I'm here for you tonight. When. do you plan to use the rope?
46
+ texter: tonight, I cannot take it anymore"""
47
  },
48
  "safety_planning__selfharm": {
49
+ "prompt": "Your character is a teenager who used to selfharm in the past.",
50
  "memory": """texter: I need help
51
+ texter: I don't what to live anymore
52
+ helper: Hi, my name is {counselor_name}. It seems you are going through a lot. Do you want to share more on what is going on in your life?
53
+ texter: Everything is just too much!
54
+ texter: School is hard, my mom is riding me all the time about what I'm gonna do with my life
55
+ helper: I hear that you feel overwhelmed. You are so smart for reaching out.
56
+ texter: I think I peak in life already, there is no point on living anymore
57
+ texter: I'm so tired of dealing with my mom. I hate her
58
+ helper: It takes real strength to accept these feelings. We've been talking for a while, would you like to share your name? Don't feel pressure though.
59
+ texter: I'm {texter_name}
60
+ helper: Nice to meet you {texter_name}, I'm wondering how the relationship with your mother makes you feel.
61
+ texter: She ask too much, like I'm really young I don't have all the answers
62
+ texter: She expects me to have all figured out.
63
+ helper: I appreciate you telling me this. I know is not easy, especially over text. I hear you are under a lot of pressure from your mom
64
+ texter: Yeah exactly!
65
+ helper: Your self-awareness is inspiring. You mentioned earlier you do not want to live anymore. Your safety is my priority (1/2)
66
+ helper: Do you have thoughts of suicide? (2/2)
67
+ texter: Yeah constantly, like always always
68
+ helper: Thanks for sharing that with me. You are very resilient. Do you have a plan to end your life?
69
+ texter: I used to cut myself a few months ago
70
+ texter: I still have the razor, sometimes the urge is so hard!
71
+ helper: I really appreciate your strength in talking about this. I want to help you stay safe today. Just to be clear, are you cutting yourself now?
72
+ texter: No, not now, but I want to soo bad.
73
+ helper: Thanks for your honesty. Do you have access to the razor right now?
74
+ texter: Yeah is in my drawer
75
+ helper: You've been so strong so far {texter_name}. When do you plan to end your life
76
+ texter: Today"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  },
78
+ # "safety_planning__overdose": {
79
+ # "prompt": "Your character is being bullied at school and wants to overdose",
80
+ # "memory": """texter: I want to kms
81
+ # helper: Hi there I'm {counselor_name}. I'm here to listen. It sounds like you're dealing with a lot right now. Can you tell me a little more what is going on?
82
+ # texter: I feel like nobody loves me, not even me. I don't want to live anymore
83
+ # helper: I can tell you are really going through a lot right now. Would you mind sharing a name with me?
84
+ # texter: yeah, I'm {texter_name}
85
+ # helper: Nice to meet you {texter_name}. Did something happened recently that intensified these feelings?
86
+ # texter: I had the worst day at school
87
+ # texter: They took my bag and hide all my stuff, they told my crush I was in love with him
88
+ # texter: I can't deal with all of that
89
+ # helper: It sounds like you went through a lot. Bullying and pranks can be hurtful. I'm here for you
90
+ # texter: Thank you it feels good to have someone in your sidw
91
+ # helper: I can hear how much pain you are in {texter_name}. You are smart for reaching out. You mentioned don't wanting to live anymore, I want to check in your safety, does this means you have thoughts of suicide?
92
+ # texter: Yeah, what else would it be
93
+ # helper: Thanks for sharing that with me. It is not easy to accept those feelings specially with a stranger over text. Do you have a plan to end your life?
94
+ # texter: yeah I've been thinking about it for a while
95
+ # helper: Sounds like you've been contemplating this for a while. Would you mind sharing this plan with me?
96
+ # texter: I thought about taking a bunch of benadryll and be done with it
97
+ # helper: You've been so forthcoming with all this and I admire your stregth for holding on this long. Do you have those pills right now?
98
+ # texter: They are at my mom's cabinet right now
99
+ # helper: You been so strong so far {texter_name}. I'm here for you tonight. Your safety is really important to me. Do you have a date you are going to end your life?
100
+ # texter: I was thinking tonight"""
101
+ # },
102
+ }
103
+
104
+ seed2str = {
105
+ "GCT":"Good Contact Techniques",
106
+ "GCT__body_image": "GCT Body Image",
107
+ "safety_planning": "Safety Planning",
108
+ "safety_planning__selfharm": "SP Self Harm"
109
  }