deepvaa-webapp / tools /json_utils.py
Hong Ong
Implement One shot ACMG classification
c7b1d79
raw
history blame contribute delete
911 Bytes
import json
def extract_json_from_response(content: str):
# Remove Markdown code block markers
if content.startswith("```json"):
content = content.replace("```json", "").strip()
if content.endswith("```"):
content = content[:-3].strip()
# Now it's safe to parse the cleaned JSON
return json.loads(content)
def extract_classification(response_content: str) -> str:
try:
if response_content.startswith("```json"):
response_content = response_content.replace("```json", "").strip()
if response_content.endswith("```"):
response_content = response_content[:-3].strip()
parsed = json.loads(response_content)
return parsed["final_consensus"]["classification"]
except Exception as e:
# Log the error or handle it as needed
print(f"Error parsing classification: {e}")
return "ParsingError"