Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -113,34 +113,29 @@ def main():
|
|
| 113 |
|
| 114 |
new_messages_placeholder = st.empty()
|
| 115 |
|
| 116 |
-
pdf = st.file_uploader("Upload your PDF", type="pdf")
|
| 117 |
-
|
| 118 |
query = st.text_input("Ask questions about your PDF file (in any preferred language):")
|
| 119 |
|
| 120 |
-
if
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
with get_openai_callback() as cb:
|
| 143 |
-
response = chain.run(input_documents=docs, question=query)
|
| 144 |
|
| 145 |
# Post-processing to remove incomplete sentences and redundant information
|
| 146 |
filtered_response = remove_incomplete_sentences(response)
|
|
|
|
| 113 |
|
| 114 |
new_messages_placeholder = st.empty()
|
| 115 |
|
|
|
|
|
|
|
| 116 |
query = st.text_input("Ask questions about your PDF file (in any preferred language):")
|
| 117 |
|
| 118 |
+
if st.button("Was genau ist ein Belegarzt?"):
|
| 119 |
+
query = "Was genau ist ein Belegarzt?"
|
| 120 |
+
if st.button("Wofür wird die Alpha-ID verwendet?"):
|
| 121 |
+
query = "Wofür wird die Alpha-ID verwendet?"
|
| 122 |
+
if st.button("Was sind die Vorteile des ambulanten operierens?"):
|
| 123 |
+
query = "Was sind die Vorteile des ambulanten operierens?"
|
| 124 |
+
|
| 125 |
+
if query:
|
| 126 |
+
st.session_state['last_input'] = query
|
| 127 |
+
st.session_state['chat_history'].append(("User", query, "new"))
|
| 128 |
+
|
| 129 |
+
loading_message = st.empty()
|
| 130 |
+
loading_message.text('Bot is thinking...')
|
| 131 |
+
|
| 132 |
+
VectorStore = load_pdf(pdf_file_path)
|
| 133 |
+
max_tokens = 120
|
| 134 |
+
chain = load_chatbot(max_tokens=max_tokens)
|
| 135 |
+
docs = VectorStore.similarity_search(query=query, k=2)
|
| 136 |
+
|
| 137 |
+
with get_openai_callback() as cb:
|
| 138 |
+
response = chain.run(input_documents=docs, question=query)
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
# Post-processing to remove incomplete sentences and redundant information
|
| 141 |
filtered_response = remove_incomplete_sentences(response)
|