File size: 3,772 Bytes
cf0f589
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""
Problem Solving Agent - Specialized MCP agent for problem-solving 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("problem-solving-agent")

# Define the system prompt for the problem solving agent
PROBLEM_SOLVING_SYSTEM_PROMPT = """
You are an expert problem-solving research assistant with deep knowledge of analytical 
frameworks, decision-making methodologies, and innovative solution development across 
multiple domains. Your expertise includes:

1. Systems thinking and complex problem analysis
2. Root cause identification and causal mapping
3. Creative ideation and solution generation
4. Decision analysis and optimization
5. Implementation planning and risk assessment
6. Interdisciplinary approaches to wicked problems

Your role is to help researchers refine their problem statements, enhance their solution 
hypotheses, and provide guidance on methodological approaches to problem-solving research. 
You excel at identifying underlying patterns in complex problems and suggesting novel 
approaches for investigation and resolution.

When evaluating research questions and hypotheses, consider:
- Problem framing and boundary definition
- Stakeholder perspectives and needs
- Feasibility, scalability, and sustainability of potential solutions
- Metrics for success and impact measurement
- Potential unintended consequences
- Implementation challenges and strategies

Provide detailed, practical analysis that demonstrates deep understanding of problem-solving 
methodologies while remaining actionable and solution-oriented.
"""

async def get_problem_solving_agent():
    """Initialize and return the problem solving agent."""
    client, agent = await get_pydantic_ai_agent(PROBLEM_SOLVING_SYSTEM_PROMPT)
    return client, agent

async def process_problem_solving_questions(research_questions, domain_context=None):
    """
    Process research questions using the problem solving 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_problem_solving_agent()
    try:
        result = await process_research_questions(agent, research_questions, domain_context)
        return result
    finally:
        await client.cleanup_servers()

async def enhance_problem_solving_hypotheses(hypotheses, research_goal):
    """
    Enhance hypotheses using the problem solving 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_problem_solving_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 = [
            "How can urban transportation systems be redesigned to reduce congestion?",
            "What strategies can effectively address food waste in the supply chain?",
            "How can organizations better prepare for and respond to cybersecurity threats?"
        ]
        
        result = await process_problem_solving_questions(research_questions)
        print(json.dumps(result, indent=2))
    
    asyncio.run(main())