A Python application that provides structured diabetes risk assessments using OpenAI's language models. The application processes patient data, generates risk assessments, and validates the output to ensure reliability and consistency.
- Structured diabetes risk assessment using OpenAI's GPT models
- Input validation using Pydantic models
- Comprehensive test suite with unit and integration tests
- Mock-based testing to avoid real API calls during development
- Type hints and static type checking with mypy
- Code formatting with Black and isort
- Python 3.10 or higher
- OpenAI API key
- pip (Python package manager)
-
Clone the repository:
git clone https://github.com/yourusername/llm_output_validation.git cd llm_output_validation -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up your environment variables:
cp .env.example .env # Edit .env and add your OpenAI API key
from diabetes_diagnosis import get_risk
patient_data = {
"age": 45,
"bmi": 28.5,
"glucose_level": 110,
"family_history": "Father had type 2 diabetes",
"symptoms": ["increased thirst", "frequent urination"],
"blood_pressure": "130/85",
"cholesterol": {"total": 210, "hdl": 45, "ldl": 130},
"physical_activity": "sedentary"
}
result = get_risk(patient_data)
print(result)The test suite includes unit tests and integration tests with mocked API responses.
# Run all tests
pytest tests/
# Run with coverage report
pytest --cov=diabetes_diagnosis tests/
# Generate HTML coverage report
pytest --cov=diabetes_diagnosis --cov-report=html tests/tests/test_diabetes.py: Core functionality teststests/test_edge_cases.py: Edge case validation teststests/test_mock_scenarios.py: Mocked API response tests
The project uses:
- Black for code formatting
- isort for import sorting
- mypy for static type checking
- Create a feature branch
- Make your changes
- Run tests and checks:
black . isort . mypy . pytest
- Commit your changes with a descriptive message
- Open a pull request
- Python 3.6+
- OpenAI API key