o
    ]<h                     @   sN   d dl mZmZmZmZ d dlmZ d dlmZ d dl	m
Z
 G dd dZdS )    )DictListAnyOptional)RoleplayScenario)GroqService)JSONHandlerc                   @   s   e Zd Zdd Zdededeeef dededee d	ee	 fd
dZ
ded	ee	 fddZd	eeeef  fddZded	ee fddZdS )ScenarioGeneratorc                 C   s   t  | _t | _d S N)r   groq_servicer   json_handlerself r   \/var/www/eduai.edurigo.com/doc_train/edurigo_ai/roleplay/prod/services/scenario_generator.py__init__   s   zScenarioGenerator.__init__category	objectivedetailsai_rolelearner_roleskills_to_assessreturnc           
         s   t |dkr|dd }||||||d}| j|  sdS g d}t fdd|D s7td|  dS tj|||||| d  d	  d
  d d
}	| j|		 rX|	S td dS )zCreate a new roleplay scenario   N)r   r   r   r   r   r   )scenario_setupai_characterconversation_startersuccess_criteriac                 3   s    | ]}| v V  qd S r
   r   ).0keyscenario_datar   r   	<genexpr>%   s    z4ScenarioGenerator.create_scenario.<locals>.<genexpr>z*Generated scenario missing required keys: r   r   r   r   )
r   r   r   r   r   r   r   r   r   r   zFailed to save scenario)
lenr   generate_scenarioallprintr   
create_newr   save_scenarioto_dict)
r   r   r   r   r   r   r   admin_inputrequired_keysscenarior   r    r   create_scenario   s@   
z!ScenarioGenerator.create_scenarioscenario_idc                 C   s   | j |}|rt|S dS )zLoad an existing scenarioN)r   load_scenarior   	from_dict)r   r.   r!   r   r   r   r/   >   s   
zScenarioGenerator.load_scenarioc                 C   s
   | j  S )zList all available scenarios)r   list_scenariosr   r   r   r   list_available_scenariosE   s   
z*ScenarioGenerator.list_available_scenariosc                 C   s4   g dg dg dg dg dd}| |g dS )z'Get default skills for a given category)zPolicy AdherenceEmpathyzCommunication ClarityzConflict ResolutionProblem Solving)zNeeds AssessmentzProduct Knowledge
PersuasionzObjection HandlingzRelationship Building)zDecision MakingzTeam Communication
Motivation
DelegationzConflict Management)PreparationzActive ListeningzCreative Problem Solving
CompromisezRelationship Management)zProblem DiagnosiszTechnical CommunicationPatienceDocumentationz	Follow-up)zCustomer ServiceSales
LeadershipNegotiationzTechnical Support)Communicationr4   ProfessionalismAdaptabilityzResults Orientation)get)r   r   skill_mappingsr   r   r   get_default_skills_for_categoryI   s   &z1ScenarioGenerator.get_default_skills_for_categoryN)__name__
__module____qualname__r   strr   r   r   r   r   r-   r/   r2   rD   r   r   r   r   r	      s    
3r	   N)typingr   r   r   r   models.scenarior   services.groq_servicer   utils.json_handlerr   r	   r   r   r   r   <module>   s
    