Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -107,27 +107,44 @@ import random
|
|
107 |
def main():
|
108 |
st.title("BinDocs Chat App")
|
109 |
|
|
|
|
|
|
|
|
|
|
|
110 |
if "chat_history" not in st.session_state:
|
111 |
st.session_state['chat_history'] = []
|
112 |
|
113 |
display_chat_history(st.session_state['chat_history'])
|
114 |
|
|
|
|
|
|
|
|
|
115 |
new_messages_placeholder = st.empty()
|
116 |
|
117 |
-
|
|
|
|
|
|
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
|
126 |
-
|
127 |
-
st.
|
|
|
|
|
|
|
|
|
128 |
st.session_state['chat_history'].append(("User", query, "new"))
|
129 |
|
130 |
loading_message = st.empty()
|
|
|
131 |
loading_message.text('Bot is thinking...')
|
132 |
|
133 |
VectorStore = load_pdf(pdf_file_path)
|
|
|
107 |
def main():
|
108 |
st.title("BinDocs Chat App")
|
109 |
|
110 |
+
pdf_path = pdf_file_path
|
111 |
+
if not os.path.exists(pdf_path):
|
112 |
+
st.error("File not found. Please check the file path.")
|
113 |
+
return
|
114 |
+
|
115 |
if "chat_history" not in st.session_state:
|
116 |
st.session_state['chat_history'] = []
|
117 |
|
118 |
display_chat_history(st.session_state['chat_history'])
|
119 |
|
120 |
+
st.write("<!-- Start Spacer -->", unsafe_allow_html=True)
|
121 |
+
st.write("<div style='flex: 1;'></div>", unsafe_allow_html=True)
|
122 |
+
st.write("<!-- End Spacer -->", unsafe_allow_html=True)
|
123 |
+
|
124 |
new_messages_placeholder = st.empty()
|
125 |
|
126 |
+
if pdf_path is not None:
|
127 |
+
query = st.text_input("Ask questions about your PDF file (in any preferred language):")
|
128 |
+
|
129 |
+
col1, col2 = st.columns(2)
|
130 |
|
131 |
+
with col1:
|
132 |
+
st.header("Examples1")
|
133 |
+
if st.button("Was genau ist ein Belegarzt?"):
|
134 |
+
query = "Was genau ist ein Belegarzt?"
|
135 |
+
if st.button("Wofür wird die Alpha-ID verwendet?"):
|
136 |
+
query = "Wofür wird die Alpha-ID verwendet?"
|
137 |
|
138 |
+
with col2:
|
139 |
+
st.header("Examples2")
|
140 |
+
if st.button("Was sind die Vorteile des ambulanten operierens?"):
|
141 |
+
query = "Was sind die Vorteile des ambulanten operierens?"
|
142 |
+
|
143 |
+
if st.button("Ask") or (not st.session_state['chat_history'] and query) or (st.session_state['chat_history'] and query != st.session_state['chat_history'][-1][1]):
|
144 |
st.session_state['chat_history'].append(("User", query, "new"))
|
145 |
|
146 |
loading_message = st.empty()
|
147 |
+
|
148 |
loading_message.text('Bot is thinking...')
|
149 |
|
150 |
VectorStore = load_pdf(pdf_file_path)
|