Spaces:
Build error
Build error
Commit
·
b2b9ba7
1
Parent(s):
06fd46f
Update app.py
Browse files
app.py
CHANGED
|
@@ -105,7 +105,7 @@ def generate_text(openAI_key, prompt, engine="text-davinci-003"):
|
|
| 105 |
max_tokens=512,
|
| 106 |
n=1,
|
| 107 |
stop=None,
|
| 108 |
-
temperature=
|
| 109 |
)
|
| 110 |
message = completions.choices[0].text
|
| 111 |
return message
|
|
@@ -118,15 +118,28 @@ def generate_answer(question, openAI_key):
|
|
| 118 |
for c in topn_chunks:
|
| 119 |
prompt += c + '\n\n'
|
| 120 |
|
| 121 |
-
prompt += "Instructions: Compose a comprehensive reply to the query using the search results given.
|
| 122 |
-
"Cite each reference using [ Page Number] notation (every result has this number at the beginning).
|
| 123 |
-
"Citation should be done at the end of each sentence.
|
| 124 |
-
"with the same name, create separate answers for each.
|
| 125 |
-
"
|
| 126 |
-
"
|
| 127 |
-
"
|
| 128 |
-
"
|
| 129 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
prompt += f"Query: {question}\nAnswer:"
|
| 132 |
answer = generate_text(openAI_key, prompt, "text-davinci-003")
|
|
@@ -183,7 +196,7 @@ with gr.Blocks() as iface:
|
|
| 183 |
url = gr.Textbox(label='Enter PDF URL here', placeholder='https://docs.pdf')
|
| 184 |
gr.Markdown(
|
| 185 |
"<center><h4>----------------------------------------------------------------------------------------------------------------------------------------------------<h4></center>")
|
| 186 |
-
file = gr.File(label='Drop PDF here', file_types=['
|
| 187 |
question = gr.Textbox(
|
| 188 |
label='Enter your question here', placeholder='Type your question here')
|
| 189 |
btn = gr.Button(value='Submit')
|
|
|
|
| 105 |
max_tokens=512,
|
| 106 |
n=1,
|
| 107 |
stop=None,
|
| 108 |
+
temperature=1,
|
| 109 |
)
|
| 110 |
message = completions.choices[0].text
|
| 111 |
return message
|
|
|
|
| 118 |
for c in topn_chunks:
|
| 119 |
prompt += c + '\n\n'
|
| 120 |
|
| 121 |
+
prompt += "Instructions: Compose a comprehensive reply to the query using the search results given."\
|
| 122 |
+
"Cite each reference using [ Page Number] notation (every result has this number at the beginning)."\
|
| 123 |
+
"Citation should be done at the end of each sentence."\
|
| 124 |
+
"If the search results mention multiple subjects with the same name, create separate answers for each."\
|
| 125 |
+
"Only include information found in the results and don't add any additional information."\
|
| 126 |
+
"Make sure the answer is correct and don't output false content."\
|
| 127 |
+
"If the text does not relate to the query, simply state 'Text Not Found in PDF'."\
|
| 128 |
+
"Ignore outlier search results which have nothing to do with the question."\
|
| 129 |
+
"Only answer what is asked."\
|
| 130 |
+
"The answer should be short and concise."\
|
| 131 |
+
"Answer step-by-step."\
|
| 132 |
+
"To answer the query, please follow these instructions:"\
|
| 133 |
+
"Please carefully read through the search results provided and compose a clear and concise response."\
|
| 134 |
+
"When citing information from the search results, please include the page number in square brackets after the relevant text."\
|
| 135 |
+
"If the search results mention multiple subjects with the same name, create separate answers for each."\
|
| 136 |
+
"Only include information found in the search results and avoid adding any additional information."\
|
| 137 |
+
"Be sure that your response is accurate and does not contain any false content."\
|
| 138 |
+
"If the query cannot be answered using the provided search results, please state [Text Not Found in PDF.]"\
|
| 139 |
+
"Please disregard any irrelevant search results and only include information that directly answers the question."\
|
| 140 |
+
"Your response should be step-by-step and easy to understand."\
|
| 141 |
+
"Good luck!"
|
| 142 |
+
|
| 143 |
|
| 144 |
prompt += f"Query: {question}\nAnswer:"
|
| 145 |
answer = generate_text(openAI_key, prompt, "text-davinci-003")
|
|
|
|
| 196 |
url = gr.Textbox(label='Enter PDF URL here', placeholder='https://docs.pdf')
|
| 197 |
gr.Markdown(
|
| 198 |
"<center><h4>----------------------------------------------------------------------------------------------------------------------------------------------------<h4></center>")
|
| 199 |
+
file = gr.File(label='Drop PDF here', file_types=['*'])
|
| 200 |
question = gr.Textbox(
|
| 201 |
label='Enter your question here', placeholder='Type your question here')
|
| 202 |
btn = gr.Button(value='Submit')
|