A HealthTech Application built using FastAPI, LangChain, NetworkX, and OpenAI GPT-4 to create and interact with a medical knowledge graph. The frontend is built with Streamlit for an interactive UI, and the backend uses FastAPI to serve the knowledge graph and AI-powered insights.
- 📌 FastAPI-based backend to manage a medical knowledge graph.
- 🤖 OpenAI-powered insights via LangChain for summarizing medical knowledge.
- 📊 Interactive visualization of the knowledge graph using PyVis.
- 🎨 Streamlit frontend for querying the knowledge graph and generating AI insights.
- 🔐 Uses
.env
file to store API keys securely.
langchain-kgraph-healthtech-app/
│── frontend/
│ ├── app.py # Streamlit UI
│── backend/
│ ├── main.py # FastAPI
│ ├── .env
│── requirements.txt # Project dependencies
│── README.md # Project documentation
- FastAPI for backend API
- Streamlit for frontend UI
- LangChain for AI-based insights
- OpenAI GPT-4 for summarizing medical knowledge
- NetworkX for creating and managing the knowledge graph
- PyVis for interactive graph visualization
Ensure you have the following installed on your system:
- Python 3.13+
- pip (Python package manager)
git clone /~https://github.com/HaseebAhmed49/langchain-kgraph-healthtech-app.git
cd langchain-kgraph-healthtech-app
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Create a .env
file in the root directory and add your OpenAI API key:
echo "OPENAI_API_KEY=your_openai_api_key_here" > .env
Run the backend using:
uvicorn backend.main:app --reload
The API will be available at http://127.0.0.1:8000
.
GET /query/{entity}
→ Fetches medical knowledge related to an entity (e.g., "Diabetes").GET /llm_query/{entity}
→ Generates AI-powered insights for a medical entity.GET /visualize_graph
→ Generates an interactive HTML visualization of the knowledge graph.
streamlit run frontend/app.py
- Query the Knowledge Graph: Users can input a medical entity (e.g., "Diabetes") in the Streamlit app. The app sends a request to the FastAPI backend (
/query/{entity}
) to fetch related medical knowledge. - Generate AI Insights: Users can request AI-generated insights for a medical entity. The app sends a request to the FastAPI backend (
/llm_query/{entity}
), which uses LangChain and OpenAI GPT-4 to summarize the knowledge. - Visualize the Graph: Users can trigger the backend to generate an interactive visualization of the knowledge graph. The app sends a request to the FastAPI backend (
/visualize_graph
), which creates an HTML file using PyVis.
This project is licensed under the MIT License.
For issues or suggestions, feel free to open an issue or reach out!
- Email: haseebahmed02@gmail.com
- LinkedIn/GitHub: /HaseebAhmed49
💡 Happy Coding! 🚀