Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -513,7 +513,7 @@ def user_input(user_question):
|
|
| 513 |
{"input_documents":docs, "question": user_question}
|
| 514 |
, return_only_outputs=True)
|
| 515 |
|
| 516 |
-
pdfof = pdfans["output_text"]
|
| 517 |
|
| 518 |
return pdfof
|
| 519 |
|
|
@@ -782,14 +782,25 @@ if pdf_mode:
|
|
| 782 |
if pdf_mode:
|
| 783 |
prompt = None
|
| 784 |
prompty = st.chat_input("Write your questions according to the pdf")
|
| 785 |
-
if prompty:
|
| 786 |
-
prmt = {'role': 'user', 'parts':[prompty]}
|
| 787 |
-
usertxt = user_input(prompty)
|
| 788 |
-
append_message({'role': 'model', 'parts':usertxt})
|
| 789 |
else:
|
| 790 |
prompty = None
|
| 791 |
prompt = st.chat_input("Write your message")
|
| 792 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 793 |
if prompt:
|
| 794 |
txt = ''
|
| 795 |
|
|
|
|
| 513 |
{"input_documents":docs, "question": user_question}
|
| 514 |
, return_only_outputs=True)
|
| 515 |
|
| 516 |
+
pdfof = f'{pdfans["output_text"]}'
|
| 517 |
|
| 518 |
return pdfof
|
| 519 |
|
|
|
|
| 782 |
if pdf_mode:
|
| 783 |
prompt = None
|
| 784 |
prompty = st.chat_input("Write your questions according to the pdf")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 785 |
else:
|
| 786 |
prompty = None
|
| 787 |
prompt = st.chat_input("Write your message")
|
| 788 |
|
| 789 |
+
if prompty:
|
| 790 |
+
spinertxt = 'Wait a moment, I am thinking...'
|
| 791 |
+
prmt = {'role': 'user', 'parts':[prompty]}
|
| 792 |
+
append_message(prmt)
|
| 793 |
+
with st.spinner(spinertxt):
|
| 794 |
+
if len(prmt['parts'][0]) > 1:
|
| 795 |
+
usertxt = user_input(prompty)
|
| 796 |
+
|
| 797 |
+
try:
|
| 798 |
+
append_message({'role': 'model', 'parts':usertxt})
|
| 799 |
+
except Exception as e:
|
| 800 |
+
append_message({'role': 'model', 'parts':f'{type(e).__name__}: {e}'})
|
| 801 |
+
|
| 802 |
+
st.rerun()
|
| 803 |
+
|
| 804 |
if prompt:
|
| 805 |
txt = ''
|
| 806 |
|