Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
| 341 |
mycomponent = components.declare_component("mycomponent", path="mycomponent")
|
| 342 |
val = mycomponent(my_input_value="Hello")
|
| 343 |
if val:
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
st.
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
|
|
|
|
|
|
| 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 |
-
|
| 412 |
-
|
|
|
|
|
|
|
| 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()
|