Spaces:
Running
Running
File size: 10,182 Bytes
6dc9d46 aefac4f 6dc9d46 aefac4f 6dc9d46 aefac4f 6dc9d46 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | # Contributing to MediGuard AI RAG-Helper
First off, thank you for considering contributing to MediGuard AI! It's people like you that make this project better for everyone.
## π Table of Contents
- [Code of Conduct](#code-of-conduct)
- [Getting Started](#getting-started)
- [How Can I Contribute?](#how-can-i-contribute)
- [Development Setup](#development-setup)
- [Style Guidelines](#style-guidelines)
- [Commit Messages](#commit-messages)
- [Pull Request Process](#pull-request-process)
## Code of Conduct
This project adheres to a code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
### Our Standards
- **Be Respectful**: Treat everyone with respect
- **Be Collaborative**: Work together effectively
- **Be Professional**: Maintain professionalism at all times
- **Be Inclusive**: Welcome diverse perspectives and backgrounds
## Getting Started
### Prerequisites
- Python 3.11+
- Git
- A GitHub account
- FREE API key from Groq or Google Gemini
### First Contribution
1. **Fork the repository**
2. **Clone your fork**
```bash
git clone https://github.com/your-username/RagBot.git
cd RagBot
```
3. **Set up development environment** (see below)
4. **Create a new branch**
```bash
git checkout -b feature/your-feature-name
```
## How Can I Contribute?
### π Reporting Bugs
**Before submitting a bug report:**
- Check the [existing issues](https://github.com/yourusername/RagBot/issues)
- Ensure you're using the latest version
- Collect relevant information (Python version, OS, error messages)
**How to submit a good bug report:**
- Use a clear and descriptive title
- Describe the exact steps to reproduce
- Provide specific examples
- Describe the behavior you observed and what you expected
- Include screenshots if applicable
- Include your environment details
**Template:**
```markdown
## Bug Description
[Clear description of the bug]
## Steps to Reproduce
1.
2.
3.
## Expected Behavior
[What should happen]
## Actual Behavior
[What actually happens]
## Environment
- OS: [e.g., Windows 11, macOS 14, Ubuntu 22.04]
- Python Version: [e.g., 3.11.5]
- MediGuard Version: [e.g., 1.0.0]
## Additional Context
[Any other relevant information]
```
### π‘ Suggesting Enhancements
**Before submitting an enhancement suggestion:**
- Check if it's already been suggested
- Determine which part of the project it relates to
- Consider if it aligns with the project's goals
**How to submit a good enhancement suggestion:**
- Use a clear and descriptive title
- Provide a detailed description of the proposed enhancement
- Explain why this enhancement would be useful
- List potential benefits and drawbacks
- Provide examples or mockups if applicable
### π¨ Pull Requests
**Good first issues:**
- Look for issues labeled `good first issue`
- Documentation improvements
- Test coverage improvements
- Bug fixes
**Areas needing contribution:**
- Additional biomarker support
- Disease model improvements
- Performance optimizations
- Documentation enhancements
- Test coverage
- UI/UX improvements
## Development Setup
### 1. Fork and Clone
```bash
# Fork via GitHub UI, then:
git clone https://github.com/your-username/RagBot.git
cd RagBot
```
### 2. Create Virtual Environment
```bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```
### 3. Install Dependencies
```bash
# Core dependencies
pip install -r requirements.txt
# Development dependencies
pip install pytest pytest-cov black flake8 mypy
```
### 4. Configure Environment
```bash
cp .env.template .env
# Edit .env with your API keys
```
### 5. Run Tests
```bash
# Run unit tests (30 tests)
.venv\Scripts\python.exe -m pytest tests/ -q \
--ignore=tests/test_basic.py \
--ignore=tests/test_diabetes_patient.py \
--ignore=tests/test_evolution_loop.py \
--ignore=tests/test_evolution_quick.py \
--ignore=tests/test_evaluation_system.py
# Run with coverage
.venv\Scripts\python.exe -m pytest --cov=src tests/
# Run specific test file
.venv\Scripts\python.exe -m pytest tests/test_codebase_fixes.py -v
```
## Style Guidelines
### Python Code Style
We follow **PEP 8** with some modifications:
- **Line length**: 100 characters maximum
- **Imports**: Organized with `isort`
- **Formatting**: Automated with `black`
- **Type hints**: Required for function signatures
- **Docstrings**: Google style
### Code Formatting
**Before committing, run:**
```bash
# Auto-format code
black src/ scripts/ tests/
# Check style compliance
flake8 src/ scripts/ tests/
# Type checking
mypy src/
# Import sorting
isort src/ scripts/ tests/
```
### Docstring Example
```python
def analyze_biomarkers(
biomarkers: Dict[str, float],
patient_context: Optional[Dict[str, Any]] = None
) -> AnalysisResult:
"""
Analyze patient biomarkers and generate clinical insights.
Args:
biomarkers: Dictionary of biomarker names to values
patient_context: Optional patient demographic information
Returns:
AnalysisResult containing predictions and recommendations
Raises:
ValueError: If biomarkers dictionary is empty
ValidationError: If biomarker values are invalid
Example:
>>> result = analyze_biomarkers({"Glucose": 185, "HbA1c": 8.2})
>>> print(result.prediction.disease)
'Diabetes'
"""
pass
```
### Testing Guidelines
- **Write tests** for all new features
- **Maintain coverage** above 80%
- **Test edge cases** and error conditions
- **Use descriptive test names**
**Test Example:**
```python
def test_biomarker_validation_with_critical_high_glucose():
"""Test that critically high glucose values trigger safety alerts."""
validator = BiomarkerValidator()
biomarkers = {"Glucose": 400} # Critically high
flags, alerts = validator.validate_all(biomarkers)
assert len(alerts) > 0
assert any("critical" in alert.message.lower() for alert in alerts)
```
## Commit Messages
### Format
```
<type>(<scope>): <subject>
<body>
<footer>
```
### Types
- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation changes
- `style`: Code style changes (formatting, etc.)
- `refactor`: Code refactoring
- `test`: Adding or updating tests
- `chore`: Maintenance tasks
### Examples
```bash
# Good commit messages
git commit -m "feat(agents): add liver disease detection agent"
git commit -m "fix(validation): correct hemoglobin range for females"
git commit -m "docs: update API documentation with new endpoints"
git commit -m "test: add integration tests for workflow"
# Bad commit messages (avoid these)
git commit -m "fixed stuff"
git commit -m "updates"
git commit -m "WIP"
```
## Pull Request Process
### Before Submitting
1. β
**Update your branch** with latest main
```bash
git checkout main
git pull upstream main
git checkout your-feature-branch
git rebase main
```
2. β
**Run all tests** and ensure they pass
```bash
pytest
```
3. β
**Format your code**
```bash
black src/ scripts/ tests/
flake8 src/ scripts/ tests/
```
4. β
**Update documentation** if needed
- README.md
- Docstrings
- API documentation
5. β
**Add/update tests** for your changes
### Submitting the PR
1. **Push to your fork**
```bash
git push origin your-feature-branch
```
2. **Create pull request** via GitHub UI
3. **Fill out the PR template** completely
### PR Template
```markdown
## Description
[Clear description of what this PR does]
## Type of Change
- [ ] Bug fix (non-breaking change)
- [ ] New feature (non-breaking change)
- [ ] Breaking change
- [ ] Documentation update
## Related Issues
Fixes #[issue number]
## Testing
- [ ] All tests pass locally
- [ ] Added new tests for changes
- [ ] Updated existing tests
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex code
- [ ] Documentation updated
- [ ] No new warnings generated
```
### Review Process
1. **Automated checks** must pass (if configured)
2. **Code review** by maintainer(s)
3. **Address feedback** if requested
4. **Approval** from maintainer
5. **Merge** by maintainer
### After Merge
- Delete your feature branch
- Update your fork's main branch
- Celebrate! π
## Project Structure
Understanding the codebase:
```
src/
βββ agents/ # Specialist agent implementations
βββ evaluation/ # Quality evaluation framework
βββ evolution/ # Self-improvement engine
βββ biomarker_validator.py # Validation logic
βββ config.py # Configuration classes
βββ llm_config.py # LLM setup
βββ pdf_processor.py # Vector store management
βββ state.py # State definitions
βββ workflow.py # Main workflow orchestration
```
## Development Tips
### Local Testing
```bash
# Test specific component
python -c "from src.biomarker_validator import BiomarkerValidator; v = BiomarkerValidator(); print('OK')"
# Test workflow initialization
python -c "from src.workflow import create_guild; guild = create_guild(); print('Guild OK')"
# Test chat interface
python scripts/chat.py
```
### Debugging
- Use `print()` statements liberally during development
- Set `LANGCHAIN_TRACING_V2="true"` for LLM call tracing
- Check logs in the console output
- Use Python debugger: `import pdb; pdb.set_trace()`
### Common Issues
**Import errors:**
- Ensure you're in the project root directory
- Check virtual environment is activated
**API errors:**
- Verify API keys in `.env`
- Check rate limits haven't been exceeded
**Vector store errors:**
- Ensure FAISS indices exist in `data/vector_stores/`
- Run `python src/pdf_processor.py` to rebuild if needed
## Questions?
- **General questions**: Open a GitHub Discussion
- **Bug reports**: Open a GitHub Issue
- **Security concerns**: Email maintainers directly
## Recognition
Contributors will be recognized in:
- Project README
- Release notes
- Special mentions for significant contributions
Thank you for contributing! π
|