Download interm.py from mgbam/Meddoc: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/spaces/mgbam/Meddoc/resolve/b6575736f03905496ccee64424ec8728e8afdf30/interm.py
- Command line
-
hf download hf://spaces/mgbam/Meddoc@b6575736f03905496ccee64424ec8728e8afdf30/interm.py
-
curl -L -o interm.py https://huggingface.co/spaces/mgbam/Meddoc/resolve/b6575736f03905496ccee64424ec8728e8afdf30/interm.py
1.74 kB
| from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel | |
| from fpdf import FPDF | |
| import tempfile | |
| # Initialize Clinical AI Agent | |
| clinical_agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel()) | |
| def generate_clinical_content(topic, audience): | |
| """Generates medical content based on topic and audience.""" | |
| prompt = f"Write a detailed medical article on: {topic}.\nTarget Audience: {audience}.\nInclude latest medical research insights." | |
| return clinical_agent.run(prompt) | |
| def generate_summary(content): | |
| """Summarizes a given clinical document or research paper.""" | |
| summary_prompt = f"Summarize the following medical research:\n{content}" | |
| return clinical_agent.run(summary_prompt) | |
| def generate_soap_note(symptoms, history): | |
| """Generates a SOAP Note for clinicians based on symptoms and patient history.""" | |
| soap_prompt = ( | |
| f"Create a structured SOAP Note for a patient with:\n" | |
| f"Symptoms: {symptoms}\n" | |
| f"History: {history}\n" | |
| f"Include Assessment & Plan." | |
| ) | |
| return clinical_agent.run(soap_prompt) | |
| def save_as_text(content, filename): | |
| """Saves AI-generated content as a TXT file.""" | |
| with tempfile.NamedTemporaryFile(delete=False, suffix=".txt") as tmp_file: | |
| tmp_file.write(content.encode()) | |
| return tmp_file.name, filename | |
| def save_as_pdf(content, filename): | |
| """Saves AI-generated content as a PDF file.""" | |
| with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_file: | |
| pdf = FPDF() | |
| pdf.add_page() | |
| pdf.set_font("Arial", size=12) | |
| pdf.multi_cell(0, 10, content) | |
| pdf.output(tmp_file.name) | |
| return tmp_file.name, filename | |