Vasanth Sarathy commited on
Commit
590f599
1 Parent(s): d280084

fixing errors with running on HF spaces

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -8,18 +8,20 @@ css_style = """
8
  }
9
  """
10
 
11
- # Load the pre-created index
12
- index_filename = 'indices/index_vector_2100.json'
13
- index = GPTSimpleVectorIndex.load_from_disk(index_filename)
14
-
15
 
16
  def ask_question(question, openai_api_key):
17
  if len(openai_api_key) > 0:
18
  os.environ['OPENAI_API_KEY'] = openai_api_key.strip()
 
 
 
 
 
19
  prompt_template = "Provide references to sections in the MPEP"
20
  response = index.query(question + " " + prompt_template )
21
  return response.response
22
- return "Enter your OpenAI API key to use MPEP-QA"
 
23
 
24
  with gr.Blocks(css=css_style) as demo:
25
  openai_api_key = gr.State('')
 
8
  }
9
  """
10
 
 
 
 
 
11
 
12
  def ask_question(question, openai_api_key):
13
  if len(openai_api_key) > 0:
14
  os.environ['OPENAI_API_KEY'] = openai_api_key.strip()
15
+
16
+ # Load the pre-created index
17
+ index_filename = 'indices/index_vector_2100.json'
18
+ index = GPTSimpleVectorIndex.load_from_disk(index_filename)
19
+
20
  prompt_template = "Provide references to sections in the MPEP"
21
  response = index.query(question + " " + prompt_template )
22
  return response.response
23
+ return "Enter your OPENAI API key"
24
+
25
 
26
  with gr.Blocks(css=css_style) as demo:
27
  openai_api_key = gr.State('')