diff --git a/Agents/Hunyan_OCR_API_Multilingual_Translation_Agent_Example/app.py b/Agents/Hunyan_OCR_API_Multilingual_Translation_Agent_Example/app.py index 6de17c8..a3beff8 100644 --- a/Agents/Hunyan_OCR_API_Multilingual_Translation_Agent_Example/app.py +++ b/Agents/Hunyan_OCR_API_Multilingual_Translation_Agent_Example/app.py @@ -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.""" @@ -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 diff --git a/Agents/Hunyan_OCR_API_Multilingual_Translation_Agent_Example/pyproject.toml b/Agents/Hunyan_OCR_API_Multilingual_Translation_Agent_Example/pyproject.toml index 6d2eb90..e02cf6d 100644 --- a/Agents/Hunyan_OCR_API_Multilingual_Translation_Agent_Example/pyproject.toml +++ b/Agents/Hunyan_OCR_API_Multilingual_Translation_Agent_Example/pyproject.toml @@ -11,4 +11,5 @@ dependencies = [ "requests>=2.32.5", "streamlit>=1.53.0", "agno>=2.0.0", + "openai>=2.34.0", ]