Spaces:
Running
Running
ivnban27-ctl
commited on
Commit
•
5431cb0
1
Parent(s):
6d8e0b1
added names variety and hide manual comparison
Browse files- convosim.py +13 -6
- {pages → hidden_pages}/manual_comparisor.py +0 -0
- pages/comparisor.py +5 -5
- utils/app_utils.py +1 -0
- utils/names.csv +176 -0
convosim.py
CHANGED
@@ -3,7 +3,7 @@ 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
|
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
|
@@ -17,9 +17,10 @@ if 'previous_source' not in st.session_state:
|
|
17 |
if 'db_client' not in st.session_state:
|
18 |
st.session_state["db_client"] = get_db_client()
|
19 |
if 'counselor_name' not in st.session_state:
|
20 |
-
st.session_state["counselor_name"] = get_random_name()
|
21 |
if 'texter_name' not in st.session_state:
|
22 |
-
st.session_state["texter_name"] = get_random_name()
|
|
|
23 |
|
24 |
with st.sidebar:
|
25 |
username = st.text_input("Username", value='ivnban-ctl', max_chars=30)
|
@@ -38,10 +39,16 @@ with st.sidebar:
|
|
38 |
)
|
39 |
|
40 |
memories = {'memory':{"issue":issue, "source":source}}
|
41 |
-
changed_source =
|
|
|
|
|
|
|
42 |
if changed_source:
|
43 |
-
st.session_state["counselor_name"] = get_random_name()
|
44 |
-
st.session_state["texter_name"] = get_random_name()
|
|
|
|
|
|
|
45 |
create_memory_add_initial_message(memories,
|
46 |
issue,
|
47 |
language,
|
|
|
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
|
9 |
from app_config import ISSUES, SOURCES, source2label
|
|
|
17 |
if 'db_client' not in st.session_state:
|
18 |
st.session_state["db_client"] = get_db_client()
|
19 |
if 'counselor_name' not in st.session_state:
|
20 |
+
st.session_state["counselor_name"] = get_random_name(names_df=DEFAULT_NAMES_DF)
|
21 |
if 'texter_name' not in st.session_state:
|
22 |
+
st.session_state["texter_name"] = get_random_name(names_df=DEFAULT_NAMES_DF)
|
23 |
+
logger.info(f"texter name is {st.session_state['texter_name']}")
|
24 |
|
25 |
with st.sidebar:
|
26 |
username = st.text_input("Username", value='ivnban-ctl', max_chars=30)
|
|
|
39 |
)
|
40 |
|
41 |
memories = {'memory':{"issue":issue, "source":source}}
|
42 |
+
changed_source = any([
|
43 |
+
st.session_state['previous_source'] != source,
|
44 |
+
st.session_state['issue'] != issue
|
45 |
+
])
|
46 |
if changed_source:
|
47 |
+
st.session_state["counselor_name"] = get_random_name(names_df=DEFAULT_NAMES_DF)
|
48 |
+
st.session_state["texter_name"] = get_random_name(names_df=DEFAULT_NAMES_DF)
|
49 |
+
st.session_state['previous_source'] = source
|
50 |
+
st.session_state['issue'] = issue
|
51 |
+
st.session_state['sent_messages'] = 0
|
52 |
create_memory_add_initial_message(memories,
|
53 |
issue,
|
54 |
language,
|
{pages → hidden_pages}/manual_comparisor.py
RENAMED
File without changes
|
pages/comparisor.py
CHANGED
@@ -6,7 +6,7 @@ import streamlit as st
|
|
6 |
from streamlit.logger import get_logger
|
7 |
from langchain.schema.messages import HumanMessage
|
8 |
from utils.mongo_utils import get_db_client, new_comparison, new_battle_result
|
9 |
-
from utils.app_utils import create_memory_add_initial_message, get_random_name
|
10 |
from utils.memory_utils import clear_memory, push_convo2db
|
11 |
from utils.chain_utils import get_chain
|
12 |
from app_config import ISSUES, SOURCES, source2label
|
@@ -32,9 +32,9 @@ memories = {
|
|
32 |
if 'db_client' not in st.session_state:
|
33 |
st.session_state["db_client"] = get_db_client()
|
34 |
if 'counselor_name' not in st.session_state:
|
35 |
-
st.session_state["counselor_name"] = get_random_name()
|
36 |
if 'texter_name' not in st.session_state:
|
37 |
-
st.session_state["texter_name"] = get_random_name()
|
38 |
|
39 |
def delete_last_message(memory):
|
40 |
last_prompt = memory.chat_memory.messages[-2].content
|
@@ -151,8 +151,8 @@ changed_source = any([
|
|
151 |
])
|
152 |
if changed_source:
|
153 |
print("changed something")
|
154 |
-
st.session_state["counselor_name"] = get_random_name()
|
155 |
-
st.session_state["texter_name"] = get_random_name()
|
156 |
st.session_state['previous_sourceA'] = sourceA
|
157 |
st.session_state['previous_sourceB'] = sourceB
|
158 |
st.session_state['issue'] = issue
|
|
|
6 |
from streamlit.logger import get_logger
|
7 |
from langchain.schema.messages import HumanMessage
|
8 |
from utils.mongo_utils import get_db_client, new_comparison, new_battle_result
|
9 |
+
from utils.app_utils import create_memory_add_initial_message, get_random_name, DEFAULT_NAMES_DF
|
10 |
from utils.memory_utils import clear_memory, push_convo2db
|
11 |
from utils.chain_utils import get_chain
|
12 |
from app_config import ISSUES, SOURCES, source2label
|
|
|
32 |
if 'db_client' not in st.session_state:
|
33 |
st.session_state["db_client"] = get_db_client()
|
34 |
if 'counselor_name' not in st.session_state:
|
35 |
+
st.session_state["counselor_name"] = get_random_name(names_df=DEFAULT_NAMES_DF)
|
36 |
if 'texter_name' not in st.session_state:
|
37 |
+
st.session_state["texter_name"] = get_random_name(names_df=DEFAULT_NAMES_DF)
|
38 |
|
39 |
def delete_last_message(memory):
|
40 |
last_prompt = memory.chat_memory.messages[-2].content
|
|
|
151 |
])
|
152 |
if changed_source:
|
153 |
print("changed something")
|
154 |
+
st.session_state["counselor_name"] = get_random_name(names_df=DEFAULT_NAMES_DF)
|
155 |
+
st.session_state["texter_name"] = get_random_name(names_df=DEFAULT_NAMES_DF)
|
156 |
st.session_state['previous_sourceA'] = sourceA
|
157 |
st.session_state['previous_sourceB'] = sourceB
|
158 |
st.session_state['issue'] = issue
|
utils/app_utils.py
CHANGED
@@ -13,6 +13,7 @@ logger = get_logger(__name__)
|
|
13 |
|
14 |
# TODO: Include more variable and representative names
|
15 |
DEFAULT_NAMES = ["Olivia", "Kit", "Abby", "Tom", "Carolyne", "Jessiny"]
|
|
|
16 |
|
17 |
def get_random_name(gender="Neutral", ethnical_group="Neutral", names_df=None):
|
18 |
if names_df is None:
|
|
|
13 |
|
14 |
# TODO: Include more variable and representative names
|
15 |
DEFAULT_NAMES = ["Olivia", "Kit", "Abby", "Tom", "Carolyne", "Jessiny"]
|
16 |
+
DEFAULT_NAMES_DF = pd.read_csv("./utils/names.csv")
|
17 |
|
18 |
def get_random_name(gender="Neutral", ethnical_group="Neutral", names_df=None):
|
19 |
if names_df is None:
|
utils/names.csv
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name,gender,ethnical_group
|
2 |
+
Jacob,Male,Neutral
|
3 |
+
Ethan,Male,Neutral
|
4 |
+
Matthew,Male,Neutral
|
5 |
+
David,Male,Neutral
|
6 |
+
Liam,Male,Neutral
|
7 |
+
Noah,Male,Neutral
|
8 |
+
Michael,Male,Neutral
|
9 |
+
Aiden,Male,Neutral
|
10 |
+
Daniel,Male,Neutral
|
11 |
+
Ryan,Male,Neutral
|
12 |
+
Mason,Male,Neutral
|
13 |
+
Lucas,Male,Neutral
|
14 |
+
Joseph,Male,Neutral
|
15 |
+
James,Male,Neutral
|
16 |
+
Alexander,Male,Neutral
|
17 |
+
Anthony,Male,Neutral
|
18 |
+
Sebastian,Male,Neutral
|
19 |
+
Jayden,Male,Neutral
|
20 |
+
Christopher,Male,Neutral
|
21 |
+
Benjamin,Male,Neutral
|
22 |
+
Emma,Female,Neutral
|
23 |
+
Olivia,Female,Neutral
|
24 |
+
Emily,Female,Neutral
|
25 |
+
Mia,Female,Neutral
|
26 |
+
Sophia,Female,Neutral
|
27 |
+
Leah,Female,Neutral
|
28 |
+
Isabella,Female,Neutral
|
29 |
+
Ava,Female,Neutral
|
30 |
+
Sarah,Female,Neutral
|
31 |
+
Chloe,Female,Neutral
|
32 |
+
Sofia,Female,Neutral
|
33 |
+
Madison,Female,Neutral
|
34 |
+
Victoria,Female,Neutral
|
35 |
+
Esther,Female,Neutral
|
36 |
+
Abigail,Female,Neutral
|
37 |
+
Rachel,Female,Neutral
|
38 |
+
Maya,Female,Neutral
|
39 |
+
Ashley,Female,Neutral
|
40 |
+
Ella,Female,Neutral
|
41 |
+
Grace,Female,Neutral
|
42 |
+
Zoe,Female,Neutral
|
43 |
+
Rowan,Neutral,Neutral
|
44 |
+
Yael,Neutral,Neutral
|
45 |
+
Eden,Neutral,Neutral
|
46 |
+
Quinn,Neutral,Neutral
|
47 |
+
Charlie,Neutral,Neutral
|
48 |
+
Milan,Neutral,Neutral
|
49 |
+
Blake,Neutral,Neutral
|
50 |
+
Tenzin,Neutral,Neutral
|
51 |
+
Peyton,Neutral,Neutral
|
52 |
+
Alexis,Neutral,Neutral
|
53 |
+
Ariel,Neutral,Neutral
|
54 |
+
Riley,Neutral,Neutral
|
55 |
+
Avery,Neutral,Neutral
|
56 |
+
Angel,Neutral,Neutral
|
57 |
+
Malachi,Male,African American
|
58 |
+
Nasir,Male,African American
|
59 |
+
Mamdou,Male,African American
|
60 |
+
Chance,Male,African American
|
61 |
+
Zaire,Male,African American
|
62 |
+
Mekhi,Male,African American
|
63 |
+
Sincere,Male,African American
|
64 |
+
Omari,Male,African American
|
65 |
+
Amadou,Male,African American
|
66 |
+
Ibrahima,Male,African American
|
67 |
+
Khalil,Male,African American
|
68 |
+
Moussa,Male,African American
|
69 |
+
Kamari,Male,African American
|
70 |
+
Alpha,Male,African American
|
71 |
+
Major,Male,African American
|
72 |
+
Abdoulaye,Male,African American
|
73 |
+
Aboul,Male,African American
|
74 |
+
Amare,Male,African American
|
75 |
+
Ousmane,Male,African American
|
76 |
+
Darius,Male,African American
|
77 |
+
Jose,Male,Hispanic
|
78 |
+
Carlos,Male,Hispanic
|
79 |
+
Luis,Male,Hispanic
|
80 |
+
Miguel,Male,Hispanic
|
81 |
+
Juan,Male,Hispanic
|
82 |
+
Jesus,Male,Hispanic
|
83 |
+
Erick,Male,Hispanic
|
84 |
+
Alejandro,Male,Hispanic
|
85 |
+
Diego,Male,Hispanic
|
86 |
+
Gael,Male,Hispanic
|
87 |
+
Santago,Male,Hispanic
|
88 |
+
Iker,Male,Hispanic
|
89 |
+
Cristian,Male,Hispanic
|
90 |
+
Jadiel,Male,Hispanic
|
91 |
+
Alexis,Male,Hispanic
|
92 |
+
Josue,Male,Hispanic
|
93 |
+
Jorge,Male,Hispanic
|
94 |
+
Andres,Male,Hispanic
|
95 |
+
Adriel,Male,Hispanic
|
96 |
+
Johan,Male,Hispanic
|
97 |
+
Ayaan,Male,Asian
|
98 |
+
Eason,Male,Asian
|
99 |
+
Tenzin,Male,Asian
|
100 |
+
Syed,Male,Asian
|
101 |
+
Kingsley,Male,Asian
|
102 |
+
Arjun,Male,Asian
|
103 |
+
Carson,Male,Asian
|
104 |
+
Arayan,Male,Asian
|
105 |
+
Anson,Male,Asian
|
106 |
+
Benson,Male,Asian
|
107 |
+
Lawrence,Male,Asian
|
108 |
+
Ayan,Male,Asian
|
109 |
+
Rohan,Male,Asian
|
110 |
+
Roy,Male,Asian
|
111 |
+
Aarav,Male,Asian
|
112 |
+
Rayyan,Male,Asian
|
113 |
+
Kimi,Male,Asian
|
114 |
+
Zayan,Male,Asian
|
115 |
+
Ricky,Male,Asian
|
116 |
+
Arham,Male,Asian
|
117 |
+
Fatoumata,Female,African American
|
118 |
+
Aminata,Female,African American
|
119 |
+
Amiyah,Female,African American
|
120 |
+
Zuri,Female,African American
|
121 |
+
Kimora,Female,African American
|
122 |
+
Mariama,Female,African American
|
123 |
+
Sanaa,Female,African American
|
124 |
+
Lyric,Female,African American
|
125 |
+
Sanai,Female,African American
|
126 |
+
Harmony,Female,African American
|
127 |
+
Aicha,Female,African American
|
128 |
+
Tori,Female,African American
|
129 |
+
Maliyah,Female,African American
|
130 |
+
Aisaatou,Female,African American
|
131 |
+
Miracle,Female,African American
|
132 |
+
Hawa,Female,African American
|
133 |
+
Oumou,Female,African American
|
134 |
+
Dakota,Female,African American
|
135 |
+
Skye,Female,African American
|
136 |
+
Kyla,Female,African American
|
137 |
+
Emely,Female,Hispanic
|
138 |
+
Leslie,Female,Hispanic
|
139 |
+
Andrea,Female,Hispanic
|
140 |
+
Valeria,Female,Hispanic
|
141 |
+
Aylin,Female,Hispanic
|
142 |
+
Jayleen,Female,Hispanic
|
143 |
+
Yaretzi,Female,Hispanic
|
144 |
+
Melany,Female,Hispanic
|
145 |
+
Danna,Female,Hispanic
|
146 |
+
Brittany,Female,Hispanic
|
147 |
+
Alison,Female,Hispanic
|
148 |
+
Jazmin,Female,Hispanic
|
149 |
+
Briana,Female,Hispanic
|
150 |
+
Kamila,Female,Hispanic
|
151 |
+
Alaia,Female,Hispanic
|
152 |
+
Ximena,Female,Hispanic
|
153 |
+
Sherlyn,Female,Hispanic
|
154 |
+
Esmeralda,Female,Hispanic
|
155 |
+
Guadalupe,Female,Hispanic
|
156 |
+
Jazlyn,Female,Hispanic
|
157 |
+
Tenzin,Female,Asian
|
158 |
+
Selina,Female,Asian
|
159 |
+
Ayesha,Female,Asian
|
160 |
+
Vicky,Female,Asian
|
161 |
+
Elaine,Female,Asian
|
162 |
+
Jenny,Female,Asian
|
163 |
+
Winnie,Female,Asian
|
164 |
+
Queenie,Female,Asian
|
165 |
+
Sharon,Female,Asian
|
166 |
+
Alisha,Female,Asian
|
167 |
+
Elina,Female,Asian
|
168 |
+
Erica,Female,Asian
|
169 |
+
Manha,Female,Asian
|
170 |
+
Syeda,Female,Asian
|
171 |
+
Jannat,Female,Asian
|
172 |
+
Janice,Female,Asian
|
173 |
+
Tina,Female,Asian
|
174 |
+
Anya,Female,Asian
|
175 |
+
Arisha,Female,Asian
|
176 |
+
Inaaya,Female,Asian
|