This is a simple API which returns structured values as JSON file from medical notes.
- Extract ECOG and KPS scores from clinical notes
- Support for multiple LLM providers:
- Anthropic Claude (via AWS Bedrock)
- OpenAI models (GPT-4o, etc.)
- UUID-based prompt management for reusable configurations
- Easy-to-use API with FastAPI
# Clone the repository
git clone https://github.com/yourusername/clinextract.git
cd clinextract
# Install dependencies
pip install -e .Create a .env file in the root directory with your API keys:
# For AWS Bedrock
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
# For OpenAI (if using)
OPENAI_API_KEY=your_openai_api_key
python app.pyThe API will be available at http://localhost:8000.
Store a prompt configuration with a UUID for reuse in multiple requests.
Example request:
{
"prompt": "You are a clinical data extraction assistant specialized in oncology. Extract ECOG and KPS scores from the provided notes.",
"provider": "anthropic",
"model_id": "anthropic.claude-3-5-sonnet-20240620-v1:0"
}All fields except prompt are optional.
Example response:
{
"prompt_id": "123e4567-e89b-12d3-a456-426614174000"
}You can also update an existing prompt by providing its UUID:
{
"prompt_id": "123e4567-e89b-12d3-a456-426614174000",
"prompt": "Updated prompt text...",
"provider": "openai",
"model_id": "gpt-4o"
}Process a clinical note to extract ECOG and KPS scores.
You can either use a previously stored prompt configuration with its UUID:
{
"text": "Patient is doing well. Physical Exam: KPS/ECOG: 80 / 1.",
"prompt_id": "123e4567-e89b-12d3-a456-426614174000"
}Or provide configuration directly (if no prompt_id is provided):
{
"text": "Patient is doing well. Physical Exam: KPS/ECOG: 80 / 1.",
"provider": "anthropic",
"model_id": "anthropic.claude-3-5-sonnet-20240620-v1:0"
}Note: When prompt_id is provided, any provider and model_id fields in the request are ignored.
Example response:
{
"ecog": 1,
"ecog_source": "KPS/ECOG: 80 / 1.",
"kps": 80,
"kps_source": "KPS/ECOG: 80 / 1."
}When the server is running, you can access the interactive API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
To add support for a new model provider:
- Create a new class that extends
ModelProvider - Implement the
processmethod - Update the
get_model_providerfactory function to support the new provider