bhaskartripathi commited on
Commit
de17ddb
1 Parent(s): 3a69038

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -101,10 +101,12 @@ def load_recommender(path, openAI_key, start_page=1):
101
  global recommender
102
  texts = pdf_to_text(path, start_page=start_page)
103
  chunks = text_to_chunks(texts, start_page=start_page)
104
- recommender = SemanticSearch()
105
  recommender.fit(chunks)
106
  return 'Corpus Loaded.'
107
 
 
 
108
  def generate_text(openAI_key, prompt, engine="text-davinci-003"):
109
  openai.api_key = openAI_key
110
  completions = openai.Completion.create(
@@ -193,4 +195,9 @@ with gr.Blocks() as demo:
193
  btn.click(question_answer, inputs=[url, file, question, openAI_key], outputs=[answer])
194
 
195
  demo.launch()
196
- recommender = SemanticSearch()
 
 
 
 
 
 
101
  global recommender
102
  texts = pdf_to_text(path, start_page=start_page)
103
  chunks = text_to_chunks(texts, start_page=start_page)
104
+ recommender = SemanticSearch(openAI_key) # add the openAI_key parameter here
105
  recommender.fit(chunks)
106
  return 'Corpus Loaded.'
107
 
108
+
109
+
110
  def generate_text(openAI_key, prompt, engine="text-davinci-003"):
111
  openai.api_key = openAI_key
112
  completions = openai.Completion.create(
 
195
  btn.click(question_answer, inputs=[url, file, question, openAI_key], outputs=[answer])
196
 
197
  demo.launch()
198
+
199
+ # remove this line
200
+ recommender = SemanticSearch(openAI_key)
201
+
202
+ # call load_recommender instead to initialize recommender
203
+ load_recommender('corpus.pdf', openAI_key)