generated from kyegomez/Python-Package-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
123 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,160 @@ | ||
[![Multi-Modality](agorabanner.png)](https://discord.com/servers/agora-999382051935506503) | ||
|
||
# Python Package Template | ||
# MedGuard | ||
|
||
|
||
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb) | ||
|
||
A easy, reliable, fluid template for python packages complete with docs, testing suites, readme's, github workflows, linting and much much more | ||
**MedGuard** is a robust, production-grade Python library that ensures HIPAA compliance for large language model (LLM) agents. Designed for enterprise applications in healthcare, MedGuard provides comprehensive security, privacy, and compliance frameworks that integrate seamlessly into your AI-driven workflows. The library guarantees that your AI models and agents operate within strict regulatory boundaries, particularly the Health Insurance Portability and Accountability Act (HIPAA), ensuring the protection of sensitive health data. | ||
|
||
## Key Features | ||
|
||
- **HIPAA-Compliant Workflows**: Ensures that LLM agents handle Protected Health Information (PHI) securely and within HIPAA guidelines. | ||
- **End-to-End Encryption**: Provides automatic encryption for data in transit and at rest to protect sensitive health data. | ||
- **Audit Logging**: Tracks all agent interactions, data access, and usage patterns for auditing and compliance reporting. | ||
- **Role-Based Access Control (RBAC)**: Fine-grained control over who can access and interact with specific data points within the system. | ||
- **Data Anonymization and Masking**: Automatically anonymizes or masks PHI when shared, minimizing the risk of data breaches. | ||
- **Seamless Integration**: Designed to integrate with popular AI/LLM libraries such as OpenAI, Hugging Face, and custom LLM architectures. | ||
- **Configurable Policies**: Allows for the customization of compliance policies and controls according to specific organizational needs. | ||
- **Scalable Infrastructure**: Built to support enterprise-level deployments, capable of scaling across cloud, hybrid, and on-premise environments. | ||
- **Comprehensive Testing Suite**: Includes unit tests, integration tests, and compliance checks to ensure secure and reliable operations. | ||
|
||
## Installation | ||
|
||
You can install the package using pip | ||
To install MedGuard, use the following pip command: | ||
|
||
```bash | ||
pip install -e . | ||
pip install medguard | ||
``` | ||
|
||
## Quick Start | ||
|
||
Here’s a quick guide to get MedGuard up and running in your environment: | ||
|
||
### 1. Setting Up Your MedGuard Environment | ||
|
||
```python | ||
from medguard import MedGuard | ||
|
||
# Initialize MedGuard with your organization's compliance configuration | ||
medguard = MedGuard(api_key="your_api_key", | ||
encryption_key="your_encryption_key", | ||
compliance_level="HIPAA") | ||
``` | ||
|
||
# Usage | ||
### 2. Integrating MedGuard with Your LLM Agent | ||
|
||
```python | ||
print("hello world") | ||
from your_llm_library import YourLLMAgent | ||
|
||
# Create an instance of your LLM agent | ||
llm_agent = YourLLMAgent() | ||
|
||
# Wrap the LLM agent with MedGuard for HIPAA compliance | ||
compliant_agent = medguard.wrap_agent(llm_agent) | ||
|
||
# Use the compliant agent to ensure all communications adhere to HIPAA guidelines | ||
response = compliant_agent.process("Analyze this patient's health record and recommend treatment.") | ||
``` | ||
|
||
### 3. Anonymizing Sensitive Data | ||
|
||
```python | ||
# Automatically anonymize sensitive data in the agent's output | ||
anonymized_output = medguard.anonymize(response) | ||
``` | ||
|
||
### 4. Logging and Auditing | ||
|
||
```python | ||
# Log and audit all interactions for compliance review | ||
medguard.audit.log_interaction(agent_id="1234", user_id="5678", input_data="Patient data", output_data=response) | ||
``` | ||
|
||
## Enterprise Features | ||
|
||
### Role-Based Access Control (RBAC) | ||
|
||
### Code Quality 🧹 | ||
MedGuard supports advanced role-based access to ensure only authorized users and systems can access PHI. | ||
|
||
- `make style` to format the code | ||
- `make check_code_quality` to check code quality (PEP8 basically) | ||
- `black .` | ||
- `ruff . --fix` | ||
```python | ||
# Define roles and permissions | ||
medguard.set_role("doctor", permissions=["read", "write"]) | ||
medguard.set_role("nurse", permissions=["read"]) | ||
``` | ||
|
||
### Audit and Compliance Reporting | ||
|
||
### Tests 🧪 | ||
MedGuard provides detailed audit logs and compliance reports, ensuring that your AI systems remain transparent and fully auditable. | ||
|
||
```python | ||
# Generate audit reports | ||
audit_report = medguard.generate_compliance_report(start_date="2024-01-01", end_date="2024-01-31") | ||
print(audit_report) | ||
``` | ||
|
||
[`pytests`](https://docs.pytest.org/en/7.1.x/) is used to run our tests. | ||
### End-to-End Encryption | ||
|
||
### Publish on PyPi 🚀 | ||
MedGuard enforces encryption both in transit and at rest for all interactions with LLM agents. | ||
|
||
**Important**: Before publishing, edit `__version__` in [src/__init__](/src/__init__.py) to match the wanted new version. | ||
```python | ||
# Encrypt sensitive data before processing | ||
encrypted_data = medguard.encrypt_data(patient_record) | ||
|
||
# Decrypt after processing | ||
decrypted_data = medguard.decrypt_data(encrypted_data) | ||
``` | ||
poetry build | ||
poetry publish | ||
|
||
## Best Practices | ||
|
||
- **Data Minimization**: Only include necessary PHI when processing data with MedGuard to reduce the risk of exposure. | ||
- **Periodic Audits**: Regularly review audit logs and compliance reports to ensure continuous adherence to HIPAA regulations. | ||
- **Automated Alerts**: Set up automated alerts for suspicious activity or policy violations using MedGuard's built-in monitoring tools. | ||
|
||
## Customization | ||
|
||
MedGuard offers a flexible configuration system, allowing your organization to tailor compliance rules to fit specific regulatory environments. | ||
|
||
```python | ||
# Customize compliance policies | ||
medguard.set_policy("data_retention_period", "30_days") | ||
medguard.set_policy("encryption_algorithm", "AES-256") | ||
``` | ||
|
||
### CI/CD 🤖 | ||
## Scalability and Performance | ||
|
||
MedGuard is built with enterprise scalability in mind, supporting multi-node clusters, cloud-native environments, and hybrid deployments. | ||
|
||
- **Cloud Support**: Full support for AWS, Azure, and Google Cloud. | ||
- **Horizontal Scaling**: Efficiently scales with Kubernetes, Docker, or other orchestration platforms. | ||
- **Performance Optimized**: Designed for minimal latency in high-volume environments with large-scale LLM agents. | ||
|
||
## Compliance Standards | ||
|
||
MedGuard complies with the following standards and regulations: | ||
|
||
- **HIPAA**: Health Insurance Portability and Accountability Act | ||
- **HITRUST**: Health Information Trust Alliance | ||
- **GDPR**: General Data Protection Regulation (Optional) | ||
|
||
## Contributions | ||
|
||
We use [GitHub actions](https://github.com/features/actions) to automatically run tests and check code quality when a new PR is done on `main`. | ||
MedGuard is open to contributions from the community. Please submit pull requests or file issues to help us improve and expand the library. | ||
|
||
On any pull request, we will check the code quality and tests. | ||
1. Fork the repository. | ||
2. Create a new branch. | ||
3. Submit a pull request with a detailed description of changes. | ||
|
||
When a new release is created, we will try to push the new code to PyPi. We use [`twine`](https://twine.readthedocs.io/en/stable/) to make our life easier. | ||
## License | ||
|
||
The **correct steps** to create a new realease are the following: | ||
- edit `__version__` in [src/__init__](/src/__init__.py) to match the wanted new version. | ||
- create a new [`tag`](https://git-scm.com/docs/git-tag) with the release name, e.g. `git tag v0.0.1 && git push origin v0.0.1` or from the GitHub UI. | ||
- create a new release from GitHub UI | ||
MedGuard is licensed under the [MIT License](LICENSE). | ||
|
||
The CI will run when you create the new release. | ||
## Support | ||
|
||
# Docs | ||
We use MK docs. This repo comes with the zeta docs. All the docs configurations are already here along with the readthedocs configs. | ||
For enterprise support, contact [[email protected]](mailto:[email protected]). | ||
|
||
For documentation, tutorials, and examples, visit our [official website](https://medguard.ai/docs). | ||
|
||
## Contact | ||
|
||
# License | ||
MIT | ||
For any inquiries or enterprise solutions, reach out to our team at [[email protected]](mailto:[email protected]). |