Spaces:
Sleeping
Sleeping
JDFPalladium commited on
Commit Β·
29898af
1
Parent(s): afe6838
adding README and updating Makefile
Browse files- Makefile +4 -1
- README.md +109 -5
- config.env.example +3 -0
Makefile
CHANGED
|
@@ -9,4 +9,7 @@ test:
|
|
| 9 |
PYTHONPATH=. pytest -vv
|
| 10 |
|
| 11 |
format:
|
| 12 |
-
black app.py chatlib
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
PYTHONPATH=. pytest -vv
|
| 10 |
|
| 11 |
format:
|
| 12 |
+
black app.py chatlib
|
| 13 |
+
|
| 14 |
+
run:
|
| 15 |
+
python app.py
|
README.md
CHANGED
|
@@ -1,6 +1,110 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Clinician Assistant LG
|
| 2 |
|
| 3 |
+
A conversational assistant designed to help clinicians in Kenya access patient data and clinical guidelines efficiently. This project uses LangChain, LangGraph, and OpenAI models to provide context-aware, tool-augmented chat for clinical decision support.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## Features
|
| 8 |
+
|
| 9 |
+
- **RAG (Retrieval-Augmented Generation):** Retrieve relevant HIV clinical guidelines using natural language queries.
|
| 10 |
+
- **SQL Chain:** Query and summarize patient data from a structured database.
|
| 11 |
+
- **IDSR Check:** Analyze clinical cases for possible notifiable diseases and suggest clarifying questions.
|
| 12 |
+
- **PHI Filtering:** Detect and filter personally identifiable information from free text.
|
| 13 |
+
- **Session Management:** Supports persistent chat sessions with unique thread IDs.
|
| 14 |
+
- **Gradio UI:** Simple web interface for clinicians to interact with the assistant.
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## Project Structure
|
| 19 |
+
|
| 20 |
+
```
|
| 21 |
+
.
|
| 22 |
+
βββ app.py # Gradio web app entry point
|
| 23 |
+
βββ chatlib/ # Core logic, tools, and utilities
|
| 24 |
+
β βββ assistant_node.py
|
| 25 |
+
β βββ guidlines_rag_agent_li.py
|
| 26 |
+
β βββ idsr_check.py
|
| 27 |
+
β βββ patient_all_data.py
|
| 28 |
+
β βββ patient_sql_agent.py
|
| 29 |
+
β βββ phi_filter.py
|
| 30 |
+
β βββ state_types.py
|
| 31 |
+
βββ requirements.txt # Python dependencies
|
| 32 |
+
βββ Makefile # Common dev commands (lint, test, format)
|
| 33 |
+
βββ README.md # Project documentation
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## Setup
|
| 39 |
+
|
| 40 |
+
1. **Clone the repository:**
|
| 41 |
+
```sh
|
| 42 |
+
git clone <repo-url>
|
| 43 |
+
cd clinician-assistant-lg
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
2. **Install dependencies:**
|
| 47 |
+
```sh
|
| 48 |
+
make install
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
3. **Set up environment variables:**
|
| 52 |
+
- Copy `config.env.example` to `config.env` and fill in your OpenAI and LangSmith API keys.
|
| 53 |
+
|
| 54 |
+
4. **Run the app:**
|
| 55 |
+
```sh
|
| 56 |
+
python app.py
|
| 57 |
+
```
|
| 58 |
+
Or use the Makefile:
|
| 59 |
+
```sh
|
| 60 |
+
make run
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
---
|
| 64 |
+
|
| 65 |
+
## Usage
|
| 66 |
+
|
| 67 |
+
- Open the Gradio web interface (URL will be shown in the terminal).
|
| 68 |
+
- Enter a clinical question and (optionally) a patient identifier.
|
| 69 |
+
- The assistant will use the appropriate tools to answer, referencing guidelines and patient data as needed.
|
| 70 |
+
|
| 71 |
+
---
|
| 72 |
+
|
| 73 |
+
## Development
|
| 74 |
+
|
| 75 |
+
- **Lint code:** `make lint`
|
| 76 |
+
- **Format code:** `make format`
|
| 77 |
+
- **Run tests:** `make test`
|
| 78 |
+
|
| 79 |
+
---
|
| 80 |
+
|
| 81 |
+
## Requirements
|
| 82 |
+
|
| 83 |
+
See `requirements.txt` for the full list. Key dependencies:
|
| 84 |
+
- Python 3.10+
|
| 85 |
+
- gradio
|
| 86 |
+
- langchain_core, langchain_community, langchain_openai
|
| 87 |
+
- langgraph
|
| 88 |
+
- pandas
|
| 89 |
+
- pydantic
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
## Notes
|
| 94 |
+
|
| 95 |
+
- Patient data and guideline retrieval are tailored for Kenyan clinical workflows.
|
| 96 |
+
- The assistant is not a substitute for clinical judgment.
|
| 97 |
+
- All PHI is filtered to protect patient privacy.
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
## License
|
| 102 |
+
|
| 103 |
+
MIT License
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## Acknowledgements
|
| 108 |
+
|
| 109 |
+
- [LangChain](https://github.com/langchain-ai/langchain)
|
| 110 |
+
- [Gradio](https://github.com/gradio-app/gradio)
|
config.env.example
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
OPENAI_API_KEY = ""
|
| 2 |
+
LANGCHAIN_API_KEY = ""
|
| 3 |
+
PK_HASH = ""
|