ledetele commited on
Commit
18e4a0a
·
1 Parent(s): d453da8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -138,10 +138,10 @@ def question_answer(url, file, question):
138
  #if openAI_key.strip()=='':
139
  # return '[ERROR]: Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys'
140
  if url.strip() == '' and file == None:
141
- return '[ERROR]: URL 和 PDF 都是空的。 至少提供一個。'
142
 
143
  if url.strip() != '' and file != None:
144
- return '[ERROR]: 提供了 URL 和 PDF 請僅提供一個(網址或 PDF)。'
145
 
146
  if url.strip() != '':
147
  glob_url = url
@@ -156,14 +156,14 @@ def question_answer(url, file, question):
156
  load_recommender(file_name)
157
 
158
  if question.strip() == '':
159
- return '[ERROR]: 問題字段為空'
160
 
161
  return generate_answer(question,api_key)
162
 
163
 
164
  recommender = SemanticSearch()
165
 
166
- title = 'AI Pdf 歸納器'
167
  #description = """ KrystalPDF AI allows you to chat with your PDF file. It gives hallucination free response than other tools. 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."""
168
 
169
  with gr.Blocks() as demo:
@@ -176,15 +176,15 @@ with gr.Blocks() as demo:
176
  with gr.Group():
177
  #gr.Markdown(f'<p style="text-align:center">Get your Open AI API key <a href="https://platform.openai.com/account/api-keys">here</a></p>')
178
  #openAI_key=gr.Textbox(label='Enter your OpenAI API key here')
179
- url = gr.Textbox(label='在此處輸入 PDF 網址')
180
  gr.Markdown("<center><h4>或<h4></center>")
181
- file = gr.File(label='在此處上傳您的 PDF/研究論文/書籍', file_types=['.pdf'])
182
- question = gr.Textbox(label='在這裡輸入您的問題')
183
  btn = gr.Button(value='提交')
184
  btn.style(full_width=True)
185
 
186
  with gr.Group():
187
- answer = gr.Textbox(label='你的提問的答案是:')
188
 
189
  #openAI_key=api_key
190
  btn.click(question_answer, inputs=[url, file, question], outputs=[answer])
 
138
  #if openAI_key.strip()=='':
139
  # return '[ERROR]: Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys'
140
  if url.strip() == '' and file == None:
141
+ return '[ERROR]: URL 和 PDF 都是空的。至少提供一个。'
142
 
143
  if url.strip() != '' and file != None:
144
+ return '[ERROR]: 提供了 URL 和 PDF。请仅提供一个(网址或 PDF)。'
145
 
146
  if url.strip() != '':
147
  glob_url = url
 
156
  load_recommender(file_name)
157
 
158
  if question.strip() == '':
159
+ return '[ERROR]: 问题字段为空'
160
 
161
  return generate_answer(question,api_key)
162
 
163
 
164
  recommender = SemanticSearch()
165
 
166
+ title = 'AI Pdf 归纳器'
167
  #description = """ KrystalPDF AI allows you to chat with your PDF file. It gives hallucination free response than other tools. 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."""
168
 
169
  with gr.Blocks() as demo:
 
176
  with gr.Group():
177
  #gr.Markdown(f'<p style="text-align:center">Get your Open AI API key <a href="https://platform.openai.com/account/api-keys">here</a></p>')
178
  #openAI_key=gr.Textbox(label='Enter your OpenAI API key here')
179
+ url = gr.Textbox(label='在此处输入 PDF 网址')
180
  gr.Markdown("<center><h4>或<h4></center>")
181
+ file = gr.File(label='在此处上传您的 PDF/研究论文/书籍', file_types=['.pdf'])
182
+ question = gr.Textbox(label='在这里输入您的问题')
183
  btn = gr.Button(value='提交')
184
  btn.style(full_width=True)
185
 
186
  with gr.Group():
187
+ answer = gr.Textbox(label='你的提问的答案是:')
188
 
189
  #openAI_key=api_key
190
  btn.click(question_answer, inputs=[url, file, question], outputs=[answer])