o
    h]<                     @   s   d dl mZ d dlmZ d dlmZmZ d dlZd dlZd dl	m
Z
 e
dd edZed	Zed
ZedZejdeeeddZejed G dd dejZG dd dejZG dd deZG dd deZdS )    )Type)BaseTool)	BaseModelFieldN)load_dotenvz7/home/azureuser/microlearn/backend/prompt_opt_dspy/.env)dotenv_pathAZURE_API_KEYAZURE_API_HOSTAZURE_DEPLOYMENT_IDAZURE_API_VERSIONzazure/Csqr-gpt-4o-minig        )api_keyapi_baseapi_versiontemperature)lmc                   @   sV   e Zd ZU dZe Zeed< e Z	eed< e Z
eed< ejddZeed< dS )	ResearchSignatureu  
    You are a topic researcher for a user in a specific topic.
    Uncover cutting-edge developments about topic
    The user prefer the researched data to be in match with the company context. The company context is :
      Company Name : {Company_Name}
      Industry : {Industry}
      Company Size : {Company_Size}
      Business Model : {Business_Model}
      Top Use Cases : {Top_Use_Cases}
      Learning Focus : {Learning_Focus}
      Tech Stack : {Tech_stack}
      Compliance : {Compliance}
    
    Perform comprehensive research on the topic **{topic}**, keeping in mind the user's job title, skills, experience, and learning level
    the motive of the user to under go this research.
    Avoid going too deep into technical details — this content is intended for a non-technical or minimally technical audience seeking a well-rounded understanding of the topic.
    Identify and list relevant concepts, methods, tools, techniques, and subtopics that should be included in a structured user journey.
    Your research should cover essential fundamentals, applied tools, advanced topics (aligned with the {Level} level), 
    and current trends relevant to the user's job title **{Job_Title}** and skills **{Skills}** and motive **{motive}**.
  
    A list of researched user journey content items for the topic {topic} tailored to the {Level} level.
    Structure the result as:
    - **Topic Area**: Main area/category (e.g., Fundamentals, Applications)
      - **Subtopics/Concepts**: List of individual concepts or tools under each topic area.
    This is purely research-based content gathering for a non-technical or minimally technical user journey preparation.
       
    topiccompany_contextuser_contextzPStructured bullet list of topic areas and subtopics tailored to the user journey)descresearched_contentN)__name__
__module____qualname____doc__dspy
InputFieldr   str__annotations__r   r   OutputFieldr    r    r    /home/azureuser/microlearn/backend/user_journey_with_openai/agentic_workflow/src/user_journey_service/tools/custom_research_tool.pyr      s   
 r   c                       s$   e Zd Z fddZdd Z  ZS )ResearcherModulec                    s   t    tt}tjddddddddtjd	d
ddddddg}dd }tj|d}|j||d || _	t
d t
| d S )NzAI in Healthcarea  
                Company Name: MediCore Solutions
                Industry: Healthcare
                Company Size: 2000+ employees
                Business Model: B2B and B2C SaaS
                Top Use Cases: Predictive analytics, Patient monitoring
                Learning Focus: AI diagnostics and workflow automation
                Tech Stack: Python, PyTorch, AWS HealthLake
                Compliance: HIPAA, GDPR
                z
                Job Title: Healthcare Analyst
                Skills: Data Analysis, Clinical Research
                Level: Intermediate
                motive: Exploring AI applications to improve patient care
                a
  
                - **Topic Area**: Fundamentals  
                - **Subtopics/Concepts**:  
                    - Introduction to Artificial Intelligence in Healthcare  
                    - Overview of Machine Learning and its Role in Patient Care  
                    - Types of AI: Supervised, Unsupervised, and Reinforcement Learning  
                    - Ethical Considerations in AI Applications  
                    - Understanding Data Privacy: HIPAA and GDPR Compliance  

                - **Topic Area**: Applications  
                - **Subtopics/Concepts**:  
                    - AI in Predictive Analytics: Enhancing Patient Outcomes  
                    - AI in Patient Monitoring: Wearables and Remote Monitoring  
                    - Use of Natural Language Processing (NLP) in Clinical Documentation  
                    - Chatbots and Virtual Health Assistants for Patient Engagement  
                    - Remote Diagnosis and Telemedicine Solutions  

                - **Topic Area**: Tools and Techniques  
                - **Subtopics/Concepts**:  
                    - Overview of Data Analytics Tools: Python and PyTorch for healthcare  
                    - Using AWS HealthLake for Data Management in Healthcare  
                    - Data Visualization Tools for Presenting AI Insights  
                    - Techniques in Data Preprocessing and Feature Engineering  
                    - Implementing AI Models for Real-Time Patient Monitoring  

                - **Topic Area**: Advanced Topics  
                - **Subtopics/Concepts**:  
                    - Deep Learning Applications in Medical Imaging  
                    - AI-Driven Decision Support Systems for Healthcare Professionals  
                    - Integrating AI into Existing Clinical Workflows  
                    - Case Studies on AI Success Stories in Patient Care  
                    - Challenges and Limitations of AI in Healthcare Practice  

                - **Topic Area**: Current Trends  
                - **Subtopics/Concepts**:  
                    - Rise of Telehealth Solutions and AI Integration  
                    - Innovations in Wearable Health Technology and AI  
                    - The Role of AI in Addressing Pandemic Challenges  
                    - The Future of AI in Personalized Medicine  
                    - Collaborations Between Tech Companies and Healthcare Institutions  

                This structured user journey content is designed to provide a comprehensive overview of AI in Healthcare, particularly aligned with the interests and learning objectives of a Healthcare Analyst looking to explore how AI can improve patient care.

                )r   r   r   r   r   r   r   zBlockchain in FinTecha  
                Company Name: FinNext Global
                Industry: FinTech
                Company Size: 1000-1500 employees
                Business Model: B2B
                Top Use Cases: Cross-border payments, Fraud prevention
                Learning Focus: Blockchain adoption and market opportunities
                Tech Stack: Ethereum, Hyperledger, Azure Blockchain Service
                Compliance: KYC, AML
                z
                Job Title: Business Development Executive
                Skills: Partnerships, Client Engagement
                Level: Beginner
                motive: Understanding blockchain for business strategy alignment
                u  


                - **Topic Area**: Fundamentals  
                - **Subtopics/Concepts**:  
                    - Introduction to Blockchain: Understanding what blockchain technology is and its significance in the FinTech landscape.  
                    - Key Terms: Decentralization, ledgers, nodes, smart contracts, tokens, hash functions.  
                    - Differences between Blockchain Types: Public vs. Private vs. Consortium blockchains.  
                    - Basic Mechanisms: How transactions are processed and validated in a blockchain network.  
                    - Overview of Cryptography: Basic principles of how cryptography secures blockchain solutions.  

                - **Topic Area**: Applications in FinTech  
                - **Subtopics/Concepts**:  
                    - Cross-border Payments: How blockchain facilitates faster, cheaper, and transparent international money transfers.  
                    - Fraud Prevention: Use of blockchain to enhance security and traceability of transactions.  
                    - Digital Identity Management: Evaluating blockchain's role in KYC and AML compliance processes for identity verification.  
                    - Smart Contracts: Understanding automated contract execution and its applications in financial services. 

                - **Topic Area**: Tools & Platforms  
                - **Subtopics/Concepts**:  
                    - Overview of Ethereum and Hyperledger: Key differences, use cases, and their relevance in FinTech.  
                    - Azure Blockchain Service: Brief introduction to Microsoft’s blockchain service and its business applications.  
                    - Wallet Solutions: Insight into digital wallets and their importance for businesses.  
                    - Integration with Existing Systems: Exploring middleware and API solutions to connect blockchain with legacy systems.  

                - **Topic Area**: Market Opportunities  
                - **Subtopics/Concepts**:  
                    - Trends in Blockchain Adoption: Current and future trends driving blockchain in FinTech, including regulatory factors.  
                    - Competitive Landscape: Overview of companies and startups utilizing blockchain for competitive advantage.  
                    - Customer Engagement: How blockchain can improve client engagement through transparency and trust.  

                - **Topic Area**: Business Strategy Alignment  
                - **Subtopics/Concepts**:  
                    - Strategic Partnerships: Identifying potential partnerships in the blockchain ecosystem for business growth.  
                    - Business Models leveraging Blockchain: Understanding various B2B models, including payment solutions, lending, and insurance.  
                    - Measuring ROI: Exploring metrics and frameworks to assess the financial impact of blockchain initiatives.  

                - **Topic Area**: Future Developments  
                - **Subtopics/Concepts**:  
                    - Emerging Trends: Overview of upcoming blockchain technology trends such as NFTs, CBDCs (Central Bank Digital Currencies), and DeFi (Decentralized Finance).  
                    - Regulatory Landscape: Understanding evolving compliance standards and regulations impacting blockchain implementations.  
                    - Education and Skill Development: Resources and communities to explore for continuous learning in blockchain and FinTech.

                This structured user journey provides the necessary foundation and insight for a Business Development Executive at FinNext Global to understand blockchain's application in developing business strategies and enhancing client engagement in the FinTech sector.

                c                    s   t t fdddD S )Nc                 3   s*    | ]}|   d   j  v V  qdS )r   N)lowersplitr   ).0sectionpredr    r!   	<genexpr>   s
    
zEResearcherModule.__init__.<locals>.research_metric.<locals>.<genexpr>)fundamentalsapplicationstoolstrends)intall)goldr(   tracer    r'   r!   research_metric   s   
z2ResearcherModule.__init__.<locals>.research_metric)metric)trainsetz=== Optimized ===)super__init__r   Predictr   Examplewith_inputsBootstrapFewShotcompileresearch_predictorprint)self	predictorr4   r2   	optimizer	__class__r    r!   r6   @   s2   



>

@  zResearcherModule.__init__c                 C   s   | j |||dS )N)r   r   r   )r<   )r>   r   r   r   r    r    r!   forward   s
   zResearcherModule.forward)r   r   r   r6   rC   __classcell__r    r    rA   r!   r"   ?   s     r"   c                   @   s  e Zd ZU dZedddZeed< edddZeed< edddZ	eed	< edd
dZ
eed< edddZeed< edddZeed< edddZeed< edddZeed< edddZeed< edddZeed< edddZeed< edddZeed< edddZeed< dS )ResearchToolInputz&Input schema for ResearchAnalysisTool..zThe topic to research)descriptionr   zName of the companyCompany_NamezIndustry of the companyIndustryzSize of the companyCompany_SizezCompany's business modelBusiness_Modelz$Top use cases the company focuses onTop_Use_CaseszLearning focus for the userLearning_FocuszCompany's tech stack
Tech_stackz Relevant compliance requirements
CompliancezJob title of the user	Job_TitlezSkills of the userSkillsz1Learning level (Beginner, Intermediate, Advanced)LevelzThe user's motive for researchmotiveN)r   r   r   r   r   r   r   r   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   r    r    r    r!   rE      s   
 rE   c                   @   sx   e Zd ZU dZeed< dZeed< eZe	e
 ed< dededed	ed
edededededededededefddZdS )ResearchAnalysisToolzResearch Analysis ToolnamezPerforms comprehensive research on a given topic while keeping in mind company context and user profile (job title, skills, level, and motive). Produces structured user journey content with topic areas and subtopics.rF   args_schemar   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   returnc                 C   sn   d| d| d| d| d| d| d| d|	 d	}d
|
 d| d| d| d		}t  }||||}|jS )Nz
        Company Name: z
        Industry: z
        Company Size: z
        Business Model: z
        Top Use Cases: z
        Learning Focus: z
        Tech Stack: z
        Compliance: z	
        z
        Job Title: z
        Skills: z
        Level: z
        Motive: )r"   rC   r   )r>   r   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   r   r   
researcherresultr    r    r!   _run   s:   zResearchAnalysisTool._runN)r   r   r   rT   r   r   rF   rE   rU   r   r   rY   r    r    r    r!   rS      sD   
 
	
rS   )typingr   crewai.toolsr   pydanticr   r   r   osdotenvr   getenvazure_api_keyazure_api_hostazure_deployment_idazure_api_versionLMr   	configure	Signaturer   Moduler"   rE   rS   r    r    r    r!   <module>   s0    




% %