rumaisa1054 commited on
Commit
47a2fd4
·
verified ·
1 Parent(s): 0fc2e4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py CHANGED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from responser import res
3
+ def main():
4
+ st.title("Doctor Chatbot")
5
+
6
+ # Initialize chat history if not already initialized
7
+ if "chat_messages" not in st.session_state:
8
+ st.session_state.chat_messages = []
9
+
10
+ # Display chat history
11
+ for message in st.session_state.chat_messages:
12
+ if message["role"] == "user":
13
+ st.text_area("User:", message["content"], height=40, key=f"user_{message['content']}", disabled=True)
14
+ else:
15
+ st.text_area("AI:", message["content"], height=40, key=f"ai_{message['content']}", disabled=True)
16
+
17
+ # User input
18
+ if prompt := st.chat_input("Welcome - How can I help you?"):
19
+ # Add user message to chat history
20
+ st.session_state.chat_messages.append({"role": "user", "content": prompt})
21
+
22
+ # Simulate AI response (replace this with your actual AI response logic)
23
+ response = res(prompt)
24
+
25
+ # Display user's message in chat message container
26
+ with st.chat_message("user"):
27
+ st.markdown(prompt)
28
+
29
+ # Display assistant's response in chat message container
30
+ with st.chat_message("assistant"):
31
+ st.markdown(response)
32
+
33
+ # Add assistant's response to chat history
34
+ st.session_state.chat_messages.append({"role": "assistant", "content": response})
35
+
36
+
37
+ if __name__ == "__main__":
38
+ main()