File size: 4,314 Bytes
f3b4b77 9d5b0de f3b4b77 9d5b0de f3b4b77 9d5b0de f3b4b77 02a8580 f3b4b77 9d5b0de f3b4b77 9d5b0de f3b4b77 9d5b0de f3b4b77 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
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) |