Spaces:
Runtime error
Runtime error
""" | |
Health Research Agent - Specialized MCP agent for health-related research. | |
""" | |
import asyncio | |
import json | |
import logging | |
from common import get_pydantic_ai_agent, process_research_questions, enhance_hypotheses | |
# Configure logging | |
logging.basicConfig( | |
level=logging.INFO, | |
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" | |
) | |
logger = logging.getLogger("health-research-agent") | |
# Define the system prompt for the health research agent | |
HEALTH_RESEARCH_SYSTEM_PROMPT = """ | |
You are an expert health research assistant with deep knowledge of medical research methodologies, | |
public health frameworks, and clinical studies across multiple health domains. Your expertise includes: | |
1. Clinical trial design and methodology | |
2. Epidemiological research approaches | |
3. Health systems and policy analysis | |
4. Patient-centered outcomes research | |
5. Translational research and implementation science | |
6. Medical ethics and research integrity | |
Your role is to help researchers refine their health-related research questions, enhance their | |
hypotheses, and provide guidance on methodological approaches. You excel at identifying gaps | |
in existing health research and suggesting novel directions for investigation that could | |
improve health outcomes. | |
When evaluating research questions and hypotheses, consider: | |
- Clinical relevance and potential impact on patient care | |
- Methodological rigor and appropriateness for health research | |
- Ethical considerations and patient protection | |
- Feasibility of data collection in healthcare settings | |
- Alignment with current medical evidence and practice guidelines | |
- Potential for translation to clinical practice or public health interventions | |
Provide detailed, thoughtful analysis that demonstrates deep understanding of health research | |
principles while remaining accessible to researchers with varying levels of clinical expertise. | |
""" | |
async def get_health_research_agent(): | |
"""Initialize and return the health research agent.""" | |
client, agent = await get_pydantic_ai_agent(HEALTH_RESEARCH_SYSTEM_PROMPT) | |
return client, agent | |
async def process_health_research_questions(research_questions, domain_context=None): | |
""" | |
Process research questions using the health research agent. | |
Args: | |
research_questions (list): List of research questions to process. | |
domain_context (str, optional): Additional domain context to provide. | |
Returns: | |
dict: Enhanced research questions with explanations and context. | |
""" | |
client, agent = await get_health_research_agent() | |
try: | |
result = await process_research_questions(agent, research_questions, domain_context) | |
return result | |
finally: | |
await client.cleanup_servers() | |
async def enhance_health_hypotheses(hypotheses, research_goal): | |
""" | |
Enhance hypotheses using the health research agent. | |
Args: | |
hypotheses (list): List of hypotheses to enhance. | |
research_goal (str): The research goal. | |
Returns: | |
dict: Enhanced hypotheses with explanations and context. | |
""" | |
client, agent = await get_health_research_agent() | |
try: | |
result = await enhance_hypotheses(agent, hypotheses, research_goal) | |
return result | |
finally: | |
await client.cleanup_servers() | |
if __name__ == "__main__": | |
# Example usage | |
async def main(): | |
research_questions = [ | |
"What are the long-term effects of COVID-19 on cardiovascular health?", | |
"How does socioeconomic status influence access to preventive healthcare?", | |
"What role does gut microbiome play in mental health disorders?" | |
] | |
result = await process_health_research_questions(research_questions) | |
print(json.dumps(result, indent=2)) | |
asyncio.run(main()) | |