About the project:
We developed a custom AI agent for a leading pharmacy chain that needed real-time, intelligent access to its internal database of medicine availability and pricing. The core of the system is a DeepSeek language model, fine-tuned using the PyTorch library with extensive pharmaceutical documentation, product manuals, and drug reference materials. This fine-tuning enabled the model to not only understand the chemical and medical context of medicines but also handle complex queries from customers and staff with precision.
The model training process was orchestrated on Amazon EC2 Spot Instances to reduce costs during experimentation. The fine-tuned DeepSeek model is hosted on Hugging Face, ensuring secure and scalable access via API. The model’s agent layer—responsible for interacting with users—was built using self-hosted n8n, providing modular logic, automation workflows, and integration points to Google Docs and other internal systems.
To enable real-time pharmacy data retrieval, we implemented Agentic RAG (Retrieval-Augmented Generation). The agent connects to the company’s internal SQL database, instantly fetching drug availability, pricing, and pharmacy location data. A Redis-based contextual memory system was integrated using the LangChain library, allowing the agent to maintain conversation context, remember user preferences, and switch focus using the MCP (Memory Context Protocol). This setup ensures continuity during complex, multi-step interactions.
The solution is hosted on a private VPS (8 CPU cores, 64GB RAM, 1TB NVMe storage), with Redis operating on a dedicated 4GB memory instance. For persistence and failover, backups are stored securely on S3. Future proofing the system, the AI agent also integrates with a Google Docs folder where additional approved pharmaceutical documentation resides, allowing it to reference official guidelines or instructions dynamically when responding to specific queries.
In practice, the agent assists pharmacists and customers by providing drug descriptions, interactions, and up-to-date availability data. This hybrid system—bridging RAG, context-aware memory, and human-readable explanations—serves as a practical example of how AI can be safely and effectively embedded in regulated industries like healthcare.
Development time :
6 months