ShiftRx MVP is a minimal viable product for an AI-powered staffing solution designed for healthcare facility managers. It allows managers to quickly post shift details by sending natural language requests. The application processes the input using an LLM (OpenAI GPT-4o) to extract key shift details, which are then stored in a PostgreSQL database.
- Natural Language Processing: Uses OpenAI's GPT-4o to parse shift details from a free-form text input.
- RESTful API: A single endpoint (
POST /shifts/create) accepts user input and returns a confirmation with a unique shift ID. - Database Persistence: Shift details including position, start time, end time, rate, facility name, and location are stored in a PostgreSQL database.
- Robust Error Handling & Logging: Comprehensive logging is implemented using Python's logging module.
- Continuous Integration (CI): Automated tests are executed on every commit using GitHub Actions.
- Automated LLM Evaluations (Gold Standard Evaluation): Implemented rigorous automated LLM evaluations using a Gold Standard approach to verify the functionality, accuracy, and reliability of the AI component, ensuring high-quality field extraction from natural language inputs.
- Backend Framework: Python with Flask
- Database: PostgreSQL (with schema including columns:
id,position,start_time,end_time,rate,facility_name,location,created_at) - NLP/LLM Integration: OpenAI GPT-4o
- Environment Management: python-dotenv
- Testing: pytest
- CI/CD: GitHub Actions
git clone https://github.com/yourusername/shiftrx-mvp.git
cd shiftrx-mvppython -m venv venv
# On Windows using Git Bash:
source venv/Scripts/activate
# On macOS/Linux:
# source venv/bin/activatepip install -r requirements.txtCopy the example file to create your own configuration:
cp .env.example .envEdit the .env file and set the following values:
OPENAI_API_KEY: Your OpenAI API key (or a dummy key for testing)DB_HOST: Typically localhostDB_PORT: Typically 5432DB_USER: e.g., postgresDB_PASS: Your PostgreSQL password (for development, you might use postgres)DB_NAME: e.g., shiftrx
Install PostgreSQL if not already installed.
Open your terminal and run:
psql -U postgresCreate the database:
CREATE DATABASE shiftrx;
\qInitialize the schema:
psql -U postgres -d shiftrxThen run the following SQL command to create the table:
CREATE TABLE IF NOT EXISTS shifts (
id SERIAL PRIMARY KEY,
position VARCHAR(50),
start_time VARCHAR(50),
end_time VARCHAR(50),
rate VARCHAR(50),
facility_name VARCHAR(100) DEFAULT 'unknown',
location VARCHAR(100) DEFAULT 'unknown',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
\qStart the Flask development server:
python app.pyThe application will be available at http://127.0.0.1:5000.
Description:
Accepts a JSON payload with a user_input field containing a natural language description of the shift. The system processes the input using an LLM to extract shift details and then stores the data in the database.
Request:
- URL:
/shifts/create - Method:
POST - Headers:
Content-Type: application/json
Body Example:
{
"user_input": "We need a Pharmacist at City Hospital in Denver from 9AM to 5PM at $50/hr"
}Response:
- Success (
201 Created):
{
"success": true,
"shift_id": 1
}- Error (
400 Bad Request):
{
"error": "No user_input provided"
}- Error (
500 Internal Server Error):
{
"success": false,
"error": "Database insertion failed"
}Automated tests have been written using pytest. To run the tests:
pytestGitHub Actions is set up to run tests automatically on every push or pull request. See the .github/workflows/ci.yml file for details.
The application uses Python’s logging module for robust error handling and debugging. Log messages are printed to the console with timestamps and log levels.