o
    1h                     @   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                   @   sf   e Zd ZU dZe Zeed< 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 )
DefaultsEstimatorSignaturea+  
    User's default skill estimator   
    Analyse the user
    You have the ability to analyze a user's profile, context, and prior knowledge to estimate their default proficiency levels across various skill categories. 
    You are an expert skill analyser based on the context.
    Your task is to analyse the user profile and determine the approximate distribution (in percentages) across the following five skill categories:
    1. SQL (Out of 100%) 
    2. Data Visualization (Viz) (Out of 100%)
    3. Statistical Analysis (Stats)  (Out of 100%)
    4. Business Communication (Comm) (Out of 100%)
    5. Data Storytelling (Story) (Out of 100%)
    The percentages may overlap and should reflect the level of each skill for the user in their current role.

    User Context:
    - Role: {Job_Title}
    - Topic: {topic}
    - Experience with the topic - {topic}: {Experience}
    - Technical Preference: {Level}

    ## SQL - ....%
    ## Viz - ....%
    ## Stats - ....%
    ## Comm - ....%
    ## Story - ....%
    Should not include any other comments.

    	Job_Titletopic
ExperienceLevelzKPercentages across SQL, Viz, Stats, Comm, Story. Format only with headings.)descskill_distributionN)__name__
__module____qualname____doc__dspy
InputFieldr   str__annotations__r   r   r   OutputFieldr    r!   r!   /home/azureuser/microlearn/backend/user_journey_with_openai/agentic_workflow/src/user_journey_service/tools/custom_default_estimator_tool.pyr      s   
 r   c                       s$   e Zd Z fddZdd Z  ZS )DefaultsEstimatorModulec                    s   t    tt| _tt}tjddddddddd	d
tjddddddddd	d
g}dd }tj|d}|j	||d || _
td t| d S )NzData AnalystSQLz2 yearsIntermediatez
                        ## SQL - 70%
                        ## Viz - 60%
                        ## Stats - 50%
                        ## Comm - 55%
                        ## Story - 45%
                        )r   r   r   r   r   r   r   r   r   zBusiness AnalystzData Visualizationz3 yearsBeginnerz
                        ## SQL - 40%
                        ## Viz - 75%
                        ## Stats - 50%
                        ## Comm - 70%
                        ## Story - 65%
                        c                    s$   |j   tt fdddD S )Nc                 3   s    | ]}| v V  qd S Nr!   ).0skilloutr!   r"   	<genexpr>h   s    zMDefaultsEstimatorModule.__init__.<locals>.estimator_metric.<locals>.<genexpr>)sqlvizstatscommstory)r   lowerintall)goldpredtracer!   r*   r"   estimator_metrice   s   
z:DefaultsEstimatorModule.__init__.<locals>.estimator_metric)metric)trainsetz.=== Optimized Defaults Estimator Predictor ===)super__init__r   Predictr   restructure_predictorExamplewith_inputsBootstrapFewShotcompiledefaults_estimator_predictorprint)self	predictorr:   r8   	optimizer	__class__r!   r"   r<   B   s4   

z DefaultsEstimatorModule.__init__c                 C   s   | j ||||dS )N)r   r   r   r   )rC   )rE   r   r   r   r   r!   r!   r"   forwards   s   zDefaultsEstimatorModule.forward)r   r   r   r<   rJ   __classcell__r!   r!   rH   r"   r#   A   s    1r#   c                   @   sb   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< dS )DefaultsEstimatorInputz'Input schema for DefaultsEstimatorTool..zUser's job title)descriptionr   zTopic of interest or focus arear   z User's experience with the topicr   z1Learning level (Beginner, Intermediate, Advanced)r   N)r   r   r   r   r   r   r   r   r   r   r   r!   r!   r!   r"   rL   |   s   
 rL   c                
   @   sT   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f
ddZdS )DefaultsEstimatorToolzDefaults Estimator ToolnamezAnalyzes a user's profile and context to estimate their default proficiency levels across SQL, Data Visualization, Statistical Analysis, Business Communication, and Data Storytelling.rM   args_schemar   r   r   r   returnc                 C   s   t  }|||||}|jS r'   )r#   rJ   r   )rE   r   r   r   r   	estimatorresultr!   r!   r"   _run   s   zDefaultsEstimatorTool._runN)r   r   r   rO   r   r   rM   rL   rP   r   r   rT   r!   r!   r!   r"   rN      s   
 
"rN   )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#   rL   rN   r!   r!   r!   r"   <module>   s.    




%;	