Inspiration

The inspiration for ShambaWise comes from the core challenges faced by small-scale farmers across Africa: unpredictable weather, crop diseases, and a lack of access to timely, localized information. Often, a single pest infestation or a delayed planting schedule can lead to significant crop loss and economic hardship. We were motivated to build a solution that empowers these farmers by transforming a wealth of agricultural data into actionable, multi-step advice, helping them move from subsistence farming to sustainable, profitable agriculture.

What it Does

ShambaWise is a multi-step, agentic solution that acts as a personal agricultural advisor for small-scale farmers. It's designed to be a comprehensive tool that not only answers questions but also provides a full, automated workflow for addressing farming challenges.

  • Ingest & Index: The agent continuously ingests a wide range of data into TiDB Serverless. This includes:
    • External Data: Real-time satellite imagery for weather patterns, sensor data on soil moisture and temperature, and a knowledge base of agricultural best practices, common pests, and crop diseases (including text and image data).
    • Farmer-Submitted Data: Farmers can submit their own data, such as a photo of a diseased plant, via a simple mobile app or a messaging service like WhatsApp.
  • Search & Diagnose: When a farmer submits a query or an image, the agent uses TiDB's vector search to find the closest matches. For example, a picture of a diseased leaf is converted into a vector and matched against the vector-indexed database of crop diseases to identify the likely pathogen. Simultaneously, a full-text search is performed on agricultural documents to find relevant best practices for that specific crop and location.
  • Chain LLM Calls: An LLM is called to synthesize the findings. It analyzes the diagnosis from the vector search and the best practices from the full-text search to formulate a detailed, multi-step recommendation. This is not a simple answer but a complete action plan, including the cause of the problem, the recommended treatment (e.g., a specific, locally available pesticide), and a step-by-step guide for application.
  • Invoke External Tools: The agent takes a tangible, real-world action.
    • It can send an SMS alert to the farmer with a summary of the recommended actions.
    • It can connect to a payment gateway to facilitate the purchase of the recommended agricultural inputs from a pre-vetted local vendor.
    • It can send a summary of the case (including all data, from the initial image to the final recommendation) to a human agricultural extension officer for follow-up, if necessary.

## How We Built It We built ShambaWise by orchestrating a number of powerful technologies around a single, unified database.

  • Database: TiDB Serverless served as the core of our application. We used its vector search to store embeddings for images and text from our knowledge base of crop diseases. We also used its full-text search to index and query our documents on farming practices. This allowed us to perform complex, multi-modal queries in a single database, which was essential for our multi-step agent.
  • Agent Orchestration: We used a framework like LangChain to build the multi-step agent. This allowed us to connect our data ingestion, TiDB queries, LLM analysis, and external API calls into a cohesive, automated workflow.
  • LLM Integration: We integrated a powerful LLM to act as the "brain" of the agent. The LLM's job was to take the raw data and search results from TiDB and turn them into a coherent, actionable plan for the farmer.
  • APIs & Services: We used a Python backend to manage the external integrations. We connected to a simple API for sending SMS messages to the farmers and a mock payment gateway API to demonstrate the final "action" step of our workflow.

Challenges We Ran Into

One of the main challenges was creating a robust, representative knowledge base. Finding high-quality, localized data on crop diseases and farming practices for a specific African context was difficult. We addressed this by curating a diverse dataset and using a synthetic data generation approach to supplement our real-world information. Another challenge was the latency of chaining multiple steps. We optimized our TiDB queries to be as fast as possible, ensuring that the farmer receives a timely response, which is critical in an agricultural context where time is of the essence.

Accomplishments We're Proud Of

We are most proud of the end-to-end, multi-step nature of the agent. It moves beyond a simple "what is this pest?" query to a complete "here's the pest, here's how to kill it, and here's how to buy the right tools" solution. The use of TiDB's vector search to correctly identify crop diseases from just an image is a significant technical achievement. We were also able to demonstrate a practical, life-changing application of AI that has a clear social good component, all built on a scalable and accessible platform like TiDB Serverless.

## What We Learned We learned that the true power of AI agents lies in their ability to combine different data types and tools to create a complete, automated solution. TiDB Serverless's ability to act as a unified hub for structured data, text, and vector embeddings was a game-changer for this project. We also learned that to build a successful solution for a specific context like African agriculture, the data must be highly localized and the final output must be practical and actionable for the end-user.

## What's Next for ShambaWise

Our vision is to expand ShambaWise into a comprehensive platform for sustainable agriculture. Our next steps include:

  • Community Data Contribution: We plan to allow farmers to contribute to the knowledge base by submitting their own data, which will improve the agent's accuracy and localization over time.
  • Predictive Analytics: We will leverage the historical data in TiDB to provide predictive advice, such as recommending planting times or fertilizer use based on long-term weather forecasts.
  • Integration with IoT: We will integrate with real-world sensors to provide real-time, hyper-localized advice on irrigation and soil health.
  • Marketplace Integration: We will build out a full-fledged marketplace API, connecting farmers directly to buyers to help them get a fair price for their produce, completing the entire farming cycle from diagnosis to sales.

Built With

Share this project:

Updates