Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1007,115 +1007,115 @@ def main():
|
|
1007 |
tab_main = st.radio("Choose Action:",
|
1008 |
["π€ Voice Input", "π¬ Chat", "πΈ Media Gallery", "π Search ArXiv", "π File Editor"],
|
1009 |
horizontal=True)
|
1010 |
-
|
1011 |
-
if tab_main == "π€ Voice Input":
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
|
|
1040 |
|
|
|
|
|
|
|
1041 |
|
1042 |
-
# Display last voice input
|
1043 |
-
if st.session_state.last_voice_input:
|
1044 |
-
st.text_area("Last Voice Input:", st.session_state.last_voice_input, height=100)
|
1045 |
-
|
1046 |
-
|
1047 |
-
if tab_main == "π¬ Chat":
|
1048 |
-
# Model Selection
|
1049 |
-
model_choice = st.sidebar.radio(
|
1050 |
-
"Choose AI Model:",
|
1051 |
-
["GPT-4o", "Claude-3", "GPT+Claude+Arxiv"]
|
1052 |
-
)
|
1053 |
|
1054 |
-
|
1055 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1056 |
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
else: # Both
|
1064 |
-
col1, col2, col3 = st.columns(3)
|
1065 |
-
with col2:
|
1066 |
-
st.subheader("Claude-3.5 Sonnet:")
|
1067 |
-
try:
|
1068 |
-
claude_response = process_with_claude(user_input)
|
1069 |
-
except:
|
1070 |
-
st.write('Claude 3.5 Sonnet out of tokens.')
|
1071 |
-
with col1:
|
1072 |
-
st.subheader("GPT-4o Omni:")
|
1073 |
-
try:
|
1074 |
-
gpt_response = process_with_gpt(user_input)
|
1075 |
-
except:
|
1076 |
-
st.write('GPT 4o out of tokens')
|
1077 |
-
with col3:
|
1078 |
-
st.subheader("Arxiv and Mistral Research:")
|
1079 |
-
with st.spinner("Searching ArXiv..."):
|
1080 |
-
#results = search_arxiv(user_input)
|
1081 |
-
results = perform_ai_lookup(user_input)
|
1082 |
-
|
1083 |
-
st.markdown(results)
|
1084 |
-
|
1085 |
-
# Display Chat History
|
1086 |
-
st.subheader("Chat History π")
|
1087 |
-
tab1, tab2 = st.tabs(["Claude History", "GPT-4o History"])
|
1088 |
|
1089 |
-
|
1090 |
-
|
1091 |
-
st.
|
1092 |
-
st.text_area("
|
1093 |
-
st.
|
|
|
|
|
|
|
1094 |
|
1095 |
-
with tab2:
|
1096 |
-
for message in st.session_state.messages:
|
1097 |
-
with st.chat_message(message["role"]):
|
1098 |
-
st.markdown(message["content"])
|
1099 |
-
|
1100 |
-
elif tab_main == "πΈ Media Gallery":
|
1101 |
-
create_media_gallery()
|
1102 |
-
|
1103 |
-
elif tab_main == "π Search ArXiv":
|
1104 |
-
query = st.text_input("Enter your research query:")
|
1105 |
-
if query:
|
1106 |
-
with st.spinner("Searching ArXiv..."):
|
1107 |
-
results = search_arxiv(query)
|
1108 |
-
st.markdown(results)
|
1109 |
-
|
1110 |
-
elif tab_main == "π File Editor":
|
1111 |
-
if hasattr(st.session_state, 'current_file'):
|
1112 |
-
st.subheader(f"Editing: {st.session_state.current_file}")
|
1113 |
-
new_content = st.text_area("Content:", st.session_state.file_content, height=300)
|
1114 |
-
if st.button("Save Changes"):
|
1115 |
-
with open(st.session_state.current_file, 'w', encoding='utf-8') as file:
|
1116 |
-
file.write(new_content)
|
1117 |
-
st.success("File updated successfully!")
|
1118 |
-
|
1119 |
|
1120 |
# Always show file manager in sidebar
|
1121 |
display_file_manager()
|
|
|
1007 |
tab_main = st.radio("Choose Action:",
|
1008 |
["π€ Voice Input", "π¬ Chat", "πΈ Media Gallery", "π Search ArXiv", "π File Editor"],
|
1009 |
horizontal=True)
|
1010 |
+
|
1011 |
+
if tab_main == "π€ Voice Input":
|
1012 |
+
st.subheader("Voice Recognition")
|
1013 |
+
|
1014 |
+
# Get transcript from the speech component
|
1015 |
+
current_transcript = integrate_speech_component()
|
1016 |
+
|
1017 |
+
# Display the transcript in a Streamlit text area
|
1018 |
+
st.markdown("### Processed Voice Input:")
|
1019 |
+
st.text_area("Voice Transcript", current_transcript, height=100)
|
1020 |
+
|
1021 |
+
# Process buttons
|
1022 |
+
col1, col2, col3 = st.columns(3)
|
1023 |
+
with col1:
|
1024 |
+
if st.button("Process with GPT"):
|
1025 |
+
st.subheader("GPT-4o Response")
|
1026 |
+
gpt_response = process_with_gpt(current_transcript)
|
1027 |
+
st.markdown(gpt_response)
|
1028 |
+
|
1029 |
+
with col2:
|
1030 |
+
if st.button("Process with Claude"):
|
1031 |
+
st.subheader("Claude Response")
|
1032 |
+
claude_response = process_with_claude(current_transcript)
|
1033 |
+
st.markdown(claude_response)
|
1034 |
+
|
1035 |
+
with col3:
|
1036 |
+
if st.button("Search ArXiv"):
|
1037 |
+
st.subheader("ArXiv Search Results")
|
1038 |
+
arxiv_results = perform_ai_lookup(current_transcript)
|
1039 |
+
st.markdown(arxiv_results)
|
1040 |
+
|
1041 |
|
1042 |
+
# Display last voice input
|
1043 |
+
if st.session_state.last_voice_input:
|
1044 |
+
st.text_area("Last Voice Input:", st.session_state.last_voice_input, height=100)
|
1045 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1046 |
|
1047 |
+
if tab_main == "π¬ Chat":
|
1048 |
+
# Model Selection
|
1049 |
+
model_choice = st.sidebar.radio(
|
1050 |
+
"Choose AI Model:",
|
1051 |
+
["GPT-4o", "Claude-3", "GPT+Claude+Arxiv"]
|
1052 |
+
)
|
1053 |
+
|
1054 |
+
# Chat Interface
|
1055 |
+
user_input = st.text_area("Message:", height=100)
|
1056 |
+
|
1057 |
+
if st.button("Send π¨"):
|
1058 |
+
if user_input:
|
1059 |
+
if model_choice == "GPT-4o":
|
1060 |
+
gpt_response = process_with_gpt(user_input)
|
1061 |
+
elif model_choice == "Claude-3":
|
1062 |
+
claude_response = process_with_claude(user_input)
|
1063 |
+
else: # Both
|
1064 |
+
col1, col2, col3 = st.columns(3)
|
1065 |
+
with col2:
|
1066 |
+
st.subheader("Claude-3.5 Sonnet:")
|
1067 |
+
try:
|
1068 |
+
claude_response = process_with_claude(user_input)
|
1069 |
+
except:
|
1070 |
+
st.write('Claude 3.5 Sonnet out of tokens.')
|
1071 |
+
with col1:
|
1072 |
+
st.subheader("GPT-4o Omni:")
|
1073 |
+
try:
|
1074 |
+
gpt_response = process_with_gpt(user_input)
|
1075 |
+
except:
|
1076 |
+
st.write('GPT 4o out of tokens')
|
1077 |
+
with col3:
|
1078 |
+
st.subheader("Arxiv and Mistral Research:")
|
1079 |
+
with st.spinner("Searching ArXiv..."):
|
1080 |
+
#results = search_arxiv(user_input)
|
1081 |
+
results = perform_ai_lookup(user_input)
|
1082 |
+
|
1083 |
+
st.markdown(results)
|
1084 |
+
|
1085 |
+
# Display Chat History
|
1086 |
+
st.subheader("Chat History π")
|
1087 |
+
tab1, tab2 = st.tabs(["Claude History", "GPT-4o History"])
|
1088 |
+
|
1089 |
+
with tab1:
|
1090 |
+
for chat in st.session_state.chat_history:
|
1091 |
+
st.text_area("You:", chat["user"], height=100)
|
1092 |
+
st.text_area("Claude:", chat["claude"], height=200)
|
1093 |
+
st.markdown(chat["claude"])
|
1094 |
+
|
1095 |
+
with tab2:
|
1096 |
+
for message in st.session_state.messages:
|
1097 |
+
with st.chat_message(message["role"]):
|
1098 |
+
st.markdown(message["content"])
|
1099 |
+
|
1100 |
+
elif tab_main == "πΈ Media Gallery":
|
1101 |
+
create_media_gallery()
|
1102 |
|
1103 |
+
elif tab_main == "π Search ArXiv":
|
1104 |
+
query = st.text_input("Enter your research query:")
|
1105 |
+
if query:
|
1106 |
+
with st.spinner("Searching ArXiv..."):
|
1107 |
+
results = search_arxiv(query)
|
1108 |
+
st.markdown(results)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1109 |
|
1110 |
+
elif tab_main == "π File Editor":
|
1111 |
+
if hasattr(st.session_state, 'current_file'):
|
1112 |
+
st.subheader(f"Editing: {st.session_state.current_file}")
|
1113 |
+
new_content = st.text_area("Content:", st.session_state.file_content, height=300)
|
1114 |
+
if st.button("Save Changes"):
|
1115 |
+
with open(st.session_state.current_file, 'w', encoding='utf-8') as file:
|
1116 |
+
file.write(new_content)
|
1117 |
+
st.success("File updated successfully!")
|
1118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1119 |
|
1120 |
# Always show file manager in sidebar
|
1121 |
display_file_manager()
|