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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -6,6 +6,7 @@ import tensorflow_hub as hub
6
  import openai
7
  import gradio as gr
8
  import os
 
9
  from sklearn.neighbors import NearestNeighbors
10
 
11
 
@@ -147,8 +148,7 @@ def generate_answer(question, openAI_key):
147
 
148
 
149
  def question_answer(url, file, question, openAI_key):
150
- if openAI_key.strip() == '':
151
- return '[ERROR]: Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys'
152
  if url.strip() == '' and file == None:
153
  return '[ERROR]: Both URL and PDF is empty. Provide atleast one.'
154
 
@@ -192,7 +192,6 @@ with gr.Blocks() as iface:
192
  with gr.Row():
193
 
194
  with gr.Group():
195
- openAI_key = gr.Textbox(label='Enter your OpenAI API key here', placeholder='sk-')
196
  url = gr.Textbox(label='Enter PDF URL here', placeholder='https://docs.pdf')
197
  gr.Markdown(
198
  "<center><h4>----------------------------------------------------------------------------------------------------------------------------------------------------<h4></center>")
@@ -207,7 +206,8 @@ with gr.Blocks() as iface:
207
  lines=5, placeholder='Your answer here...')
208
 
209
  btn.click(question_answer, inputs=[
210
- url, file, question, openAI_key], outputs=[answer])
211
  # openai.api_key = os.getenv('Your_Key_Here')
 
212
  iface.launch()
213
- # iface.launch(share=True)
 
6
  import openai
7
  import gradio as gr
8
  import os
9
+ import dotenv
10
  from sklearn.neighbors import NearestNeighbors
11
 
12
 
 
148
 
149
 
150
  def question_answer(url, file, question, openAI_key):
151
+ openAI_key = os.environ.get('OPENAI_KEY')
 
152
  if url.strip() == '' and file == None:
153
  return '[ERROR]: Both URL and PDF is empty. Provide atleast one.'
154
 
 
192
  with gr.Row():
193
 
194
  with gr.Group():
 
195
  url = gr.Textbox(label='Enter PDF URL here', placeholder='https://docs.pdf')
196
  gr.Markdown(
197
  "<center><h4>----------------------------------------------------------------------------------------------------------------------------------------------------<h4></center>")
 
206
  lines=5, placeholder='Your answer here...')
207
 
208
  btn.click(question_answer, inputs=[
209
+ url, file, question], outputs=[answer])
210
  # openai.api_key = os.getenv('Your_Key_Here')
211
+ dotenv.load_dotenv()
212
  iface.launch()
213
+ # iface.launch(share=True)