Spaces:
Sleeping
Sleeping
Update API routes and endpoints
Browse files- .gitattributes +39 -1
- README.md +13 -100
- how_to_run.md +117 -0
.gitattributes
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
# Auto detect text files and perform LF normalization
|
| 2 |
* text=auto
|
| 3 |
|
|
@@ -31,4 +32,41 @@ Dockerfile text eol=lf
|
|
| 31 |
# Windows specific
|
| 32 |
*.bat text eol=crlf
|
| 33 |
*.cmd text eol=crlf
|
| 34 |
-
*.ps1 text eol=crlf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<<<<<<< HEAD
|
| 2 |
# Auto detect text files and perform LF normalization
|
| 3 |
* text=auto
|
| 4 |
|
|
|
|
| 32 |
# Windows specific
|
| 33 |
*.bat text eol=crlf
|
| 34 |
*.cmd text eol=crlf
|
| 35 |
+
*.ps1 text eol=crlf
|
| 36 |
+
=======
|
| 37 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 69 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 70 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 72 |
+
>>>>>>> cc72a56032827788eed3105a0ef90e037552e5a7
|
README.md
CHANGED
|
@@ -1,104 +1,17 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
- **main.py**: Entry point for the FastAPI application.
|
| 9 |
-
- **api/**: Contains API route definitions.
|
| 10 |
-
- **routes.py**: Defines the endpoints for the application.
|
| 11 |
-
- **services/**: Contains service logic for interacting with external APIs.
|
| 12 |
-
- **groq_service.py**: Handles requests to the Groq API and processes responses.
|
| 13 |
-
- **models/**: Contains data models for requests and responses.
|
| 14 |
-
- **request_models.py**: Defines request models for incoming data.
|
| 15 |
-
- **response_models.py**: Defines response models for outgoing data.
|
| 16 |
-
- **config/**: Contains configuration settings for the application.
|
| 17 |
-
- **settings.py**: Configuration for API keys and model IDs.
|
| 18 |
-
- **utils/**: Contains utility functions and prompt templates.
|
| 19 |
-
- **prompts.py**: Defines prompt templates for querying the model.
|
| 20 |
|
| 21 |
-
|
| 22 |
-
- **test_api.py**: Tests for API endpoints.
|
| 23 |
-
|
| 24 |
-
- **requirements.txt**: Lists the dependencies required for the project.
|
| 25 |
-
|
| 26 |
-
- **.env.example**: Template for environment variables.
|
| 27 |
-
|
| 28 |
-
- **.gitignore**: Specifies files to be ignored by Git.
|
| 29 |
-
|
| 30 |
-
- **Dockerfile**: Instructions for building a Docker image for the application.
|
| 31 |
-
|
| 32 |
-
## Setup Instructions
|
| 33 |
-
|
| 34 |
-
1. **Clone the Repository**:
|
| 35 |
-
Clone the repository to your local machine.
|
| 36 |
-
|
| 37 |
-
2. **Create a Virtual Environment**:
|
| 38 |
-
Create a virtual environment to manage dependencies.
|
| 39 |
-
```
|
| 40 |
-
python -m venv venv
|
| 41 |
-
```
|
| 42 |
-
|
| 43 |
-
3. **Activate the Virtual Environment**:
|
| 44 |
-
Activate the virtual environment.
|
| 45 |
-
- On Windows:
|
| 46 |
-
```
|
| 47 |
-
venv\Scripts\activate
|
| 48 |
-
```
|
| 49 |
-
- On macOS/Linux:
|
| 50 |
-
```
|
| 51 |
-
source venv/bin/activate
|
| 52 |
-
```
|
| 53 |
-
|
| 54 |
-
4. **Install Dependencies**:
|
| 55 |
-
Install the required dependencies using pip.
|
| 56 |
-
```
|
| 57 |
-
pip install -r requirements.txt
|
| 58 |
-
```
|
| 59 |
-
|
| 60 |
-
5. **Set Up Environment Variables**:
|
| 61 |
-
Copy `.env.example` to `.env` and fill in the necessary values, including the Groq API key and model ID.
|
| 62 |
-
|
| 63 |
-
6. **Run the Application**:
|
| 64 |
-
Start the FastAPI application.
|
| 65 |
-
```
|
| 66 |
-
uvicorn src.main:app --reload
|
| 67 |
-
```
|
| 68 |
-
|
| 69 |
-
## Usage
|
| 70 |
-
|
| 71 |
-
- **Endpoint**: `/api/coding`
|
| 72 |
-
- **Method**: `POST`
|
| 73 |
-
- **Request Body**:
|
| 74 |
-
```json
|
| 75 |
-
{
|
| 76 |
-
"provider_notes": "Your provider notes here."
|
| 77 |
-
}
|
| 78 |
-
```
|
| 79 |
-
|
| 80 |
-
- **Response**:
|
| 81 |
-
```json
|
| 82 |
-
{
|
| 83 |
-
"icd_codes": [
|
| 84 |
-
{
|
| 85 |
-
"code": "ICD_CODE_1",
|
| 86 |
-
"explanation": "Explanation for ICD_CODE_1"
|
| 87 |
-
}
|
| 88 |
-
],
|
| 89 |
-
"cpt_codes": [
|
| 90 |
-
{
|
| 91 |
-
"code": "CPT_CODE_1",
|
| 92 |
-
"explanation": "Explanation for CPT_CODE_1"
|
| 93 |
-
}
|
| 94 |
-
]
|
| 95 |
-
}
|
| 96 |
-
```
|
| 97 |
-
|
| 98 |
-
## Deployment
|
| 99 |
-
|
| 100 |
-
For deployment, you can use Docker to containerize the application. Follow the instructions in the Dockerfile to build and run the application in a containerized environment.
|
| 101 |
-
|
| 102 |
-
## License
|
| 103 |
-
|
| 104 |
-
This project is licensed under the MIT License. See the LICENSE file for more details.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: ICD CPT Coding API
|
| 3 |
+
emoji: 🏥
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
---
|
| 10 |
|
| 11 |
+
# ICD-10 and CPT Coding API
|
| 12 |
|
| 13 |
+
This API analyzes medical provider notes and returns appropriate ICD-10 and CPT codes with explanations.
|
| 14 |
|
| 15 |
+
## API Endpoint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
POST /api/v1/analyze
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
how_to_run.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<<<<<<< HEAD
|
| 2 |
+
# ICD-CPT Model
|
| 3 |
+
|
| 4 |
+
This project implements a FastAPI application that utilizes the Groq API and a language model (Llama 3.3 70b Versatile) to provide CPT and ICD coding based on provider notes. The application is designed to return structured JSON responses that include the predicted codes along with explanations for each code.
|
| 5 |
+
|
| 6 |
+
## Project Structure
|
| 7 |
+
|
| 8 |
+
- **src/**: Contains the main application code.
|
| 9 |
+
- **main.py**: Entry point for the FastAPI application.
|
| 10 |
+
- **api/**: Contains API route definitions.
|
| 11 |
+
- **routes.py**: Defines the endpoints for the application.
|
| 12 |
+
- **services/**: Contains service logic for interacting with external APIs.
|
| 13 |
+
- **groq_service.py**: Handles requests to the Groq API and processes responses.
|
| 14 |
+
- **models/**: Contains data models for requests and responses.
|
| 15 |
+
- **request_models.py**: Defines request models for incoming data.
|
| 16 |
+
- **response_models.py**: Defines response models for outgoing data.
|
| 17 |
+
- **config/**: Contains configuration settings for the application.
|
| 18 |
+
- **settings.py**: Configuration for API keys and model IDs.
|
| 19 |
+
- **utils/**: Contains utility functions and prompt templates.
|
| 20 |
+
- **prompts.py**: Defines prompt templates for querying the model.
|
| 21 |
+
|
| 22 |
+
- **tests/**: Contains unit tests for the application.
|
| 23 |
+
- **test_api.py**: Tests for API endpoints.
|
| 24 |
+
|
| 25 |
+
- **requirements.txt**: Lists the dependencies required for the project.
|
| 26 |
+
|
| 27 |
+
- **.env.example**: Template for environment variables.
|
| 28 |
+
|
| 29 |
+
- **.gitignore**: Specifies files to be ignored by Git.
|
| 30 |
+
|
| 31 |
+
- **Dockerfile**: Instructions for building a Docker image for the application.
|
| 32 |
+
|
| 33 |
+
## Setup Instructions
|
| 34 |
+
|
| 35 |
+
1. **Clone the Repository**:
|
| 36 |
+
Clone the repository to your local machine.
|
| 37 |
+
|
| 38 |
+
2. **Create a Virtual Environment**:
|
| 39 |
+
Create a virtual environment to manage dependencies.
|
| 40 |
+
```
|
| 41 |
+
python -m venv venv
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
3. **Activate the Virtual Environment**:
|
| 45 |
+
Activate the virtual environment.
|
| 46 |
+
- On Windows:
|
| 47 |
+
```
|
| 48 |
+
venv\Scripts\activate
|
| 49 |
+
```
|
| 50 |
+
- On macOS/Linux:
|
| 51 |
+
```
|
| 52 |
+
source venv/bin/activate
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
4. **Install Dependencies**:
|
| 56 |
+
Install the required dependencies using pip.
|
| 57 |
+
```
|
| 58 |
+
pip install -r requirements.txt
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
5. **Set Up Environment Variables**:
|
| 62 |
+
Copy `.env.example` to `.env` and fill in the necessary values, including the Groq API key and model ID.
|
| 63 |
+
|
| 64 |
+
6. **Run the Application**:
|
| 65 |
+
Start the FastAPI application.
|
| 66 |
+
```
|
| 67 |
+
uvicorn src.main:app --reload
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
## Usage
|
| 71 |
+
|
| 72 |
+
- **Endpoint**: `/api/coding`
|
| 73 |
+
- **Method**: `POST`
|
| 74 |
+
- **Request Body**:
|
| 75 |
+
```json
|
| 76 |
+
{
|
| 77 |
+
"provider_notes": "Your provider notes here."
|
| 78 |
+
}
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
- **Response**:
|
| 82 |
+
```json
|
| 83 |
+
{
|
| 84 |
+
"icd_codes": [
|
| 85 |
+
{
|
| 86 |
+
"code": "ICD_CODE_1",
|
| 87 |
+
"explanation": "Explanation for ICD_CODE_1"
|
| 88 |
+
}
|
| 89 |
+
],
|
| 90 |
+
"cpt_codes": [
|
| 91 |
+
{
|
| 92 |
+
"code": "CPT_CODE_1",
|
| 93 |
+
"explanation": "Explanation for CPT_CODE_1"
|
| 94 |
+
}
|
| 95 |
+
]
|
| 96 |
+
}
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
## Deployment
|
| 100 |
+
|
| 101 |
+
For deployment, you can use Docker to containerize the application. Follow the instructions in the Dockerfile to build and run the application in a containerized environment.
|
| 102 |
+
|
| 103 |
+
## License
|
| 104 |
+
|
| 105 |
+
This project is licensed under the MIT License. See the LICENSE file for more details.
|
| 106 |
+
=======
|
| 107 |
+
---
|
| 108 |
+
title: Icd Cpt Coding Api
|
| 109 |
+
emoji: 📈
|
| 110 |
+
colorFrom: indigo
|
| 111 |
+
colorTo: indigo
|
| 112 |
+
sdk: docker
|
| 113 |
+
pinned: false
|
| 114 |
+
---
|
| 115 |
+
|
| 116 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 117 |
+
>>>>>>> cc72a56032827788eed3105a0ef90e037552e5a7
|