Wajahat698 commited on
Commit
b554423
·
verified ·
1 Parent(s): dfca0d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -48,7 +48,8 @@ st.markdown("""
48
  }
49
  </style>
50
  """, unsafe_allow_html=True)
51
-
 
52
  def copy_to_clipboard(text):
53
  """Creates a button to copy text to clipboard."""
54
  escaped_text = text.replace('\n', '\\n').replace('"', '\\"')
@@ -364,9 +365,10 @@ for message in st.session_state.chat_history:
364
  st.markdown(message["content"])
365
 
366
  # Chat input
367
-
368
 
369
- st.markdown("""
 
370
  <script>
371
  document.addEventListener('DOMContentLoaded', (event) => {
372
  const svgs = document.querySelectorAll('svg');
@@ -473,7 +475,7 @@ def clean_text_for_markdown(text):
473
  prompt = st.chat_input("")
474
  if prompt :
475
 
476
-
477
  # Add user message to chat history
478
  st.session_state.chat_history.append({"role": "user", "content": prompt})
479
 
@@ -493,10 +495,11 @@ if prompt :
493
  "chat_history": st.session_state.chat_history
494
  })
495
  full_response = output["output"]
496
-
 
497
  # Display the response
498
 
499
- st.write(full_response)
500
  follow_up_output = agent_executor.invoke({
501
  "input": f"Extract 1-2 follow-up questions from the following text: {full_response}",
502
  "chat_history": st.session_state.chat_history
 
48
  }
49
  </style>
50
  """, unsafe_allow_html=True)
51
+ if "chat_started" not in st.session_state:
52
+ st.session_state["chat_started"] = False
53
  def copy_to_clipboard(text):
54
  """Creates a button to copy text to clipboard."""
55
  escaped_text = text.replace('\n', '\\n').replace('"', '\\"')
 
365
  st.markdown(message["content"])
366
 
367
  # Chat input
368
+ if not st.session_state.get("chat_started", False):
369
 
370
+
371
+ st.markdown("""
372
  <script>
373
  document.addEventListener('DOMContentLoaded', (event) => {
374
  const svgs = document.querySelectorAll('svg');
 
475
  prompt = st.chat_input("")
476
  if prompt :
477
 
478
+ st.session_state["chat_started"] = True
479
  # Add user message to chat history
480
  st.session_state.chat_history.append({"role": "user", "content": prompt})
481
 
 
495
  "chat_history": st.session_state.chat_history
496
  })
497
  full_response = output["output"]
498
+ st.write(full_response.replace("*", "").replace("_", "").replace("**", "").replace("__", ""))
499
+
500
  # Display the response
501
 
502
+ #st.write(full_response)
503
  follow_up_output = agent_executor.invoke({
504
  "input": f"Extract 1-2 follow-up questions from the following text: {full_response}",
505
  "chat_history": st.session_state.chat_history