Spaces:
Sleeping
Sleeping
fixing displaying wrong number of total messages
Browse files- pages/convosim.py +2 -3
pages/convosim.py
CHANGED
@@ -94,7 +94,6 @@ memoryA = st.session_state[list(memories.keys())[0]]
|
|
94 |
llm_chain, stopper = get_chain(issue, language, source, memoryA, temperature, texter_name=st.session_state["texter_name"])
|
95 |
|
96 |
st.title("💬 Simulator")
|
97 |
-
st.session_state['total_messages'] = len(memoryA.chat_memory.messages)
|
98 |
for msg in memoryA.buffer_as_messages:
|
99 |
role = "user" if type(msg) == HumanMessage else "assistant"
|
100 |
st.chat_message(role).write(msg.content)
|
@@ -105,6 +104,7 @@ def sent_request_llm(llm_chain, prompt):
|
|
105 |
responses = custom_chain_predict(llm_chain, prompt, stopper)
|
106 |
for response in responses:
|
107 |
st.chat_message("assistant").write(response)
|
|
|
108 |
transcript = memoryA.load_memory_variables({})[memoryA.memory_key]
|
109 |
update_convo(st.session_state["db_client"], st.session_state["convo_id"], transcript)
|
110 |
|
@@ -143,7 +143,7 @@ def push_latest_confirmation_db():
|
|
143 |
else:
|
144 |
bp_push2db({x['label']:x['score'] for x in st.session_state['bp_prediction']})
|
145 |
|
146 |
-
disable_chat = (st.session_state['total_messages'] > MAX_MSG_COUNT -
|
147 |
if prompt := st.chat_input(disabled=disable_chat): #account for next interaction
|
148 |
st.session_state['last_message_ts'] = time.time()
|
149 |
if 'convo_id' not in st.session_state:
|
@@ -206,7 +206,6 @@ with st.sidebar:
|
|
206 |
update_convo(st.session_state["db_client"], st.session_state["convo_id"], transcript)
|
207 |
st.switch_page("pages/training_adherence.py")
|
208 |
|
209 |
-
st.session_state['total_messages'] = len(memoryA.chat_memory.messages)
|
210 |
if st.session_state['total_messages'] >= MAX_MSG_COUNT:
|
211 |
st.toast(f"Total of {MAX_MSG_COUNT} Messages reached. Conversation Ended", icon=":material/verified:")
|
212 |
elif st.session_state['total_messages'] >= WARN_MSG_COUT:
|
|
|
94 |
llm_chain, stopper = get_chain(issue, language, source, memoryA, temperature, texter_name=st.session_state["texter_name"])
|
95 |
|
96 |
st.title("💬 Simulator")
|
|
|
97 |
for msg in memoryA.buffer_as_messages:
|
98 |
role = "user" if type(msg) == HumanMessage else "assistant"
|
99 |
st.chat_message(role).write(msg.content)
|
|
|
104 |
responses = custom_chain_predict(llm_chain, prompt, stopper)
|
105 |
for response in responses:
|
106 |
st.chat_message("assistant").write(response)
|
107 |
+
st.session_state['total_messages'] = len(memoryA.chat_memory.messages)
|
108 |
transcript = memoryA.load_memory_variables({})[memoryA.memory_key]
|
109 |
update_convo(st.session_state["db_client"], st.session_state["convo_id"], transcript)
|
110 |
|
|
|
143 |
else:
|
144 |
bp_push2db({x['label']:x['score'] for x in st.session_state['bp_prediction']})
|
145 |
|
146 |
+
disable_chat = (st.session_state['total_messages'] > MAX_MSG_COUNT - 2) and not st.session_state['scored']
|
147 |
if prompt := st.chat_input(disabled=disable_chat): #account for next interaction
|
148 |
st.session_state['last_message_ts'] = time.time()
|
149 |
if 'convo_id' not in st.session_state:
|
|
|
206 |
update_convo(st.session_state["db_client"], st.session_state["convo_id"], transcript)
|
207 |
st.switch_page("pages/training_adherence.py")
|
208 |
|
|
|
209 |
if st.session_state['total_messages'] >= MAX_MSG_COUNT:
|
210 |
st.toast(f"Total of {MAX_MSG_COUNT} Messages reached. Conversation Ended", icon=":material/verified:")
|
211 |
elif st.session_state['total_messages'] >= WARN_MSG_COUT:
|