This project provides a Medical Drug Interaction and Analysis API, allowing users to extract detailed medication-related information from multiple online sources, analyze drug interactions, and manage this data via a backend API.
The API integrates:
- Web scraping from trusted medical resources (e.g., drugs.com, 1mg.com).
- Natural language processing for content extraction and categorization using ChatGroq and LangChain.
- Persistent storage and querying of drug metadata using ChromaDB.
- RESTful endpoints for user interaction with medication data.
This project is built using Python with the Flask web framework and supports asynchronous background task execution via threading.
-
Drug Data Extraction
- Scrapes drug information from reliable sources.
- Uses a sophisticated language model (ChatGroq) for text processing and data extraction.
-
Drug Interaction Analysis
- Identifies potential interactions between drugs.
- Records metadata and interaction details for easy querying.
-
User Medication Management
- Links user-provided medication data with detailed drug analysis.
-
Persistent Storage
- Stores drug metadata and interaction data in ChromaDB.
- Enables fast querying of existing records.
-
REST API
- Provides endpoints to trigger background tasks and fetch/update medication data.
project/
├── Files/
│ ├── Original.py # Main Python File
│ # Background task handling
├── requirements.txt # Python dependencies
└── README.md # Documentation
- Python 3.8 or higher
- API key for ChatGroq
- Libraries: Flask, BeautifulSoup, requests, ChromaDB, LangChain
-
Clone the repository:
git clone https://github.com/krishnaAg16/DailyDoseLLM.git cd DailyDoseLLM.git
-
Install dependencies:
pip install -r requirements.txt
-
Configure ChatGroq API key:
- Replace
YOUR_API_KEY
inapp.py
with your actual API key.
- Replace
-
Run the Flask application:
python app.py
GET /addDrug/<usr>
- Description: Triggers a background task to scrape, analyze, and store drug data for a specific user.
- Parameters:
usr
: The user identifier.
- Response:
202 Accepted
: Task started successfully.500 Internal Server Error
: Task initialization failed.
Example:
curl -X GET http://127.0.0.1:5000/addDrug/user123
- Data Sources:
- Drugs.com
- 1mg.com
- Tools Used:
BeautifulSoup
for HTML parsing.requests
for making HTTP requests.
- LLM: ChatGroq (Llama-3.1-70B)
- Processing Steps:
- Scraped text is passed to the ChatGroq model via the LangChain pipeline.
- Extracted details include:
- Drug Name
- Recommended and avoided foods
- Interacting drugs
- Common and serious side effects
- Treatment use cases
- Purpose:
- Store and query drug metadata.
- Data Model:
{ "name": "DrugName", "super_food": ["list of recommended foods"], "bad_food": ["list of foods to avoid"], "interactive_drug": [ {"name": "InteractingDrug", "delta": "time in hours"} ], "common_symptom": ["list of common side effects"], "serious_symptom": ["list of serious side effects"], "treatment": ["medical conditions treated"] }
- Background tasks are handled using Python's
threading
module. - Tasks include:
- Fetching and analyzing user medication data.
- Updating drug interactions in the database.
Contributions are welcome! If you'd like to contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed description of changes.