PearlIsa commited on
Commit
ab1f9e0
·
verified ·
1 Parent(s): 9d64f0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -1013,8 +1013,11 @@ def chat(message: str, history: List[tuple]) -> List[tuple]:
1013
 
1014
  response_data = rag_system.generate_response(message, history)
1015
  response = process_chat_response(response_data, message, history)
1016
- history.append((message, response))
 
 
1017
  return history
 
1018
  except Exception as e:
1019
  logger.error(f"Error in chat: {e}")
1020
  emergency_response = (
@@ -1024,7 +1027,8 @@ def chat(message: str, history: List[tuple]) -> List[tuple]:
1024
  "- Visit NHS 111 online for non-urgent concerns\n\n"
1025
  "Would you like to try asking your question again?"
1026
  )
1027
- history.append((message, emergency_response))
 
1028
  return history
1029
 
1030
  # Initialize RAG system globally
@@ -1044,7 +1048,7 @@ title = """
1044
  <div style="text-align: center; max-width: 700px; margin: 0 auto;">
1045
  <h1>Pearly Medical Assistant</h1>
1046
  <p>Hi! I'm Pearly, your GP medical assistant. I can help assess your symptoms,
1047
- provide medical guidance, and assist with finding appropriate care.</p>
1048
  <p style="color: #666; font-size: 0.9em;">For emergencies, always call 999</p>
1049
  </div>
1050
  """
@@ -1052,7 +1056,7 @@ title = """
1052
  with gr.Blocks(css="footer {display: none}") as demo:
1053
  gr.HTML(title)
1054
  chatbot = gr.Chatbot(
1055
- value=[(None, "Hi! I'm Pearly, your GP medical assistant. How can I help you today?")],
1056
  height=600,
1057
  type="messages",
1058
  label="Medical Consultation"
 
1013
 
1014
  response_data = rag_system.generate_response(message, history)
1015
  response = process_chat_response(response_data, message, history)
1016
+ # Convert to message format
1017
+ history.append({"role": "user", "content": message})
1018
+ history.append({"role": "assistant", "content": response})
1019
  return history
1020
+
1021
  except Exception as e:
1022
  logger.error(f"Error in chat: {e}")
1023
  emergency_response = (
 
1027
  "- Visit NHS 111 online for non-urgent concerns\n\n"
1028
  "Would you like to try asking your question again?"
1029
  )
1030
+ history.append({"role": "user", "content": message})
1031
+ history.append({"role": "assistant", "content": emergency_response})
1032
  return history
1033
 
1034
  # Initialize RAG system globally
 
1048
  <div style="text-align: center; max-width: 700px; margin: 0 auto;">
1049
  <h1>Pearly Medical Assistant</h1>
1050
  <p>Hi! I'm Pearly, your GP medical assistant. I can help assess your symptoms,
1051
+ provide medical guidance and assist with finding appropriate care.</p>
1052
  <p style="color: #666; font-size: 0.9em;">For emergencies, always call 999</p>
1053
  </div>
1054
  """
 
1056
  with gr.Blocks(css="footer {display: none}") as demo:
1057
  gr.HTML(title)
1058
  chatbot = gr.Chatbot(
1059
+ value=[{"role": "assistant", "content": "Hi! I'm Pearly, your GP medical assistant. How can I help you today?"}],
1060
  height=600,
1061
  type="messages",
1062
  label="Medical Consultation"