An AI copilot for smallholder farmers in Kenya.
# Smart Farming Assistant
A web application for **smallholder farmers in Kenya** that combines **retrieval-augmented generation (RAG)** over curated agricultural documents with a **two-agent** workflow (weather → seasonal planning) powered by **CrewAI** and a **Streamlit** interface.
---
## What it does
| Mode | Description |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Ask** | Natural-language questions (e.g. crop timing, pests, inputs) are answered from a **local knowledge base** built from PDFs. Every answer is **grounded in retrieved text** and cites **source documents and page numbers**. |
| **Plan** | Given **location**, **farm size**, and **month**, a **Weather** agent fetches a **live forecast** (Open-Meteo) and a **Planner** agent produces a **structured one-page seasonal planting plan**, using the same knowledge base. |
| **Metrics** | Session-level stats: request counts, success rate, latencies, and token usage (where available). |
---
## Architecture
```mermaid
flowchart LR
subgraph ui [Streamlit]
A[Ask tab]
P[Plan tab]
M[Metrics tab]
end
subgraph rag [RAG]
PDF[docs/*.pdf] --> Ingest[Ingest + chunk + embed]
Ingest --> Chroma[(ChromaDB)]
A --> Q[query_rag]
Chroma --> Q
Q --> ClaudeRAG[Claude - answer]
end
subgraph crew [CrewAI - sequential]
P --> R[run_planner_crew]
R --> W[Weather agent + tool]
W --> OM[Open-Meteo API]
R --> L[Planner agent + RAG tool]
L --> Q2[query_rag]
Chroma --> Q2
end …