awacke1 commited on
Commit
ee456d4
β€’
1 Parent(s): bae6ae8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -28
app.py CHANGED
@@ -337,39 +337,43 @@ def main():
337
 
338
  model_choice = st.sidebar.radio("AI Model:", ["Arxiv","GPT-4o","Claude-3","GPT+Claude+Arxiv"], index=0)
339
 
340
- # A simple component placeholder
341
  mycomponent = components.declare_component("mycomponent", path="mycomponent")
342
  val = mycomponent(my_input_value="Hello")
343
  if val:
344
- user_input = val
345
- if model_choice == "GPT-4o":
346
- process_with_gpt(user_input)
347
- elif model_choice == "Claude-3":
348
- process_with_claude(user_input)
349
- elif model_choice == "Arxiv":
350
- st.subheader("Arxiv Only Results:")
351
- perform_ai_lookup(user_input)
352
- else:
353
- col1,col2,col3=st.columns(3)
354
- with col1:
355
- st.subheader("GPT-4o Omni:")
356
- try: process_with_gpt(user_input)
357
- except: st.write('GPT 4o error')
358
- with col2:
359
- st.subheader("Claude-3 Sonnet:")
360
- try: process_with_claude(user_input)
361
- except: st.write('Claude error')
362
- with col3:
363
- st.subheader("Arxiv + Mistral:")
364
- try:
365
- r = perform_ai_lookup(user_input)
366
- st.markdown(r)
367
- except:
368
- st.write("Arxiv error")
 
 
369
 
370
  if tab_main == "🎀 Voice Input":
371
  st.subheader("🎀 Voice Recognition")
372
  user_text = st.text_area("Message:", height=100)
 
 
373
  if st.button("Send πŸ“¨"):
374
  if user_text:
375
  if model_choice == "GPT-4o":
@@ -408,13 +412,16 @@ def main():
408
  elif tab_main == "πŸ” Search ArXiv":
409
  q=st.text_input("Research query:")
410
  if q:
411
- r=search_arxiv(q)
412
- st.markdown(r)
 
 
413
 
414
  elif tab_main == "πŸ“ File Editor":
415
  if getattr(st.session_state,'current_file',None):
416
  st.subheader(f"Editing: {st.session_state.current_file}")
417
  new_text = st.text_area("Content:", st.session_state.file_content, height=300)
 
418
  if st.button("Save"):
419
  with open(st.session_state.current_file,'w',encoding='utf-8') as f:
420
  f.write(new_text)
@@ -422,5 +429,6 @@ def main():
422
 
423
  display_file_manager()
424
 
 
425
  if __name__=="__main__":
426
  main()
 
337
 
338
  model_choice = st.sidebar.radio("AI Model:", ["Arxiv","GPT-4o","Claude-3","GPT+Claude+Arxiv"], index=0)
339
 
340
+ # Declare the component
341
  mycomponent = components.declare_component("mycomponent", path="mycomponent")
342
  val = mycomponent(my_input_value="Hello")
343
  if val:
344
+ # Strip whitespace and newlines from the end of the user input
345
+ user_input = val.strip()
346
+ if user_input:
347
+ if model_choice == "GPT-4o":
348
+ process_with_gpt(user_input)
349
+ elif model_choice == "Claude-3":
350
+ process_with_claude(user_input)
351
+ elif model_choice == "Arxiv":
352
+ st.subheader("Arxiv Only Results:")
353
+ perform_ai_lookup(user_input)
354
+ else:
355
+ col1,col2,col3=st.columns(3)
356
+ with col1:
357
+ st.subheader("GPT-4o Omni:")
358
+ try: process_with_gpt(user_input)
359
+ except: st.write('GPT 4o error')
360
+ with col2:
361
+ st.subheader("Claude-3 Sonnet:")
362
+ try: process_with_claude(user_input)
363
+ except: st.write('Claude error')
364
+ with col3:
365
+ st.subheader("Arxiv + Mistral:")
366
+ try:
367
+ r = perform_ai_lookup(user_input)
368
+ st.markdown(r)
369
+ except:
370
+ st.write("Arxiv error")
371
 
372
  if tab_main == "🎀 Voice Input":
373
  st.subheader("🎀 Voice Recognition")
374
  user_text = st.text_area("Message:", height=100)
375
+ # Strip whitespace and newlines
376
+ user_text = user_text.strip()
377
  if st.button("Send πŸ“¨"):
378
  if user_text:
379
  if model_choice == "GPT-4o":
 
412
  elif tab_main == "πŸ” Search ArXiv":
413
  q=st.text_input("Research query:")
414
  if q:
415
+ q = q.strip() # Strip whitespace and newlines
416
+ if q:
417
+ r=search_arxiv(q)
418
+ st.markdown(r)
419
 
420
  elif tab_main == "πŸ“ File Editor":
421
  if getattr(st.session_state,'current_file',None):
422
  st.subheader(f"Editing: {st.session_state.current_file}")
423
  new_text = st.text_area("Content:", st.session_state.file_content, height=300)
424
+ # Here also you can strip if needed, but usually for file editing you might not want to.
425
  if st.button("Save"):
426
  with open(st.session_state.current_file,'w',encoding='utf-8') as f:
427
  f.write(new_text)
 
429
 
430
  display_file_manager()
431
 
432
+
433
  if __name__=="__main__":
434
  main()