RxQuery.AI: Your Dr. Internet Replacement powered by MindsDB!



This content originally appeared on DEV Community and was authored by Juanita

A pharmacist-AI that’s here to replace your endless scrolling of symptoms and remedies on google search! Ask your queries and get smarter, faster and reliable responses.

Well, What is RxQuery and Why?

Imagine a world where AI acts like your own personal pharmacist, answering your drug-related queries, recommending safe alternatives, and analyzing side effects—all in seconds. Yea, that’s our goal lol. RxQuery is an intelligent, AI-powered drug information finder and medicine assistant (think of a pharmacy simulator?) that provides instant, reliable drug consultation through an intuitive interface.

⚠ Note: RxQuery.AI is not a substitute for professional medical advice. Please consult actual doctors, thanks 🙂

💡 Why We Built RxQuery.AI

With the vast amount of drug data available out there, we wanted to simplify access using natural language queries. Traditional search doesn’t cut it, semantic understanding is key ( basically understanding user context ). This allows users to narrow down their drug queries and get smarter and safer responses. To implement this semantic understanding, we use MindsDB’s Knowledge bases.

✨ Key Features

General Purpose Assistant: RxAssistant (via AI Table)
AI Agents:

  • 🔍 Drug Classification – Instantly classify medications (Antibiotic, Analgesic, etc.)
  • 💊 Smart Recommendations – Get personalized drug suggestions based on symptoms
  • ⚠ Side Effects Checker – Comprehensive side effects analysis
  • 🛡 Allergy-Safe Search – Find safe alternatives for patients with allergies Command based input:
  • Command-based Interaction – We use simple slash commands like /classify, /recommend, etc to select the agent and input in a singular input field.
  • Voice Interaction – Talk to RxQuery for hands-free health queries
  • Intuitive UI/UX – Chat-based interface with real-time updates

🛠 Tech Stack

  • Frontend: Next.js 14, TypeScript, Tailwind CSS, Framer Motion, Shadcn, MVPBlocks
  • Backend: FastAPI, Python, Pydantic

#🧠 MindsDB

  • CREATE KNOWLEDGE_BASE, INSERT INTO, CREATE INDEX(chromadb)

  • CHAINED MULTI AGENTS using CREATE AGENT for each feature (/classify, /recommend, /side-effects, etc.)

  • EVALUATE KNOWLEDGE_BASE with Groq for document scoring

  • CREATE JOB to ingest drug data periodically

  • SELECT ... WHERE content LIKE in semanticss!

  • metadata_columns to enable hybrid semantic + SQL filtering

  • CREATE MODEL rx_assistant with OpenAI for reasoning and classification

  • KB_EVALUATE: Groq LLM, AI TABLES: OpenAI, AGENTS: OpenAI, Ollama (experimental, model removed)

  • 🧪 Editor: Our MindsDB SQL Editor code is included as reference for building/debugging Agents and KB queries.

P.S KNOWLEDGE BASES, AGENTS AND AI TABLES powered by MindsDB!

ARCHITECTURE!

Image description

Deep dive into implementation~

1.🧩 Knowledge Base Creation

Everything starts with the creation of a Knowledge Base (drug_kb), which acts as the centralized, semantically searchable store for drug data.

CREATE KNOWLEDGE_BASE drug_kb
USING
embedding_model = {
"provider": "",
"model_name": "",
"base_url": ""
},
reranking_model = {
"provider": "",
"model_name": "",
"base_url": ""
},
metadata_columns = ['category', 'usage'],
content_columns = ['description'],
id_column = 'drug_name';

  • metadata_columns: Supports hybrid queries (e.g., filter by category).
  • content_columns: The KB “reads” from description, basically here only we have the semantic matching.

2.📥Ingesting Data into the KB

Once the KB is created, we ingest structured data from a CSV file (medicine_details) into it

INSERT INTO drug_kb (drug_name, description, category, usage)
SELECT drug_name, description, category, usage
FROM files.medicine_details
LIMIT 50;

We will be automating this ingestion later using Jobs

3.🔍 Semantic Querying

Now that our KB is populated, we can use natural-language-style semantic queries — thanks to the embeddings under the hood.

SELECT *
FROM drug_kb
WHERE content LIKE 'what drug to use for Fever and Headaches category?';

This gives us relevant drugs, even if the query doesn’t match word-for-word. Basically, semantics lol.

4.🧠 Chained Multi-Agent Pipeline

We’ve created a modular AI agent chain, where each step enriches context for the next. These agents access the KB for tailored outputs!

a. Classify Agent

CREATE AGENT classify_agent
USING
input_column = 'question',
output_column = 'response',
prompt_template =
'Classify the query "{{question}}" into a drug category like Antibiotic, Antipyretic etc.';

Classify agent obviously, used to infer drug class from user symptoms. (e.g., “fever” → Antipyretic).

b. Recommender Agent

CREATE AGENT drug_recommender
USING
input_column = 'question',
output_column = 'recommendation',
metadata_columns = ['category'],
prompt_template =
'Based on drugs in category "{{category}}", what should user take for: {{question}}?';

This agent uses the output from the Classifier and the category metadata in the KB.

c. Side Effects Agent

CREATE AGENT side_effect_agent
USING
input_column = 'recommendation',
output_column = 'side_effects',
prompt_template =
'what are the common side effects of the drug "{{recommendation}}" ?';

Gives post-recommendation validation like on side effects and stuff, ensuring user safety.

d. Allergy-Safe Agent

CREATE AGENT allergy_safe_recommender
USING
input_column = 'allergy',
output_column = 'safe_drug',
prompt_template =
'Given the allergy: "{{allergy}}", recommend a safe drug that avoids triggering it. Also explain why it is suitable shortly.';

Well as name says, it filters recommendations based on allergy risk.

5. 🛠 AI Tables: rx_assistant

In addition to agents, we used AI Tables for general-purpose assistance.

CREATE MODEL rx_assistant
PREDICT response
USING
engine = 'openai',
model_name = '',
api_key = '',
prompt_template =
'You are a helpful drug information assistant. If a user inputs a user query "{{question}}" and allergy "{{allergy}}", return helpful medicine suggestions...'

This model takes free-form medical questions and provides safe suggestions, optionally filtering with user allergy input.

6.⏱Automated Ingestion: JOBS

CREATE JOB drug_kb_updater AS (
INSERT INTO drug_kb (drug_name, description, category, usage)
SELECT drug_name, description, category, usage
FROM files.medicine_details
WHERE id > COALESCE(LAST, 0)
)
EVERY 1 hour;

Well this just makes sure everything is upto date and kb is updated…this occurs every 1 hour.

** 7.⚠ We do our knowledge base evaluation using Groq with the command EVALUATE KNOWLEDGE_BASE**

✨ ✨ To the curious folks,

If y’all are interested and wanna try it out, you can do so on your local:

Prerequisites

  • Python 3.8+
  • Node.js 18+

Backend Setup

cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

Frontend Setup

cd frontend/rxquery
npm install
npm run dev

Something like this~

Command Example Result
/classify /classify paracetamol → “Antipyretic”
/recommend /recommend headache → “Paracetamol 500mg every 6 hours”
/side-effects /side-effects Ibuprofen → “Stomach upset, kidney issues with long-term use”
/allergy /allergy penicillin → “Try Azithromycin (macrolide class)”
/general /general tired and dizzy → *”Drink warm water, eat light foods and take dolo.”

🍒 Acknowledgments

  • MindsDB team for the amazing AI platform
  • Kaggle for the dataset
  • Open source community for inspiration

Thank you for reading, hope you all like it and try it out! 🙂


This content originally appeared on DEV Community and was authored by Juanita