Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
layout="wide"
)

# Security: Maximum file size limit (10MB)
MAX_FILE_SIZE = 10 * 1024 * 1024 # 10MB in bytes


def encode_image(uploaded_file) -> str:
"""Convert uploaded file to base64 data URI."""
Expand All @@ -47,6 +50,11 @@ def main():

# Translation workflow
if uploaded_file and translate_button:
# Security: Validate file size before processing
if uploaded_file.size > MAX_FILE_SIZE:
st.error(f"❌ File size exceeds {MAX_FILE_SIZE // (1024 * 1024)}MB limit. Please upload a smaller image.")
return

with st.spinner("Processing..."):
try:
# Step 1: Encode image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ dependencies = [
"requests>=2.32.5",
"streamlit>=1.53.0",
"agno>=2.0.0",
"openai>=2.34.0",
]