Singularity666 commited on
Commit
473583b
·
1 Parent(s): 36b2997

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -12,6 +12,8 @@ from reportlab.pdfgen import canvas
12
  import docx
13
  from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
14
  from io import BytesIO
 
 
15
 
16
  # Set up OpenAI API
17
  openai.api_key = "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"
@@ -109,11 +111,20 @@ if uploaded_file is not None:
109
  # Add the chatbot functionality
110
  st.header("1-to-1 Consultation")
111
  st.write("Ask any questions you have about the radiology report:")
 
 
 
 
112
  user_input = st.text_input("Enter your question:")
113
  if user_input:
 
114
  if user_input.lower() == "thank you":
115
- st.write("You're welcome! If you have any more questions, feel free to ask.")
116
  else:
117
  # Add the OpenAI API call here and generate the answer to the user's question
118
  answer = f"Answer to the user's question based on the generated radiology report: {user_input}"
119
- st.write(answer)
 
 
 
 
 
12
  import docx
13
  from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
14
  from io import BytesIO
15
+ import session_state # Import SessionState
16
+
17
 
18
  # Set up OpenAI API
19
  openai.api_key = "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"
 
111
  # Add the chatbot functionality
112
  st.header("1-to-1 Consultation")
113
  st.write("Ask any questions you have about the radiology report:")
114
+
115
+ # Use SessionState to store the chat history
116
+ state = session_state.get(chat_history=[])
117
+
118
  user_input = st.text_input("Enter your question:")
119
  if user_input:
120
+ state.chat_history.append(f"You: {user_input}")
121
  if user_input.lower() == "thank you":
122
+ state.chat_history.append("Bot: You're welcome! If you have any more questions, feel free to ask.")
123
  else:
124
  # Add the OpenAI API call here and generate the answer to the user's question
125
  answer = f"Answer to the user's question based on the generated radiology report: {user_input}"
126
+ state.chat_history.append(f"Bot: {answer}")
127
+
128
+ # Display the chat history
129
+ for message in state.chat_history:
130
+ st.write(message)