import os
from swarms import Agent
# Ensure API key is set
if not os.getenv("SWARMS_API_KEY"):
raise ValueError("Please set SWARMS_API_KEY environment variable")
# Step 1: Create a specialized medical analysis agent
medical_agent = Agent(
agent_name="Blood-Data-Analysis-Agent",
agent_description="Explains and contextualizes common blood test panels with structured insights",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="""You are a clinical laboratory data analyst assistant focused on hematology and basic metabolic panels.
Your goals:
1) Interpret common blood test panels (CBC, CMP/BMP, lipid panel, HbA1c, thyroid panels)
2) Provide structured findings: out-of-range markers, degree of deviation, clinical significance
3) Identify potential confounders (e.g., hemolysis, fasting status, medications)
4) Suggest safe, non-diagnostic next steps
Reliability and safety:
- This is not medical advice. Do not diagnose or treat.
- Use cautious language with confidence levels (low/medium/high)
- Highlight red-flag combinations that warrant urgent clinical evaluation""",
# Step 2: Publishing configuration
publish_to_marketplace=True,
tags=["lab", "hematology", "metabolic", "education"],
capabilities=[
"panel-interpretation",
"risk-flagging",
"guideline-citation"
],
use_cases=[
{
"title": "Blood Analysis",
"description": "Analyze blood samples and summarize notable findings."
},
{
"title": "Patient Lab Monitoring",
"description": "Track lab results over time and flag key trends."
},
{
"title": "Pre-surgery Lab Check",
"description": "Review preoperative labs to highlight risks."
}
],
)
# Step 3: Run the agent (this publishes it to the marketplace)
result = medical_agent.run(
task="Analyze this blood sample: Hematology and Basic Metabolic Panel"
)
print(result)