taesiri commited on
Commit
c4d7d33
1 Parent(s): 4639ead

update layout

Browse files
Files changed (1) hide show
  1. app.py +29 -15
app.py CHANGED
@@ -17,6 +17,14 @@ from coreservice import app
17
 
18
  LEADING_PROMPT = "Read the following paper:"
19
 
 
 
 
 
 
 
 
 
20
 
21
  def replace_texttt(text):
22
  return re.sub(r"\\texttt\{(.*?)\}", r"*\1*", text)
@@ -31,7 +39,10 @@ def get_paper_info(paper_id):
31
 
32
  if paper is not None:
33
  # Return the paper's title and abstract
34
- return paper.title, paper.summary
 
 
 
35
  else:
36
  return None, None
37
 
@@ -203,7 +214,7 @@ def clear_context():
203
  return []
204
 
205
 
206
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
207
  gr.HTML(
208
  """
209
  <h1 style='text-align: center; font-size: 24px;'>
@@ -211,13 +222,13 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
211
  </h1>
212
  """
213
  )
214
- gr.HTML(
215
- """
216
- <p style='text-align: justify; font-size: 18px; margin: 10px;'>
217
- Explore the depths of ArXiv papers with our interactive app, powered by the advanced <code>claude-2.0</code> model. Ask detailed questions and get immediate, context-rich answers from academic papers.
218
- </p>
219
- """
220
- )
221
 
222
  gr.HTML(
223
  """
@@ -233,21 +244,24 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
233
  """
234
  )
235
 
236
- with gr.Column():
237
- with gr.Row():
 
 
 
238
  paper_id_input = gr.Textbox(label="Enter Paper ID", value="2310.12103")
239
  btn_load = gr.Button("Load Paper")
240
  qa_model = gr.State()
241
 
242
- with gr.Column():
243
- chatbot = gr.Chatbot().style(color_map=("blue", "yellow"))
244
  question_txt = gr.Textbox(
245
- label="Question", lines=1, placeholder="Type your question here..."
246
  )
247
- btn_answer = gr.Button("Answer Question")
248
 
 
249
  btn_clear = gr.Button("Clear Chat")
250
 
 
 
251
  gr.HTML(
252
  """<center>All the inputs are being sent to Anthropic's Claude endpoints. Please refer to <a href="https://legal.anthropic.com/#privacy">this link</a> for privacy policy.</center>"""
253
  )
 
17
 
18
  LEADING_PROMPT = "Read the following paper:"
19
 
20
+ # with open("assets/custom.css", "r", encoding="utf-8") as f:
21
+ # custom_css = f.read()
22
+
23
+ custom_css = """
24
+ div#component-4 #chatbot {
25
+ height: 800px !important;
26
+ }
27
+ """
28
 
29
  def replace_texttt(text):
30
  return re.sub(r"\\texttt\{(.*?)\}", r"*\1*", text)
 
39
 
40
  if paper is not None:
41
  # Return the paper's title and abstract
42
+ # remove new lines
43
+ title_ = paper.title.replace("\n", " ").replace("\r", " ")
44
+ summary_ = paper.summary.replace("\n", " ").replace("\r", " ")
45
+ return title_, summary_
46
  else:
47
  return None, None
48
 
 
214
  return []
215
 
216
 
217
+ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
218
  gr.HTML(
219
  """
220
  <h1 style='text-align: center; font-size: 24px;'>
 
222
  </h1>
223
  """
224
  )
225
+ # gr.HTML(
226
+ # """
227
+ # <p style='text-align: justify; font-size: 18px; margin: 10px;'>
228
+ # Explore the depths of ArXiv papers with our interactive app, powered by the advanced <code>claude-2.0</code> model. Ask detailed questions and get immediate, context-rich answers from academic papers.
229
+ # </p>
230
+ # """
231
+ # )
232
 
233
  gr.HTML(
234
  """
 
244
  """
245
  )
246
 
247
+ with gr.Row().style(equal_height=False):
248
+ with gr.Column(scale=2, emem_id="column-flex"):
249
+ chatbot = gr.Chatbot(elem_id="chatbot")
250
+
251
+ with gr.Column(scale=1):
252
  paper_id_input = gr.Textbox(label="Enter Paper ID", value="2310.12103")
253
  btn_load = gr.Button("Load Paper")
254
  qa_model = gr.State()
255
 
 
 
256
  question_txt = gr.Textbox(
257
+ label="Question", lines=5, placeholder="Type your question here..."
258
  )
 
259
 
260
+ btn_answer = gr.Button("Answer Question")
261
  btn_clear = gr.Button("Clear Chat")
262
 
263
+
264
+
265
  gr.HTML(
266
  """<center>All the inputs are being sent to Anthropic's Claude endpoints. Please refer to <a href="https://legal.anthropic.com/#privacy">this link</a> for privacy policy.</center>"""
267
  )