Spaces:
Running
Running
Commit
·
54e37e6
1
Parent(s):
f82b5ba
Update app.py
Browse files
app.py
CHANGED
|
@@ -131,14 +131,14 @@ def generate_answer(question,openAI_key):
|
|
| 131 |
return answer
|
| 132 |
|
| 133 |
|
| 134 |
-
def question_answer(url, file, question,
|
| 135 |
-
if openAI_key.strip()
|
| 136 |
-
return '[ERROR]: Please enter
|
| 137 |
-
if url.strip() == '' and
|
| 138 |
-
return '[ERROR]: Both URL and PDF is empty. Provide
|
| 139 |
-
|
| 140 |
-
if url.strip() != '' and
|
| 141 |
-
return '[ERROR]: Both URL and PDF is provided. Please provide only one (
|
| 142 |
|
| 143 |
if url.strip() != '':
|
| 144 |
glob_url = url
|
|
@@ -146,9 +146,6 @@ def question_answer(url, file, question, openAI_key):
|
|
| 146 |
load_recommender('corpus.pdf')
|
| 147 |
|
| 148 |
else:
|
| 149 |
-
if file.size == 0:
|
| 150 |
-
return '[ERROR]: The uploaded file is empty. Please provide a non-empty PDF file.'
|
| 151 |
-
|
| 152 |
old_file_name = file.name
|
| 153 |
file_name = file.name
|
| 154 |
file_name = file_name[:-12] + file_name[-4:]
|
|
@@ -158,7 +155,7 @@ def question_answer(url, file, question, openAI_key):
|
|
| 158 |
if question.strip() == '':
|
| 159 |
return '[ERROR]: Question field is empty'
|
| 160 |
|
| 161 |
-
return generate_answer(question,
|
| 162 |
|
| 163 |
|
| 164 |
recommender = SemanticSearch()
|
|
|
|
| 131 |
return answer
|
| 132 |
|
| 133 |
|
| 134 |
+
def question_answer(url, file, question,openAI_key):
|
| 135 |
+
if openAI_key.strip()=='':
|
| 136 |
+
return '[ERROR]: Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys'
|
| 137 |
+
if url.strip() == '' and file == None:
|
| 138 |
+
return '[ERROR]: Both URL and PDF is empty. Provide atleast one.'
|
| 139 |
+
|
| 140 |
+
if url.strip() != '' and file != None:
|
| 141 |
+
return '[ERROR]: Both URL and PDF is provided. Please provide only one (eiter URL or PDF).'
|
| 142 |
|
| 143 |
if url.strip() != '':
|
| 144 |
glob_url = url
|
|
|
|
| 146 |
load_recommender('corpus.pdf')
|
| 147 |
|
| 148 |
else:
|
|
|
|
|
|
|
|
|
|
| 149 |
old_file_name = file.name
|
| 150 |
file_name = file.name
|
| 151 |
file_name = file_name[:-12] + file_name[-4:]
|
|
|
|
| 155 |
if question.strip() == '':
|
| 156 |
return '[ERROR]: Question field is empty'
|
| 157 |
|
| 158 |
+
return generate_answer(question,openAI_key)
|
| 159 |
|
| 160 |
|
| 161 |
recommender = SemanticSearch()
|