wholewhale commited on
Commit
6989cae
·
1 Parent(s): 84c1c08
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -90,6 +90,7 @@ class SemanticSearch:
90
  return embeddings
91
 
92
 
 
93
  def load_recommender(path, start_page=1):
94
  global recommender
95
  texts = pdf_to_text(path, start_page=start_page)
@@ -98,8 +99,8 @@ def load_recommender(path, start_page=1):
98
  return 'Corpus Loaded.'
99
 
100
 
101
- def generate_text(prompt, engine="gpt-3.5-turbo-16k"):
102
- openai.api_key = os.getenv('YOUR_KEY_HERE')
103
  completions = openai.Completion.create(
104
  engine=engine,
105
  prompt=prompt,
@@ -129,7 +130,7 @@ def generate_answer(question):
129
  "answer should be short and concise. \n\nQuery: {question}\nAnswer: "
130
 
131
  prompt += f"Query: {question}\nAnswer:"
132
- answer = generate_text(prompt,"gpt-3.5-turbo-16k")
133
  return answer
134
 
135
 
@@ -160,8 +161,8 @@ def question_answer(url, file, question):
160
 
161
  recommender = SemanticSearch()
162
 
163
- title = 'CauseWriter.ai PDF'
164
- description = """ PDF GPT allows you to chat with your PDF file using Universal Sentence Encoder and Open AI. The returned response can even cite the page number in square brackets([]) where the information is located, adding credibility to the responses and helping to locate pertinent information quickly."""
165
 
166
 
167
  with gr.Blocks() as demo:
@@ -184,4 +185,4 @@ with gr.Blocks() as demo:
184
 
185
  btn.click(question_answer, inputs=[url, file, question], outputs=[answer])
186
 
187
- demo.launch()
 
90
  return embeddings
91
 
92
 
93
+
94
  def load_recommender(path, start_page=1):
95
  global recommender
96
  texts = pdf_to_text(path, start_page=start_page)
 
99
  return 'Corpus Loaded.'
100
 
101
 
102
+ def generate_text(prompt, engine="text-davinci-003"):
103
+ openai.api_key = os.getenv('Your_Key_Here')
104
  completions = openai.Completion.create(
105
  engine=engine,
106
  prompt=prompt,
 
130
  "answer should be short and concise. \n\nQuery: {question}\nAnswer: "
131
 
132
  prompt += f"Query: {question}\nAnswer:"
133
+ answer = generate_text(prompt,"text-davinci-003")
134
  return answer
135
 
136
 
 
161
 
162
  recommender = SemanticSearch()
163
 
164
+ title = 'CauseWriter PDF'
165
+ description = """ PDF GPT allows you to chat with your PDF file using Universal Sentence Encoder and Open AI. It gives hallucination free response than other tools as the embeddings are better than OpenAI. The returned response can even cite the page number in square brackets([]) where the information is located, adding credibility to the responses and helping to locate pertinent information quickly."""
166
 
167
 
168
  with gr.Blocks() as demo:
 
185
 
186
  btn.click(question_answer, inputs=[url, file, question], outputs=[answer])
187
 
188
+ demo.launch()