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
Your Name
committed
Sep 24, 2024
1 parent
5140963
commit 6842ac8
Showing
8 changed files
with
179 additions
and
82 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 |
---|---|---|
|
@@ -17,6 +17,7 @@ downloads/ | |
eggs/ | ||
.eggs/ | ||
lib/ | ||
agent_workspace | ||
lib64/ | ||
parts/ | ||
.ruff_cache/ | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import json | ||
from medguard.secure_communications import SecureCommunicationAES | ||
|
||
if __name__ == "__main__": | ||
secure_comm = SecureCommunicationAES() | ||
|
||
# Encrypt a simple string with an authorized role | ||
user_role = "doctor" | ||
message = "This is sensitive health information." | ||
encrypted_message = secure_comm.encrypt(message, user_role) | ||
print(f"Encrypted payload: {encrypted_message}") | ||
|
||
# Decrypt the message with the same authorized role | ||
decrypted_message = secure_comm.decrypt( | ||
encrypted_message, user_role | ||
) | ||
print(f"Decrypted message: {decrypted_message}") | ||
|
||
# Attempt to encrypt with an unauthorized role | ||
try: | ||
unauthorized_role = "patient" | ||
encrypted_message = secure_comm.encrypt( | ||
message, unauthorized_role | ||
) | ||
except PermissionError as e: | ||
print(e) | ||
|
||
# Encrypt a JSON object | ||
sample_json = json.dumps( | ||
{ | ||
"name": "John Doe", | ||
"ssn": "123-45-6789", | ||
"diagnosis": "Hypertension", | ||
} | ||
) | ||
encrypted_json = secure_comm.encrypt(sample_json, user_role) | ||
print(f"Encrypted JSON payload: {encrypted_json}") | ||
|
||
# Decrypt the JSON object | ||
decrypted_json = secure_comm.decrypt(encrypted_json, user_role) | ||
print(f"Decrypted JSON: {decrypted_json}") |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from dotenv import load_dotenv | ||
from medinsight.agent import MedInsightPro | ||
|
||
from medguard.main import MedGuard | ||
|
||
load_dotenv() | ||
|
||
# Initialize the MedInsight Pro agent | ||
med_agent = MedInsightPro(max_articles=10) | ||
|
||
|
||
# MedGuard | ||
model = MedGuard(agent=med_agent, user="admin") | ||
|
||
print( | ||
model.run_agent( | ||
"Patient Information: Name - Kye Gomez, Social Security Number - 888-233-2322, Email - [email protected]. Diagnosis: Pennuenmoia. Treatment Query: What is the most effective treatment plan for a patient diagnosed with Pennuenmoia?" | ||
) | ||
) |
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 |
---|---|---|
|
@@ -18,17 +18,16 @@ def __init__(self, patterns: List[str] = None) -> None: | |
:param patterns: A list of regex patterns to identify sensitive data. | ||
""" | ||
if patterns is None: | ||
patterns = [ | ||
r"\b\d{3}-\d{2}-\d{4}\b", # SSN pattern | ||
r"\b[A-Z][a-z]*\s[A-Z][a-z]*\b", # Names pattern (simple) | ||
r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b", # Email pattern | ||
r"\b\d{3}-\d{3}-\d{4}\b", # Phone number pattern | ||
r"\b\d{1,2}/\d{1,2}/\d{2,4}\b", # Date pattern (MM/DD/YYYY or MM/DD/YY) | ||
r"\b\d{4}-\d{4}-\d{4}-\d{4}\b", # Credit card number pattern | ||
r"\b\d{3}-\d{4}-\d{4}-\d{4}\b", # Credit card number pattern with dashes | ||
r"\b\d{16}\b", # Credit card number pattern without dashes | ||
] | ||
patterns = [ | ||
r"\b\d{3}-\d{2}-\d{4}\b", # SSN pattern | ||
r"\b[A-Z][a-z]*\s[A-Z][a-z]*\b", # Names pattern (simple) | ||
r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b", # Email pattern | ||
r"\b\d{3}-\d{3}-\d{4}\b", # Phone number pattern | ||
r"\b\d{1,2}/\d{1,2}/\d{2,4}\b", # Date pattern (MM/DD/YYYY or MM/DD/YY) | ||
r"\b\d{4}-\d{4}-\d{4}-\d{4}\b", # Credit card number pattern | ||
r"\b\d{3}-\d{4}-\d{4}-\d{4}\b", # Credit card number pattern with dashes | ||
r"\b\d{16}\b", # Credit card number pattern without dashes | ||
] | ||
self.patterns = patterns | ||
|
||
def deidentify(self, text: str) -> str: | ||
|
@@ -45,16 +44,16 @@ def deidentify(self, text: str) -> str: | |
return text | ||
|
||
|
||
import time | ||
# import time | ||
|
||
# Example usage | ||
if __name__ == "__main__": | ||
deid = Deidentifier() | ||
sample_text = "John Doe's SSN is 123-45-6789 and his email is [email protected]." | ||
start_time = time.time() | ||
clean_text = deid.deidentify(sample_text) | ||
end_time = time.time() | ||
print( | ||
f"Deidentification completed in {end_time - start_time} seconds." | ||
) | ||
print(clean_text) | ||
# # Example usage | ||
# if __name__ == "__main__": | ||
# deid = Deidentifier() | ||
# sample_text = "John Doe's SSN is 123-45-6789 and his email is [email protected]." | ||
# start_time = time.time() | ||
# clean_text = deid.deidentify(sample_text) | ||
# end_time = time.time() | ||
# print( | ||
# f"Deidentification completed in {end_time - start_time} seconds." | ||
# ) | ||
# print(clean_text) |
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
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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "medguard" | ||
version = "0.0.1" | ||
version = "0.0.2" | ||
description = "medguard - Swarms" | ||
license = "MIT" | ||
authors = ["Kye Gomez <[email protected]>"] | ||
|