Makes the recommendation agent region-parameterized and renames the
India-specific output field recommendation_ta -> recommendation_local
(+ sibling local_language_code: 'ta' | 'sw').
- REGION_CONFIG dict keyed by region with 10 fields (region_name,
currency_symbol, market_type, local_language_name/code,
phone_country_code, local_greeting_example, typical_crops, etc.)
- SYSTEM_PROMPT + TRANSLATION_PROMPT parameterize via .format()
- Claude models unchanged: Sonnet for reasoning, Haiku for translation
- FarmerRecommendation dataclass: recommendation_ta -> recommendation_local
- Rule-based fallback is region-aware (currency, market terminology)
- Delivery SMS: phone country code + language-tagged local text
(+254..., 'SW:' prefix under Kenya; +91..., 'TA:' under India)
- src/api.py demo endpoint emits the new fields
- src/db.py: DB-schema-gap comment at SellRecommendation persistence
(local text lives in full_data JSONB; no dedicated column change)
Co-Authored-By: Claude Opus 4…
- Use get_session() instead of manual sessionmaker (match existing db pattern)
- Remove unused DeliveryChannel enum and Recipient dataclass
- Create Twilio client once before loop, not per message
- Skip duplicate format_sms when language is English
- Remove redundant status/channel reassignment in dry-run path
- Add index on delivery_logs.created_at
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add Step 7: SMS delivery for sell recommendations
- sell_recommendations.full_data: complete rec dict with all options,
costs, credit readiness
- market_prices.full_data: complete price dict with source breakdown
- pipeline_runs.price_conflicts: full conflict investigation data
- Vercel endpoints use full_data when available, fall back to columns
Next pipeline run will populate the JSONB columns. Dashboard will then
show full cost breakdowns and investigation steps from Neon.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Widen market_prices.source column to VARCHAR(100)
Prevents pipeline from hanging when Neon PostgreSQL connection is
stale. Adds 10s connect_timeout, pool_timeout, and pool_recycle=300s.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace health supply chain optimizer with market intelligence agent
Complete rewrite from health domain to post-harvest market intelligence
for Tamil Nadu smallholder farmers. Same 6-step pipeline architecture
(ingest → extract → reconcile → forecast → optimize → recommend),
new domain: conflicting mandi price data → reconciled prices →
sell-now-or-wait recommendations with credit readiness assessment.
Backend: 15 real Tamil Nadu mandis, 10 commodities, real Agmarknet API
(data.gov.in), eNAM scraper, NASA POWER weather, XGBoost price forecaster,
Claude agents with rule-based fallbacks, FAISS+BM25 RAG.
Frontend: 5 pages (Markets, Forecast, Sell Advisor, Pipeline, Data),
amber/saffron theme, Tamil Nadu map, Joyride tour, credit readiness UI.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Simplify: fix bugs, remove duplication, use public APIs
- Remove dead `or True` filter in anomaly detector score()
- Remove dead REPORTING_QUALITY_ENC from detector.py
- Add public metrics/feature_importances properties to XGBoostDemandModel
- Add predict_batch() for vectorized predictions
- Fix residual model to use public predict_batch() instead of _model internals
- Reuse training_df in pipeline instead of calling build_training_data twice
- Add exception handling for residual model training failures
- Replace per-item anomaly scoring loop with batch score_batch()
- Use real facility/drug data for anomaly features instead of hardcoded values
- Gate init_db() with flag so DDL only runs once
- Replace duplicate LEAD_TIME_MAP with import from config.LEAD_TIMES
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Expand XGBoost demand model from 13 to 20 features (RMSE 5.8→3.3, R²=0.998)
- Add residual correction model (MOS pattern: model-correcting-model)
- Add isolation forest anomaly detection on consumption patterns
- Upgrade RAG from TF-IDF to sentence-transformers (all-MiniLM-L6-v2)
- Expand knowledge base from 33 to 101 chunks across 15 categories
- Add Neon PostgreSQL persistence layer (5 tables)
- Add evaluation suite (44 pytest tests)
- Wire new components into pipeline and API
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>