ofermend commited on
Commit
4e8669d
1 Parent(s): fa5195a
Files changed (1) hide show
  1. st_app.py +7 -10
st_app.py CHANGED
@@ -22,6 +22,10 @@ def show_example_questions():
22
  return True
23
  return False
24
 
 
 
 
 
25
  def agent_progress_callback(status_type: AgentStatusType, msg: str):
26
  output = f'<span style="color:blue;">{status_type.value}</span>: {msg}'
27
  st.session_state.log_messages.append(output)
@@ -37,22 +41,15 @@ def agent_progress_callback(status_type: AgentStatusType, msg: str):
37
  return
38
 
39
  st.session_state.status.update(label=latest_message)
40
- max_log_msg_size = 500
41
  with st.session_state.status:
42
  for log_msg in st.session_state.log_messages:
43
- if len(log_msg) > max_log_msg_size:
44
- st.markdown(log_msg[:max_log_msg_size]+'...', unsafe_allow_html=True)
45
- else:
46
- st.markdown(log_msg, unsafe_allow_html=True)
47
 
48
  @st.dialog(title="Agent logs", width='large')
49
  def show_modal():
50
- max_log_msg_size = 500
51
  for log_msg in st.session_state.log_messages:
52
- if len(log_msg) > max_log_msg_size:
53
- st.write(log_msg[:max_log_msg_size]+'...', unsafe_allow_html=True)
54
- else:
55
- st.write(log_msg, unsafe_allow_html=True)
56
 
57
  async def launch_bot():
58
  def reset():
 
22
  return True
23
  return False
24
 
25
+ def format_log_msg(log_msg: str):
26
+ max_log_msg_size = 500
27
+ return log_msg if len(log_msg) <= max_log_msg_size else log_msg[:max_log_msg_size]+'...'
28
+
29
  def agent_progress_callback(status_type: AgentStatusType, msg: str):
30
  output = f'<span style="color:blue;">{status_type.value}</span>: {msg}'
31
  st.session_state.log_messages.append(output)
 
41
  return
42
 
43
  st.session_state.status.update(label=latest_message)
44
+
45
  with st.session_state.status:
46
  for log_msg in st.session_state.log_messages:
47
+ st.markdown(format_log_msg(log_msg), unsafe_allow_html=True)
 
 
 
48
 
49
  @st.dialog(title="Agent logs", width='large')
50
  def show_modal():
 
51
  for log_msg in st.session_state.log_messages:
52
+ st.markdown(format_log_msg(log_msg), unsafe_allow_html=True)
 
 
 
53
 
54
  async def launch_bot():
55
  def reset():