Shamba Advisor: A Streamlit-based AI agricultural tool. It uses a two-step LLM pipeline to analyze farmer queries with conversation context and generate safe, localized, step-by-step farming advice with downloadable reports.
# 🌱 Shamba Advisor
An AI-powered decision assistant for smallholder farmers in Kenya — covering the whole farming cycle, from land preparation and planting, through pest and disease problems, to harvest and storage.
**Group:** AFRIC
**Members:** Faith Mshiki, Simon Gatuku
**Course:** WeCan Academy — AI & Chatbot Course, Season 11
---
### 🚀 Live Demo
Click the badge below to try the live application:
---
## What it does
A farmer types a question in plain language — misspellings, mixed English/Swahili, and incomplete sentences are all fine. Shamba Advisor then:
1. **Understands the question** using conversation memory — follow-up messages like "what should I plant?" are correctly understood using earlier context (location, farm size, crop) without the farmer repeating themselves (Call 1)
2. **Pulls in live weather data** automatically, when relevant to the question
3. If multiple causes are plausible (e.g. a pest problem), **asks the farmer to pick one** from quick-select buttons, or type their own description if none fit
4. **Generates a practical, low-cost, week-by-week action plan** based on the analysis (Call 2)
5. **Saves the advice to a file**, downloadable directly from the chat
6. **Remembers the farmer** — returning to the same link signs them back in automatically, with recent chats available in the sidebar to reopen at any time
## How it works — the pipeline
```
Farmer types a message
│
▼
CALL 1 (ai/first_call.py)
Analyzes intent, crop, location, symptoms, possible causes, etc.
Uses conversation history to understand follow-up questions
Returns structured JSON
│
▼
Weather lookup (weather/open_meteo.py)
Only runs if the analysis says weather matters
│
▼
[If ambiguous] Farmer picks a cause via buttons, or types their own
│
▼
CALL 2 (ai/second_call.py)
Turns the analysis + weather + selected cause into a real action plan
│
▼
Saved to a .txt file + shown in the chat
Conversation stored in Supabase (encrypted at rest)
```
Both AI calls use Open …