Upload 2 files
Browse files- interm.py +42 -0
- requirements.txt +9 -0
interm.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
2 |
+
from fpdf import FPDF
|
3 |
+
import tempfile
|
4 |
+
|
5 |
+
# Initialize Clinical AI Agent
|
6 |
+
clinical_agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
|
7 |
+
|
8 |
+
def generate_clinical_content(topic, audience):
|
9 |
+
"""Generates medical content based on topic and audience."""
|
10 |
+
prompt = f"Write a detailed medical article on: {topic}.\nTarget Audience: {audience}.\nInclude latest medical research insights."
|
11 |
+
return clinical_agent.run(prompt)
|
12 |
+
|
13 |
+
def generate_summary(content):
|
14 |
+
"""Summarizes a given clinical document or research paper."""
|
15 |
+
summary_prompt = f"Summarize the following medical research:\n{content}"
|
16 |
+
return clinical_agent.run(summary_prompt)
|
17 |
+
|
18 |
+
def generate_soap_note(symptoms, history):
|
19 |
+
"""Generates a SOAP Note for clinicians based on symptoms and patient history."""
|
20 |
+
soap_prompt = (
|
21 |
+
f"Create a structured SOAP Note for a patient with:\n"
|
22 |
+
f"Symptoms: {symptoms}\n"
|
23 |
+
f"History: {history}\n"
|
24 |
+
f"Include Assessment & Plan."
|
25 |
+
)
|
26 |
+
return clinical_agent.run(soap_prompt)
|
27 |
+
|
28 |
+
def save_as_text(content, filename):
|
29 |
+
"""Saves AI-generated content as a TXT file."""
|
30 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".txt") as tmp_file:
|
31 |
+
tmp_file.write(content.encode())
|
32 |
+
return tmp_file.name, filename
|
33 |
+
|
34 |
+
def save_as_pdf(content, filename):
|
35 |
+
"""Saves AI-generated content as a PDF file."""
|
36 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_file:
|
37 |
+
pdf = FPDF()
|
38 |
+
pdf.add_page()
|
39 |
+
pdf.set_font("Arial", size=12)
|
40 |
+
pdf.multi_cell(0, 10, content)
|
41 |
+
pdf.output(tmp_file.name)
|
42 |
+
return tmp_file.name, filename
|
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
fastapi
|
3 |
+
transformers
|
4 |
+
torch
|
5 |
+
requests
|
6 |
+
uvicorn
|
7 |
+
pandas
|
8 |
+
sqlalchemy
|
9 |
+
openai # For SQL query generation
|