Spaces:
Sleeping
Sleeping
Commit History
2 days ago
-
Update dependencies and fix runtime bugs found in audit
Dependencies - Pin Streamlit 1.67.0 and Python 3.12 via README sdk_version/python_version - Update all packages to current releases (pandas 3.1, numpy 2.5, plotly 7.1, PyMuPDF 2.1, Pillow 13, OpenCV 5, reportlab 5.1, google-genai 3.1, firebase-admin 7.7, Document AI 3.17) - Remove unused packages: langchain, langchain-core, langchain-community, langchain-google-genai, langsmith, google-generativeai (deprecated), fpdf2, imageio, python-docx, python-dotenv, pyyaml - Add beautifulsoup4 (used for HTML table parsing) and packages.txt with tesseract-ocr so the Tesseract OCR fallback works on Spaces Streamlit API - Replace deprecated use_container_width=True with width="stretch" (136 calls) - Replace deprecated st.components.v1.html with st.iframe via embed_html helper Bug fixes - CropDrive parent-window listener script had a JS syntax error (doubled braces in a non f-string), so language/config messages were never handled - OCR: missing `io` import broke PDF-to-image conversion…3f62288
-
Use latest Gemini 3.1 Pro as default analysis model
Mark CuizonPrefer gemini-3.1-pro-preview with fallbacks to gemini-3.6-flash, gemini-3.5-flash, and gemini-2.5-pro. Map bare gemini-3.1 aliases to the full Pro endpoint and keep image/audio models blocked for text analysis.b4bd144 -
Restore robust Gemini init so analysis steps use real LLM results
Mark CuizonBlock broken gemini-3.x model IDs, prefer gemini-2.5-pro with multi-model fallback, restore google.genai client path, and switch models on 404 during generate_content so steps 1-6 no longer fall back by default.6b26e92 -
Simplify Gemini client path and prefer gemini-3.1
Mark CuizonUse the legacy google.generativeai client with a shorter model fallback list headed by gemini-3.1, and restore direct error details in fallback analysis responses.88a0782
-
Harden Gemini model selection and hide fallback error metadata
Mark Cuizon3c12ca1 -
Fix results rendering and Gemini fallback robustness
Mark Cuizon3e1ad08 -
refactor: simplify Step 2/3 results, severity thresholds, and analysis progress UI
Mark CuizonRestore simpler recommendation display and MPOB severity matching in analysis/results, and streamline Streamlit step progress updates during AI analysis.e30538d -
fix: Step 2 real issues, clean Step 1/3 formatting, stop empty re-extract
Mark CuizonKeep pre-extracted soil/leaf parameter_statistics instead of wiping them. Rebuild Step 2 from real averages with correct severity thresholds. Format Step 3 solutions as cards; strip ### and raw Action/Headers dumps; skip placeholder tables.95837b5 -
chore: note gemini-2.5-pro as default analysis model
Mark Cuizon9bc4da8 -
fix: analysis progress UI, Gemini models, and Step 2/3/5 results
Mark CuizonShorten AI progress labels to stop duplicating full step prompts. Prefer gemini-2.5-pro/flash. Rebuild Step 2/3/5 narratives from real issues and economic forecast when LLM returns placeholders. Route Step 2 and 5 through dedicated renderers and hide empty Issues Source dumps.f8d30ca -
fix: parse SP Lab OCR from real text and restore Gemini analysis
Mark CuizonRemove hardcoded SP Lab sample values so structured OCR matches raw OCR (including pH). Resolve Gemini API keys from common HF secret names and use valid models with probe verification instead of gemini-3.1 fallback-only runs.5cac7b6
-
Merge hf/main: resolve conflicts, keep HF fixes and translations
Mark Cuizona5c3983 -
fix-bodystreambuffer-hf
Mark Cuizon8f155fd -
fix: restore Hugging Face Space build and startup reliability
Mark Cuizon- Remove spellchecker (no Linux wheel) and unused Streamlit extras that bloated installs - Relax pandas/numpy/PyMuPDF pins for Python 3.10 manylinux compatibility - Delete orphaned dead code in dashboard.py that could break fresh builds - Make Firebase initialization non-fatal so the Space stays running without secrets - Add safe Streamlit secrets helpers and remove import-time st.stop() in upload - Add .streamlit/config.toml and pin Python 3.10 in README metadatac9a0fae
-
Add Malay/Indonesian translation coverage and switch to Gemini 3.1
Mark Cuizonf746550
-
feat: add Indonesian (Bahasa Indonesia) language support
Mark Cuizon- Add full 'id' translation dictionary to translations.py with ~300+ keys - Update get_language(), set_language(), toggle_language() to support 'id' - Toggle now cycles en -> ms -> id -> en - Add Indonesian LLM language instruction in analysis_engine.py - Update all language validations in cropdrive_integration.py to include 'id' - Update app.py fallback language checks to include 'id' - AI assistant, analysis results and PDF reports all translate to Indonesian when lang=idb63bb45
-
Update app.py and translations.py
081ba44 -
Update app.py, results.py, and translations.py
0540f42
-
Add Palm Tree Age input (1-35 years) and Soil Type selection to upload page
ff8c766
-
Fix Malaysian language translations for Step 6 PDF titles and chart labels
c4a4c9c
-
Update results, pdf_utils, and translations
329ee7f -
Fix translation for Step 6 yield forecast headers and chart titles in results page and PDF utils
412d66d -
Fix Step 6 translation issues - Translate all graph elements, axis labels, year labels, investment scenarios, and footnotes to Malaysian language
fb7fb3f -
Pdf utils translated to malaysian
1c33eb3 -
Update app.py, results.py, pdf_utils.py, and translations.py
2f19080 -
Add Malaysian language translations for PDF reports and step results - Translate all English texts in PDF (headers, sections, step descriptions, table headers) - Add translate_content_labels function to replace English labels in step results - Remove blank Solution Recommendations section in Step 3 - Enhance table header translations for comprehensive coverage
953de63 -
Fix duplicate error messages in Malaysian language
- Fixed duplicate 'Tiada hasil tersedia' messages in results page - Separated error and info messages with distinct translation keys - Added results_module_not_available and results_contact_support translation keys - Error now shows: 'Modul hasil tidak tersedia' - Info now shows: 'Sila hubungi sokongan jika isu ini berterusan.'2f253f7 -
Add Malaysian language translations for step results and PDF reports
- Added translate_content_labels() function to replace English labels (Analysis::, Summary::, Detailed Analysis::, Formatted Analysis::) in step results content - Applied translations to all step display functions (steps 1-6) - Translated all hardcoded English strings in PDF generation: - Header sections (Analysis Results, Analysis Date, Report Types) - Step titles and descriptions - Section headers (Summary, Detailed Analysis, Data Tables, Key Findings) - Economic Impact Forecast labels - Yield Forecast labels - Added automatic table header translation in PDF table creation - Removed blank Solution Recommendations section from Step 3 PDF - Added missing translation keys for PDF sections6d52594
-
Fix Malaysian language translations for step titles and analysis results headers
- Fixed hardcoded 'Step {number}' text to use translation function - Ensured all step titles (Step 1-6) are properly translated - Fixed 'Additional Analysis Results' header to use translation - Added translation for sub-headers: Analysis, Summary, Detailed Analysis, Formatted Analysis - Fixed 'Detailed Interpretations' headers to use translation - Added translate_llm_headers() function to translate English headers in LLM output - Applied translations to summary and detailed analysis text sectionsd934d06 -
Fix Malaysian language translations for step titles and analysis results headers - Translate all step titles (Step 1-6) to Malaysian - Fix STEP/LANGKAH prefix translation - Translate Additional Analysis Results header - Translate sub-headers (Analysis, Summary, Formatted Analysis, Detailed Interpretations) - Fix Economic Impact Analysis messages - Ensure all tables display properly in both languages
4217c16 -
Add Malaysian language translation for all analysis results text including step titles and headers
f099144 -
Fix: Translate step titles and fix table placeholders in Step 5
- Added translation support for step titles (Steps 2-6) including patterns like 'Diagnose Agronomic Issues', 'Recommend Solutions', etc. - Fixed table placeholder rendering in Step 5 to replace __TABLE_PLACEHOLDER_X__ with actual economic forecast tables - Enhanced translate_step_title() function to handle more step title patterns - Updated display_formatted_economic_tables() to accept analysis_data and replace placeholders with real tables - Added Malaysian translation keys for step title patterns9de4c72
-
Fix Step 6 errors and analysis limit enforcement - Fix 'str' object has no attribute 'get' error in forecast graph - Fix interpretations and key_findings display formatting issues - Fix analysis limit check order to use updated session state - Add proper type validation for forecast data
197ef6c
-
Update send_analysis_complete to match AI Assistant Integration Guide format - Remove userId from message (website uses authenticated user ID) - Update message format to match exact guide specification - Update error handling to send ANALYSIS_ERROR messages - Add documentation references to integration guide
307f1c9
-
feat: Add SCRIPT_RUN_STATE_CHANGED communication functions
- Add send_script_run_state_changed() for analysis progress updates - Add send_error_message() for error status notifications - Add send_progress_update() for step-by-step progress tracking - Complete implementation of all message types from communication guide - Fix type annotations for new functionseaa5dc3 -
fix: Complete data table formatting and LLM content label translation
- Fixed data table formatting issues in formatted analysis section for all steps (1-6) - Added missing apply_table_styling() and translate_column_headers() calls to all dataframes - Implemented translate_llm_content_labels() function to translate LLM-generated content labels - Added translation keys for common LLM content labels: • Analysis: → Analisis: • Summary: → Ringkasan: • Detailed Analysis: → Analisis Terperinci: • Formatted Analysis: → Analisis Terformat: - Applied label translation to all LLM-generated content before display - Ensured all data tables show proper formatting with translated column headers - Fixed inconsistent table styling across step-by-step analysis sections - All data tables now display correctly with proper Malaysian translations Data tables in formatted analysis now show proper formatting for all steps, and all LLM content labels (Analysis:, Summary:, Detailed Analysis:) are properly translated to Malaysian when the language is switched.023d7c3 -
feat: Implement comprehensive formatted data tables for all analysis steps
- Fixed critical f-string syntax errors preventing table translations from working - Created unified formatted comparison table showing soil and leaf results vs MPOB standards - Implemented proper HTML table formatting with localized headers and content: • Parameter (parameter name) • Sumber/Source (Tanah/Daun - Soil/Leaf) • Purata/Average (average values) • Piawaian MPOB/MPOB Standard (MPOB standard ranges) • Jurang/Gap (calculated difference from standards) - Updated display_overall_results_summary_table() to show formatted comparison table - Updated display_comprehensive_data_tables() to use same formatted approach - Added comprehensive MPOB standards mapping for all soil and leaf parameters - Implemented gap calculation logic for different standard formats (> X, X-Y ranges) - Added translation keys for all table headers and content - Ensured formatted tables appear in all analysis steps (1-6) through main analysis flow - Tables automatically switch between English and Mal…d584695 -
fix: Complete step-by-step results section localization
- Fixed critical f-string syntax errors where {t('detailed_analysis', 'Detailed Analysis')} was displaying literally instead of being evaluated - Added comprehensive translation keys for all remaining hardcoded headers in step-by-step results: • 📋 Summary → 📋 Ringkasan • 📋 Detailed Analysis → 📋 Analisis Terperinci • 📊 Data Tables → 📊 Jadual Data • 🔍 Detailed Interpretations → 🔍 Tafsiran Terperinci • 💰 Economic Forecast → 💰 Ramalan Ekonomi • 📈 Investment Scenarios → 📈 Senario Pelaburan • 📋 Key Assumptions → 📋 Andaian Utama • 🌱 Raw Soil Sample Data → 🌱 Data Sampel Tanah Mentah • 📊 Economic Analysis Tables → 📊 Jadual Analisis Ekonomi • 📊 Economic Impact Analysis → 📊 Analisis Kesan Ekonomi • 📋 Complete Analysis Tables → 📋 Jadual Analisis Lengkap - Corrected all f-string syntax errors (missing 'f' prefix) that prevented translation functions from executing - Updated all step-by-step analysis section headers to use translation functions - Ensured a…b0e9312 -
feat: Complete Malaysian localization for step headers and analysis sections
- Add comprehensive translation keys for all remaining hardcoded headers - Update all step display headers to use translation functions: • 📋 Summary → 📋 Ringkasan • 📋 Detailed Analysis → 📋 Analisis Terperinci • 📊 Data Tables → 📊 Jadual Data • 🔍 Detailed Interpretations → 🔍 Tafsiran Terperinci - Update step title generation to use translated step titles instead of dynamic English • Step 1: Data Analysis → Langkah 1: Analisis Data • Step 2: Issue Diagnosis → Langkah 2: Diagnosis Isu • All step titles (1-6) now properly localized - Add translation keys for step-specific headers and analysis sections - Ensure all step-by-step analysis headers switch between English and Malaysian - Maintain existing PDF localization while improving web interface translations All section headers, step titles, and analysis display elements in the results page now provide complete bilingual support, ensuring Malaysian users see all content in Bahasa Malaysia when the language toggle is a…4950b71 -
feat: Complete Malaysian localization for all results page headers
- Add comprehensive translation keys for all hardcoded section headers - Update all results page section titles to use translation functions: • Comprehensive Data Analysis Tables → Jadual Analisis Data Komprehensif • Soil Parameter Averages → Purata Parameter Tanah • All Soil Sample Values → Semua Nilai Sampel Tanah • Leaf Analysis Summary → Ringkasan Analisis Daun • All Leaf Sample Values → Semua Nilai Sampel Daun • Combined Analysis Summary → Ringkasan Analisis Gabungan • Step-by-Step Analysis → Analisis Langkah Demi Langkah • Key Findings → Penemuan Utama • Specific Recommendations → Cadangan Khusus • Additional Analysis Results → Keputusan Analisis Tambahan • Analysis Results → Keputusan Analisis - Update HTML content in step display functions to use translated headers - Ensure all user-facing text in results page switches between English and Malaysian - Maintain existing PDF localization functionality All section headers, titles, and user interface elements …a09a243 -
feat: Complete Malaysian language localization for results page
- Add comprehensive translation keys for results page elements - Replace all hardcoded English strings with translation function calls - Add translate_column_headers() function for DataFrame column translation - Fix data table formatting with proper localized column headers - Ensure PDF utils maintain existing translation support - Test translation functions for both English and Malaysian languages Changes include: - utils/translations.py: Added missing translation keys and Malaysian translations - modules/results.py: Replaced hardcoded strings and added column header translation All results page elements, data tables, and user interface text now properly switch between English and Malaysian languages.9707d9d
-
feat: Implement AI Assistant Integration Guide
- Update CONFIG message handling to store user config in window.userConfig - Enhance ANALYSIS_COMPLETE message sending with proper format and sessionStorage backup - Add REQUEST_CONFIG_UPDATE functionality for config synchronization - Implement comprehensive error handling with safePostMessage function - Add automatic config update requests after analysis completion - Improve bidirectional communication between AI assistant and CropDrive website99cf00c -
Fix: Add REQUEST_CONFIG_UPDATE after ANALYSIS_COMPLETE and enhanced logging
- Added REQUEST_CONFIG_UPDATE message requests after sending ANALYSIS_COMPLETE - Increased delay to 2 seconds to allow parent time to process ANALYSIS_COMPLETE - Added backup request after 5 seconds - Enhanced logging for upload count updates - Added warnings about parent website needing to increment upload count - Improved CONFIG message handling to update URL params NOTE: Parent website MUST increment upload count when it receives ANALYSIS_COMPLETE. If parent sends CONFIG with old count, it will overwrite optimistic update.7a7eafd -
Fix: Add optimistic upload count update after ANALYSIS_COMPLETE
- Added optimistic upload count increment in Python session state before sending ANALYSIS_COMPLETE - Added optimistic update in JavaScript sessionStorage and URL params - Updated upload.py to always read from URL params (most up-to-date source) - Enhanced CONFIG message handling with logging - Added CONFIG_UPDATE handler for non-reload updates - Ensures upload count (e.g., 0/2 used) updates immediately after analysis completes - Multiple update mechanisms ensure count stays in syncddd3171 -
Fix: Add ANALYSIS_COMPLETE message sending and Firestore save with user ID
- Added send_analysis_complete() function to send ANALYSIS_COMPLETE message to parent website - Enhanced store_analysis_to_firestore() to reliably save with user_id for website queries - Added logger import to cropdrive_integration.py (was missing, causing silent failures) - Called send_analysis_complete() immediately after analysis completes in process_new_analysis() - Improved error handling and logging throughout - Ensures analysis results are saved to Firestore with user_id so website can fetch them - Message format matches exact specification required by parent website43e20d5 -
Fix analysis completion: ensure user_id is included and message sent correctly
- Add extensive logging to debug user_id retrieval issues - Ensure ANALYSIS_COMPLETE message includes user_id from multiple sources - Add fallback to get user_id from URL params if session state missing - Improve error handling and logging in send_analysis_complete() - Ensure Firestore save includes user_id before sending message - Add userId to analysis_data for redundancy - Add detailed console logging in JavaScript for debuggingaf79a1f -
Fix multiple issues: time estimates, table display, and PDF translations
- Change '2-5 minutes' to '5-8 minutes' in all texts (translations.py and results.py) - Fix markdown table rendering to handle Malaysian table captions (Jadual) in addition to English (Table) - Add Malaysian translations for PDF conclusion sections (Analysis Overview, Key Findings, Economic Impact, etc.) - Fix PDF interpretations section to filter out empty arrays and None values - Ensure all conclusion text in PDF utils uses translation system instead of hardcoded Englishc166ab1 -
Fix postMessage origin mismatch: use '*' as target origin
- Update send_analysis_complete() to use '*' instead of specific origins - Update send_feature_restricted() to use '*' instead of specific origins - Update send_language_change() to use '*' instead of specific origins - Parent page will verify message origin on its side - This fixes the 'target origin does not match recipient window origin' error0da4769 -
Fix upload limit calculation logic
- Calculate uploads_remaining as uploads_limit - uploads_used instead of trusting parent value - Fix can_start_analysis() to recalculate remaining for accuracy - Fix display to show correct remaining count (e.g., 0/2 used = 2 remaining, not 0) - Ensure limit is only reached when uploads_used >= uploads_limit82b42ca -
Add CropDrive integration: upload limits enforcement and analysis completion messaging
- Update cropdrive_integration.py to handle CONFIG messages with upload limits - Add can_start_analysis() function to check upload limits before analysis - Add get_upload_limit_info() helper function - Update send_analysis_complete() to include ISO timestamp - Update upload.py to enforce upload limits before allowing analysis - Display upload usage information on upload page - Update results.py to ensure ANALYSIS_COMPLETE message includes timestamp - Handle unlimited plans (infinity/-1) properly9d3b8a9