Spaces:
Sleeping
Sleeping
ivnban27-ctl
commited on
Commit
·
6213506
1
Parent(s):
5431cb0
prompt count feature
Browse files- convosim.py +8 -2
- pages/comparisor.py +2 -0
convosim.py
CHANGED
@@ -10,8 +10,11 @@ from app_config import ISSUES, SOURCES, source2label
|
|
10 |
|
11 |
logger = get_logger(__name__)
|
12 |
openai_api_key = os.environ['OPENAI_API_KEY']
|
13 |
-
memories = {'memory':{"issue": ISSUES[0], "source": SOURCES[0]}}
|
14 |
|
|
|
|
|
|
|
|
|
15 |
if 'previous_source' not in st.session_state:
|
16 |
st.session_state['previous_source'] = SOURCES[0]
|
17 |
if 'db_client' not in st.session_state:
|
@@ -22,6 +25,8 @@ 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)
|
27 |
temperature = st.slider("Temperature", 0., 1., value=0.8, step=0.1)
|
@@ -37,8 +42,8 @@ with st.sidebar:
|
|
37 |
source = st.selectbox("Select a source Model A", SOURCES, index=0,
|
38 |
format_func=source2label,
|
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
|
@@ -66,6 +71,7 @@ for msg in memoryA.buffer_as_messages:
|
|
66 |
st.chat_message(role).write(msg.content)
|
67 |
|
68 |
if prompt := st.chat_input():
|
|
|
69 |
if 'convo_id' not in st.session_state:
|
70 |
push_convo2db(memories, username, language)
|
71 |
|
|
|
10 |
|
11 |
logger = get_logger(__name__)
|
12 |
openai_api_key = os.environ['OPENAI_API_KEY']
|
|
|
13 |
|
14 |
+
if "sent_messages" not in st.session_state:
|
15 |
+
st.session_state['sent_messages'] = 0
|
16 |
+
if "issue" not in st.session_state:
|
17 |
+
st.session_state['issue'] = ISSUES[0]
|
18 |
if 'previous_source' not in st.session_state:
|
19 |
st.session_state['previous_source'] = SOURCES[0]
|
20 |
if 'db_client' not in st.session_state:
|
|
|
25 |
st.session_state["texter_name"] = get_random_name(names_df=DEFAULT_NAMES_DF)
|
26 |
logger.info(f"texter name is {st.session_state['texter_name']}")
|
27 |
|
28 |
+
memories = {'memory':{"issue": st.session_state['issue'], "source": st.session_state['previous_source']}}
|
29 |
+
|
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)
|
|
|
42 |
source = st.selectbox("Select a source Model A", SOURCES, index=0,
|
43 |
format_func=source2label,
|
44 |
)
|
45 |
+
st.markdown(f"### Previous Prompt Count: :red[**{st.session_state['sent_messages']}**]")
|
46 |
|
|
|
47 |
changed_source = any([
|
48 |
st.session_state['previous_source'] != source,
|
49 |
st.session_state['issue'] != issue
|
|
|
71 |
st.chat_message(role).write(msg.content)
|
72 |
|
73 |
if prompt := st.chat_input():
|
74 |
+
st.session_state['sent_messages'] += 1
|
75 |
if 'convo_id' not in st.session_state:
|
76 |
push_convo2db(memories, username, language)
|
77 |
|
pages/comparisor.py
CHANGED
@@ -133,6 +133,8 @@ with st.sidebar:
|
|
133 |
format_func=source2label
|
134 |
)
|
135 |
|
|
|
|
|
136 |
sbcol1, sbcol2 = st.columns(2)
|
137 |
beta = sbcol1.button("A is better", on_click=replaceB)
|
138 |
betb = sbcol2.button("B is better", on_click=replaceA)
|
|
|
133 |
format_func=source2label
|
134 |
)
|
135 |
|
136 |
+
st.markdown(f"### Previous Prompt Count: :red[**{st.session_state['sent_messages']}**]")
|
137 |
+
|
138 |
sbcol1, sbcol2 = st.columns(2)
|
139 |
beta = sbcol1.button("A is better", on_click=replaceB)
|
140 |
betb = sbcol2.button("B is better", on_click=replaceA)
|