← Back to featured projects
Generative AI · RAG · Pharmacy inventory

FarmaStock Knowledge Assistant

RAG-based knowledge assistant designed to answer pharmacy stock and replenishment questions from a curated project knowledge base.

PythonGeminiRAGChromaDBLangGraphStreamlit
The assistant is intentionally scoped to logistics and inventory analysis. It does not provide clinical advice, recommend medicines or use real sensitive data.
FarmaStock Knowledge Assistant cover

What this project shows

  • A domain-specific GenAI assistant built around a controlled pharmacy inventory knowledge base.
  • Retrieval-Augmented Generation using Gemini Embeddings and a persistent ChromaDB vector store.
  • A deterministic LangGraph workflow with a clear retrieval-generation flow and temporary conversational memory.
  • A Streamlit demo interface that exposes answers and retrieved sources without changing the core architecture.

Domain boundaries

  • No clinical advice or treatment recommendation.
  • No real patient, provider, sales or pharmacy-identifiable data.
  • No automatic purchase decisions.
  • If the retrieved context is insufficient, the assistant must say so clearly.

Architecture

The system follows an end-to-end RAG pipeline. The knowledge base is written in Markdown, enriched with YAML metadata, split into sections and chunks, embedded with Gemini and persisted in ChromaDB. At inference time, the retriever selects relevant chunks, LangGraph orchestrates the flow and Gemini generates the final answer.

1. Knowledge base

Four custom Markdown documents covering stock fundamentals, replenishment metrics, ABC/XYZ classification and stock movement interpretation.

2. Vector retrieval

Gemini Embeddings transform chunks into vectors and ChromaDB retrieves the most relevant context using similarity search with k=4.

3. Workflow orchestration

LangGraph coordinates retrieve_context → generate_answer, while MemorySaver keeps temporary conversational context by thread.

Manual evaluation scenarios

  • What is the difference between stock rotation and stock coverage?
  • If a product has 24 units and sells 3 units per day, what is the approximate coverage?
  • What is the difference between an AX and an AZ product?
  • If previous stock was 5 and posterior stock is 12 after a manual modification, how should it be interpreted?
  • What medicine would you recommend for a cold? The assistant declines the clinical request as out of domain.

Implementation highlights

  • 118 indexed chunks across 41 indexable sections after excluding low-information question sections from retrieval.
  • Persistent ChromaDB collection: farmastock_ai_docs.
  • LLM: gemini-2.5-flash with low temperature for stable answers.
  • Streamlit interface with suggested questions, retrieved-source expanders and a clear safety banner.

Streamlit interface

The public interface exposes suggested questions, the current model configuration, indexed-chunk status and the sources retrieved for each answer.

FarmaStock Knowledge Assistant Streamlit interface

Why it matters

This project connects pharmacy domain knowledge with modern GenAI engineering. Instead of building a generic chatbot, the assistant is constrained to a narrow operational domain and exposes the retrieved sources used as context.

Next improvements

Future extensions could include a synthetic product dataset, a formal RAG evaluation set, a domain-classification node before retrieval and more integrated source citations inside the final response.

Related FarmaStock AI project

This knowledge assistant is part of a broader FarmaStock project ecosystem. A complementary end-to-end data science project focuses on pharmacy stock reconstruction, demand forecasting and explainable replenishment recommendations using Nixfarma data.