Skip to content

ygivenx/clinExtract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClinExtract

This is a simple API which returns structured values as JSON file from medical notes.

Features

  • 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

Installation

# Clone the repository
git clone https://github.com/yourusername/clinextract.git
cd clinextract

# Install dependencies
pip install -e .

Configuration

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

Usage

Start the server

python app.py

The API will be available at http://localhost:8000.

API Endpoints

POST /setup-prompt

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"
}

POST /process

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."
}

API Documentation

When the server is running, you can access the interactive API documentation at:

Adding New Providers

To add support for a new model provider:

  1. Create a new class that extends ModelProvider
  2. Implement the process method
  3. Update the get_model_provider factory function to support the new provider

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages