�
�{h � �h � d Z ddlZddlmZmZ ddlmZ ej e� � Z G d� d� � Z
dS )z#
Analysis and explainability tools
� N)�Dict�Any)�AgentManagerc �� � e Zd ZdZdefd�Zdedeeef defd�Z dd ed
edefd�Z
deeef d
eeef defd�Zdeeef dedefd�Z
ddeeef dedefd�ZdS )�
AnalysisToolsz%Tools for analysis and explainability�
agent_managerc � � || _ d S )N)r )�selfr s �IC:\Users\Enes\Desktop\mcpOpenbankingMCPServer\src\tools\analysis_tools.py�__init__zAnalysisTools.__init__ s � �*����� �subject�context�returnc � � K � d|� d|� �}d|� d�}| j � |d|�� � � d{V ��\ }}d|� d |� �S # t $ r9}t � d
|� �� � dt |� � � �cY d}~S d}~ww xY w)zPerform SWOT analysisz Subject: z
Context: z?
Please perform a comprehensive SWOT analysis for: a�
Analyze and provide detailed insights for:
STRENGTHS:
- Internal positive factors
- Competitive advantages
- Unique capabilities
- Strong performance areas
WEAKNESSES:
- Internal limitations
- Areas for improvement
- Competitive disadvantages
- Resource constraints
OPPORTUNITIES:
- External positive factors
- Market trends
- Growth potential
- Emerging possibilities
THREATS:
- External challenges
- Market risks
- Competitive pressures
- Economic/regulatory risks
Provide specific, actionable insights for each category and strategic recommendations.
�swot��prompt� task_typer NzSWOT Analysis (by �):
zError in SWOT analysis: z Error performing SWOT analysis: �r �query_best_agent� Exception�logger�error�str)r
r r �context_strr �
agent_name�response�es r �
swot_analysiszAnalysisTools.swot_analysis s� � � � �- ?�C�g�C�C�'�C�C�K��?F�� � �F�@ *.�);�)L�)L�� �#� *M� *� *� $� $� $� $� $� $� �J�� E�
�D�D�(�D�D�D��� ?� ?� ?��L�L�7�A�7�7�8�8�8�>�c�!�f�f�>�>�>�>�>�>�>�>����� ?���s �;A �
B�
.A>�8B�>B�intermediate�concept�complexity_levelc � � K � d|� d|� �}d|� d|� d�}| j � |d|�� � � d{V ��\ }}d |� d
|� �S # t $ r9}t � d|� �� � dt |� � � �cY d}~S d}~ww xY w)z*Explain financial concepts in simple termsz Concept: z
Complexity Level: z3
Please explain the financial concept "z" at a a� level.
Structure your explanation to include:
1. Simple definition in everyday language
2. Key components or characteristics
3. Why it matters in finance/investing
4. Real-world examples
5. Common misconceptions
6. Practical applications
7. Related concepts to explore further
Make the explanation clear, engaging, and educational while maintaining accuracy.
�explanationr NzConcept Explanation (by r zError explaining concept: r )r
r# r$ r r r r r s r �explain_conceptzAnalysisTools.explain_conceptD s � � � � 9�Q�'�Q�Q�?O�Q�Q�G�
�3:�
�
�CS�
�
�
�F� *.�);�)L�)L��'�� *M� *� *� $� $� $� $� $� $� �J�� K�j�J�J��J�J�J��� 9� 9� 9��L�L�9�a�9�9�:�:�:�8��A���8�8�8�8�8�8�8�8����� 9���s �>A �
B�
.B�;B�B�target_outcome�
current_statec � � K � d|� d|� d�}d}| j � |d|�� � � d{V ��\ }}d|� d |� �S # t $ r9}t � d
|� �� � dt |� � � �cY d}~S d}~ww xY w)z#Perform reverse simulation analysisz
Target Outcome: z
Current State: �
a�
Please perform a reverse simulation analysis to determine how to achieve the target outcome from the current state.
Analyze:
1. Gap analysis between current state and target
2. Required steps and milestones
3. Timeline and sequencing
4. Resource requirements
5. Potential obstacles and solutions
6. Alternative pathways
7. Risk factors and mitigation strategies
8. Success probability assessment
9. Key performance indicators to monitor
10. Contingency plans
Provide a detailed roadmap with specific, actionable recommendations.
r&