bhaskartripathi commited on
Commit
9efa4bb
1 Parent(s): b6e2b19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -118,7 +118,7 @@ def load_recommender(path, start_page=1):
118
 
119
 
120
 
121
- def generate_text2(openAI_key,prompt, engine="text-davinci-003"):
122
  openai.api_key = openAI_key
123
  completions = openai.Completion.create(
124
  engine=engine,
@@ -131,7 +131,7 @@ def generate_text2(openAI_key,prompt, engine="text-davinci-003"):
131
  message = completions.choices[0].text
132
  return message
133
 
134
- def generate_text(openAI_key, prompt, engine="gpt-3.5-turbo-0301"):
135
  openai.api_key = openAI_key
136
  messages = [{'role': 'system', 'content': 'You are a helpful assistant.'},
137
  {'role': 'user', 'content': prompt}]
@@ -155,13 +155,13 @@ def generate_answer(question,openAI_key):
155
  prompt += c + '\n\n'
156
 
157
  prompt += "Instructions: Compose a comprehensive reply to the query using the search results given. "\
158
- "Cite each reference using [number] notation (every result has this number at the beginning). "\
159
  "Citation should be done at the end of each sentence. If the search results mention multiple subjects "\
160
  "with the same name, create separate answers for each. Only include information found in the results and "\
161
  "don't add any additional information. Make sure the answer is correct and don't output false content. "\
162
- "If the text does not relate to the query, simply state 'Found Nothing'. Ignore outlier "\
163
  "search results which has nothing to do with the question. Only answer what is asked. The "\
164
- "answer should be short and concise.\n\nQuery: {question}\nAnswer: "
165
 
166
  prompt += f"Query: {question}\nAnswer:"
167
  answer = generate_text(openAI_key, prompt,"text-davinci-003")
 
118
 
119
 
120
 
121
+ def generate_text(openAI_key,prompt, engine="text-davinci-003"):
122
  openai.api_key = openAI_key
123
  completions = openai.Completion.create(
124
  engine=engine,
 
131
  message = completions.choices[0].text
132
  return message
133
 
134
+ def generate_text2(openAI_key, prompt, engine="gpt-3.5-turbo-0301"):
135
  openai.api_key = openAI_key
136
  messages = [{'role': 'system', 'content': 'You are a helpful assistant.'},
137
  {'role': 'user', 'content': prompt}]
 
155
  prompt += c + '\n\n'
156
 
157
  prompt += "Instructions: Compose a comprehensive reply to the query using the search results given. "\
158
+ "Cite each reference using [ Page Number] notation (every result has this number at the beginning). "\
159
  "Citation should be done at the end of each sentence. If the search results mention multiple subjects "\
160
  "with the same name, create separate answers for each. Only include information found in the results and "\
161
  "don't add any additional information. Make sure the answer is correct and don't output false content. "\
162
+ "If the text does not relate to the query, simply state 'Text Not Found in PDF'. Ignore outlier "\
163
  "search results which has nothing to do with the question. Only answer what is asked. The "\
164
+ "answer should be short and concise. Answer step-by-step. \n\nQuery: {question}\nAnswer: "
165
 
166
  prompt += f"Query: {question}\nAnswer:"
167
  answer = generate_text(openAI_key, prompt,"text-davinci-003")