SaileshSivan commited on
Commit
da6c21b
·
1 Parent(s): 3437930

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -23
app.py CHANGED
@@ -86,37 +86,75 @@ if 'flowmessages' not in st.session_state:
86
 
87
  ]
88
 
89
- # Display conversation history in sidebar
90
- with st.sidebar:
91
- st.title("Chat History")
92
- for message in reversed(st.session_state["flowmessages"]):
93
- if isinstance(message, AIMessage):
94
- st.header("Doctor AI", divider=True)
95
- st.write(message.content)
96
- elif isinstance(message, HumanMessage):
97
- st.header(":blue[You]", divider=True)
98
- st.write(message.content)
99
-
100
- # Main container for input form
101
- with st.container():
102
- # Input form at the bottom
103
- with st.form(key="my_form", clear_on_submit=True):
104
- input_question = st.text_input("Type here.")
105
- submit = st.form_submit_button("Ask Doctor AI")
106
-
107
- # If the "Submit" button is clicked
108
- if submit:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  # Get Doctor AI's response
110
  response = get_chatmodel_response(input_question)
111
 
112
  if response is not None:
113
- # Display conversation history in main container
114
- for message in reversed(st.session_state["flowmessages"]):
115
  if isinstance(message, AIMessage):
116
  st.header("Doctor AI", divider=True)
117
  st.write(message.content)
118
  elif isinstance(message, HumanMessage):
119
  st.header(":blue[You]", divider=True)
120
  st.write(message.content)
 
 
 
121
  else:
122
- st.subheader("Error: Unable to get response. Please try again later.")
 
 
 
 
86
 
87
  ]
88
 
89
+
90
+
91
+ # Streamlit UI
92
+ with st.form(key='my_form', clear_on_submit=True):
93
+ st.markdown(
94
+ """
95
+ <style>
96
+ .stTextInput {
97
+ border-radius: 15px;
98
+ padding: 12px;
99
+ margin-top: 10px;
100
+ margin-bottom: 10px;
101
+ box-shadow: 2px 2px 5px #888888;
102
+ border: 1px solid #dddddd;
103
+ font-size: 16px;
104
+ width: 100%;
105
+ height: 100px;
106
+ }
107
+ .blue-text {
108
+ color: blue;
109
+ }
110
+ .black-text {
111
+ color: black;
112
+ }
113
+ .separator {
114
+ border-top: 2px solid #888888;
115
+ margin-top: 10px;
116
+ margin-bottom: 10px;
117
+ }
118
+ </style>
119
+ """,
120
+ unsafe_allow_html=True
121
+ )
122
+
123
+ input_question = st.text_input("Type here.", key="input")
124
+ submit = st.form_submit_button("Ask Doctor AI")
125
+
126
+
127
+
128
+
129
+ # Add a "Clear Chat" button next to the "Submit" button
130
+ clear_chat_button = st.button("Clear Chat", key="clear_button", help="Clear Chat")
131
+
132
+ # If the "Clear Chat" button is clicked
133
+ if clear_chat_button:
134
+ # Clear the entire session and chat
135
+ st.session_state['flowmessages'] = []
136
+
137
+ # If the "Submit" button is clicked
138
+ if submit:
139
+ # Display loading message while processing
140
+ with st.spinner("Analyzing..."):
141
  # Get Doctor AI's response
142
  response = get_chatmodel_response(input_question)
143
 
144
  if response is not None:
145
+ # Display conversation history
146
+ for message in st.session_state['flowmessages']:
147
  if isinstance(message, AIMessage):
148
  st.header("Doctor AI", divider=True)
149
  st.write(message.content)
150
  elif isinstance(message, HumanMessage):
151
  st.header(":blue[You]", divider=True)
152
  st.write(message.content)
153
+
154
+
155
+
156
  else:
157
+ st.subheader("Error: Unable to get response. Please try again later.")
158
+
159
+
160
+