rubenroy's picture
Update app.py
02a8580 verified
import streamlit as st
import requests
st.set_page_config(
page_title="Seneca Engine | Mathematical Computation",
page_icon="🧮",
layout="wide",
initial_sidebar_state="collapsed"
)
st.markdown("""
<style>
[data-testid="stHeader"] {
background-color: rgba(255, 255, 255, 0);
}
.main-container {
max-width: 1200px;
margin: 0 auto;
padding: 2rem;
}
.title-container {
text-align: center;
margin-bottom: 3rem;
}
.stButton > button {
background-color: #0066cc;
color: white;
border: none;
border-radius: 6px;
padding: 0.5rem 1rem;
font-weight: 500;
}
footer {
text-align: center;
padding: 2rem;
color: #666;
font-size: 0.9rem;
}
</style>
""", unsafe_allow_html=True)
st.title("Seneca Computational Engine")
st.markdown("""
<p style='font-size: 1.2rem; margin-bottom: 2rem;'>
Advanced Mathematical Computation & Problem Solving
</p>
""", unsafe_allow_html=True)
st.markdown("</div>", unsafe_allow_html=True)
main_container = st.container()
with main_container:
left_col, right_col = st.columns([6, 4])
with left_col:
st.markdown("### Mathematical Query")
mode = st.radio(
"Select Computation Mode",
options=["Mode 1", "Mode 2"],
index=0
)
query = st.text_area(
"Math Question",
height=150,
placeholder="Enter your mathematical expression here...\nExample: Solve x^2 + 2x + 1 = 0",
key="query_input"
)
if st.button("Solve Expression", type="primary", use_container_width=True):
if not query:
st.error("Please enter a mathematical expression.")
else:
try:
with st.spinner("Computing solution..."):
mode_num = int(mode.split("Mode ")[1])
url = "https://seneca.ruben-roy.com/v1/process"
headers = {'Content-Type': 'application/json'}
data = {"query": query, "mode": mode_num}
response = requests.post(
url,
json=data,
headers=headers,
verify=False,
timeout=60
)
if response.status_code == 200:
result = response.json()
st.markdown("#### Solution")
st.latex(result['solution'])
except requests.exceptions.Timeout:
st.error("⚠️ Request timed out. Please try again.")
except requests.exceptions.RequestException as e:
st.error(f"⚠️ Connection error: {str(e)}")
except Exception as e:
st.error(f"⚠️ An unexpected error occurred: {str(e)}")
with right_col:
with st.expander("About Seneca Engine", expanded=True):
st.markdown("""
Seneca is a mathematical computation engine designed
to solve complex mathematical problems.
Developed by Ruben Roy, 2025.
""")
with st.expander("Computation Modes", expanded=True):
st.markdown("""
Seneca has 2 computational modes, they perform differently depending on what you want to do with it. If you get an unexpected or disappointing output from a specific mode, try switching to the other mode.
""")
with st.expander("How to Use", expanded=True):
st.markdown("""
1. First, select the mode you'd like to use.
2. Then, enter your query and type your mathematical expression
3. Finally click 'Solve Expression' to get your solution
Try using clear, standard mathematical notation for the best results.
""")
st.markdown("---")
st.markdown("""
<footer>
<p>© Ruben Roy 2025. All rights reserved.</p>
</footer>
""", unsafe_allow_html=True)