ELEVEN-001 commited on
Commit
b2b9ba7
1 Parent(s): 06fd46f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -11
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=0.7,
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. If the search results mention multiple subjects "\
124
- "with the same name, create separate answers for each. Only include information found in the results and "\
125
- "don't add any additional information. Make sure the answer is correct and don't output false content. "\
126
- "If the text does not relate to the query, simply state 'Text Not Found in PDF'. Ignore outlier "\
127
- "search results which has nothing to do with the question. Only answer what is asked. The "\
128
- "answer should be short and concise. Answer step-by-step. \n\nQuery: {question}\nAnswer: "\
129
- "if you are asked to make questions from the pdf that you are provided with, kindly make it according to the question"
 
 
 
 
 
 
 
 
 
 
 
 
 
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=['.pdf'])
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')