Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -173,83 +173,8 @@ def page1():
|
|
| 173 |
|
| 174 |
|
| 175 |
def page2():
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
<style>
|
| 179 |
-
#MainMenu {visibility: hidden;}
|
| 180 |
-
footer {visibility: hidden;}
|
| 181 |
-
</style>
|
| 182 |
-
"""
|
| 183 |
-
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
| 184 |
-
|
| 185 |
-
col1, col2 = st.columns([3, 1])
|
| 186 |
-
|
| 187 |
-
with col1:
|
| 188 |
-
st.title("Kodieren statt Frustrieren!")
|
| 189 |
-
|
| 190 |
-
with col2:
|
| 191 |
-
image = Image.open('BinDoc Logo (Quadratisch).png')
|
| 192 |
-
st.image(image, use_column_width='always')
|
| 193 |
-
|
| 194 |
-
if not os.path.exists(pdf_path2):
|
| 195 |
-
st.error("File not found. Please check the file path.")
|
| 196 |
-
return
|
| 197 |
-
|
| 198 |
-
VectorStore = load_vector_store(pdf_path2, "vector_store_page2", force_reload=False)
|
| 199 |
-
display_chat_history(st.session_state['chat_history_page2'])
|
| 200 |
-
|
| 201 |
-
st.write("<!-- Start Spacer -->", unsafe_allow_html=True)
|
| 202 |
-
st.write("<div style='flex: 1;'></div>", unsafe_allow_html=True)
|
| 203 |
-
st.write("<!-- End Spacer -->", unsafe_allow_html=True)
|
| 204 |
-
|
| 205 |
-
query = st.text_input("Ask questions about your PDF file (in any preferred language):")
|
| 206 |
-
add_vertical_space(2)
|
| 207 |
-
|
| 208 |
-
col1, col2 = st.columns(2)
|
| 209 |
-
|
| 210 |
-
with col1:
|
| 211 |
-
if st.button("Wann kodiere ich etwas als Hauptdiagnose und wann als Nebendiagnose?"):
|
| 212 |
-
query = "Wann kodiere ich etwas als Hauptdiagnose und wann als Nebendiagnose?"
|
| 213 |
-
if st.button("Ein Patient wird mit Aszites bei bekannter Leberzirrhose stationär aufgenommen. Es wird nur der Aszites durch eine Punktion behandelt. Wie kodiere ich das?"):
|
| 214 |
-
query = "Ein Patient wird mit Aszites bei bekannter Leberzirrhose stationär aufgenommen. Es wird nur der Aszites durch eine Punktion behandelt. Wie kodiere ich das?"
|
| 215 |
-
if st.button("Hauptdiagnose: Hirntumor wie kodiere ich das?"):
|
| 216 |
-
query = "Hauptdiagnose: Hirntumor wie kodiere ich das?"
|
| 217 |
-
|
| 218 |
-
with col2:
|
| 219 |
-
if st.button("Welche Prozeduren werden normalerweise nicht verschlüsselt?"):
|
| 220 |
-
query = "Welche Prozeduren werden normalerweise nicht verschlüsselt?"
|
| 221 |
-
if st.button("Was muss ich bei der Kodierung der Folgezustände von Krankheiten beachten?"):
|
| 222 |
-
query = "Was muss ich bei der Kodierung der Folgezustände von Krankheiten beachten?"
|
| 223 |
-
if st.button("Was mache ich bei einer Verdachtsdiagnose, wenn mein Patient nach Hause entlassen wird?"):
|
| 224 |
-
query = "Was mache ich bei einer Verdachtsdiagnose, wenn mein Patient nach Hause entlassen wird?"
|
| 225 |
-
|
| 226 |
-
if query:
|
| 227 |
-
st.session_state['chat_history_page2'].append(("User", query, "new"))
|
| 228 |
-
start_time = time.time()
|
| 229 |
-
with st.spinner('Bot is thinking...'):
|
| 230 |
-
chain = load_chatbot()
|
| 231 |
-
docs = VectorStore.similarity_search(query=query, k=3)
|
| 232 |
-
with get_openai_callback() as cb:
|
| 233 |
-
response = chain.run(input_documents=docs, question=query)
|
| 234 |
-
|
| 235 |
-
end_time = time.time()
|
| 236 |
-
duration = end_time - start_time
|
| 237 |
-
st.text(f"Response time: {duration:.2f} seconds")
|
| 238 |
-
|
| 239 |
-
st.session_state['chat_history_page2'].append(("Bot", response, "new"))
|
| 240 |
-
|
| 241 |
-
new_messages = st.session_state['chat_history_page2'][-2:]
|
| 242 |
-
for chat in new_messages:
|
| 243 |
-
background_color = "#ffeecf"
|
| 244 |
-
st.markdown(f"<div style='background-color: {background_color}; padding: 10px; border-radius: 10px; margin: 10px;'>{chat[0]}: {chat[1]}</div>", unsafe_allow_html=True)
|
| 245 |
-
|
| 246 |
-
query = ""
|
| 247 |
-
|
| 248 |
-
st.session_state['chat_history_page2'] = [(sender, msg, "old") for sender, msg, _ in st.session_state['chat_history_page2']]
|
| 249 |
-
|
| 250 |
-
except Exception as e:
|
| 251 |
-
st.error(f"Upsi, an unexpected error occurred: {e}")
|
| 252 |
-
|
| 253 |
|
| 254 |
def main():
|
| 255 |
# Sidebar content
|
|
|
|
| 173 |
|
| 174 |
|
| 175 |
def page2():
|
| 176 |
+
st.title('BinDoc GmbH')
|
| 177 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
def main():
|
| 180 |
# Sidebar content
|