o
    hԦ                     @   s   d dl Z d dlZd dlmZmZ d dlmZmZmZmZ d dl	Z	d dl
Z
d dlZd dlZd dlmZ d dlmZ G dd deZeG dd	 d	ZG d
d dZdS )    N)datetime	timedelta)DictListAnyOptional)	dataclass)Enumc                   @   s$   e Zd ZdZdZdZdZdZdZdS )ConversationStageinitializationrapport_buildingchallenge_introductionskill_developmentadvanced_scenariosclosureN)	__name__
__module____qualname__INITIALIZATIONRAPPORT_BUILDINGCHALLENGE_INTRODUCTIONSKILL_DEVELOPMENTADVANCED_SCENARIOSCLOSURE r   r   X/var/www/eduai.edurigo.com/doc_train/edurigo_ai/my_career/testing/roleplay_processing.pyr
      s    r
   c                   @   sn   e Zd ZU eed< eed< eed< eed< eed< eed< eed< eed< eed	< e	e ed
< e	e ed< dS )SessionContext
session_id	client_id	user_typeroleplay_categoryconversation_stage
turn_count
created_atlast_activityuser_performance_scorekey_topics_coveredlearning_objectives_metN)
r   r   r   int__annotations__strr
   r   floatr   r   r   r   r   r      s   
 r   c                   @   s  e Zd Zdd Z	dWdededee deeef deeef d	e	eeef  d
ede	e dee deeef fddZ
dededee de	e deeef deeef fddZdefddZdede	e dee defddZdede	e dee deeef fddZdeeef fddZdeeef deeef fddZ	dWdeeef deeef dedeeef d eded	e	eeef  defd!d"Zdeeef defd#d$Zdeeef deeef d edefd%d&Zd ed'edefd(d)Zdeeef defd*d+Zdeeef defd,d-Zd.edeeef d edee def
d/d0Zd'ed edefd1d2Zd3edeeef defd4d5Zdede	e d6edee de	e f
d7d8Zded ed3edee fd9d:Zdedeeef fd;d<Z dXd>efd?d@Z!d	e	eeef  defdAdBZ"dCededeeef deeef d edeeef ded	e	eeef  de	e fdDdEZ#dCededeeef deeef d edeeef ded	e	eeef  defdFdGZ$d	e	eeef  defdHdIZ%dCed'edefdJdKZ&d	e	eeef  d edefdLdMZ'd ed'edefdNdOZ(ded'edefdPdQZ)dRededeeef d	e	eeef  de	e f
dSdTZ*ded'ed ede	e fdUdVZ+dS )YRoleplayProcessorc                 C   s    d| _ t | _i | _i | _d S )Nz
gemma3:12b)
model_nameollamaAsyncClientclientsession_storageconversation_memory)selfr   r   r   __init__#   s   

zRoleplayProcessor.__init__Nr   r   r   org_knowledge_baseroleplay_dataskills_for_roleplayis_suggested_responsesprevious_memoryqueryreturnc
              
      s  zs|  |||||\}
}| |}| |}| |||	}| |
||	}| |||||||}| ||||	I dH }g }|dkrP| ||||||||I dH }|dd }| |
|||	}| 	|
|||	 |||
|j
|t  dW S  ty } z	tdt| d}~ww )zS
        Enhanced roleplay processing with conditional suggested responses
        N      )responseupdated_memoryr   r!   suggested_responses	timestampzError processing roleplay: )_manage_session_extract_organization_info_extract_roleplay_info_determine_conversation_stage_build_memory_context_build_enhanced_context_prompt_generate_contextual_response_generate_suggested_responses_update_conversation_memory_update_session_contextvaluer   now	isoformat	Exceptionr*   )r3   r   r   r   r5   r6   r7   r8   r9   r:   final_session_idsession_contextorg_inforoleplay_infor!   memory_contextcontext_promptr>   r@   r?   er   r   r   process_roleplay)   sX   






	z"RoleplayProcessor.process_roleplayc                 C   sB  |s^|du r0|   }t||||ddtjdt t dg g d}|| j|< g | j|< ||fS || jvrWt||||ddtjdt t dg g d}|| j|< g | j|< || j| fS |duru|| jv ru| j| }|j	|kru||fS |   }t||||ddtj
t|t t dg g d}|| j|< g | j|< ||fS )zJ
        Enhanced session management with proper context tracking
        Ncategorygeneralr           )r   r   r   r    r!   r"   r#   r$   r%   r&   r'   )_generate_session_idr   getr
   r   r   rM   r1   r2   r   r   len)r3   r   r   r   r9   r6   new_session_idrQ   r   r   r   rB   v   sr   











z!RoleplayProcessor._manage_sessionc                 C   sT   t t  }t tdd}| | }t| }t	|
 dd dd S )z,Generate cryptographically secure session IDi i?B N      i@B )r*   r   rM   rA   randomrandinthashlibmd5encoder(   	hexdigest)r3   rA   random_component
hash_inputhash_objectr   r   r   r[      s
   z&RoleplayProcessor._generate_session_idrQ   c                 C   sT   t |}|dkrtjS |dkrtjS |dkrtjS |dkr tjS |dkr'tjS tjS )z>
        Intelligent conversation stage determination
        r         r_      )r]   r
   r   r   r   r   r   r   )r3   rQ   r9   r:   r"   r   r   r   rE      s   	z/RoleplayProcessor._determine_conversation_stagec           	      C   s   g g g g |dd}|| j v r| j | }||d< |r>t|D ] \}}|d ||d dkr-dndt  d	}|d | q|S )
zP
        Build comprehensive memory context for conversation continuity
        natural)conversation_history
key_topicsuser_responsesai_responsescurrent_queryconversation_flowrn   r<   rj   r   ai_responseuser_response)turncontenttyperA   )r2   	enumerater   rM   rN   append)	r3   r   r9   r:   rT   stored_memoryir>   response_contextr   r   r   rF      s&   

	

z'RoleplayProcessor._build_memory_contextc              	   C   sL   z
|j |j|jdW S  ty%   |dd|dd|ddd Y S w )z4Extract organization information with error handling)organisation_nameorganisation_objectiveorganisation_informationr~   zUnknown Organizationr   zNot specifiedr   zNo information available)r~   r   r   AttributeErrorr\   )r3   r5   r   r   r   rC     s   



z,RoleplayProcessor._extract_organization_infoc                 C   s<   | dd | dd| dd| dd| d	d
dS )z,Extract roleplay information with validationrX   rY   	objectivezGeneral roleplay practiceadditional_info difficulty_levelmediumscenario_typestandard)rX   r   r   r   r   r\   lower)r3   r6   r   r   r   rD     s   



z(RoleplayProcessor._extract_roleplay_inforR   rS   rT   r!   c                 C   sb  |  |}| |||}	| ||d }
| |}| |pg }dg d|j d|j  d|j	 d|d  d|  d	|d  d
|d  d|d  d|d   d
|d  d|d  d|d   d|d  d| d|	 d| d| d|
 d|
dd d| | d}|S ) z]
        Build sophisticated context prompt with memory integration and skills focus
        rX   r   z
    You are an advanced AI roleplay partner in a sophisticated business training environment.
    === SESSION CONTEXT ===
    Session ID: 
    Conversation Stage: 
    Turn Count: 
    Organization: r~   z
    Participant: z,
    === ORGANIZATION PROFILE ===
    Name: z
    Objective: r   z
    Details: r   z-
    === ROLEPLAY SCENARIO ===
    Category: r   z
    Context: r   
    Difficulty: r   z
    Scenario Type: r   z
    === SKILLS FOCUS ===
    z#
    === CHARACTER PROFILE ===
    z%
    === CONVERSATION MEMORY ===
    z'
    === CONVERSATION ANALYSIS ===
    z-
    === STAGE-SPECIFIC INSTRUCTIONS ===
    a#  
    === ADVANCED RESPONSE GUIDELINES ===
    1. MEMORY INTEGRATION: Reference previous conversations naturally and maintain consistency
    2. PROGRESSIVE LEARNING: Adapt difficulty and complexity based on conversation stage
    3. AUTHENTIC INTERACTION: Act as a realistic business professional with genuine motivations
    4. EDUCATIONAL VALUE: Provide meaningful challenges that develop specific skills
    5. EMOTIONAL INTELLIGENCE: Display appropriate emotions and interpersonal dynamics
    6. CONTEXTUAL AWARENESS: Maintain awareness of business context and organizational objectives
    7. CONVERSATIONAL FLOW: Ensure natural progression and avoid repetitive patterns
    8. SKILLS DEVELOPMENT: Focus on developing and testing the specified skills during interaction
    Current Query Context: rr   zNo specific query providedz
    Respond as the z- keeping all context and memory in mind:
    )_analyze_conversation_history!_build_advanced_character_profile _get_stage_specific_instructions_build_memory_summary_build_skills_contextjoinr   rL   titler"   r\   _get_roleplay_character)r3   rR   rS   r   rT   r!   rQ   r7   conversation_analysischaracter_profilestage_instructionsmemory_summaryskills_contextpromptr   r   r   rG   "  sf   


	



%&)z0RoleplayProcessor._build_enhanced_context_promptc                 C   s   | dg }|s
dS dt| d}t|dkr.dd |dd	 D }|d
d| d7 }t|dkr:|d7 }|S t|dkrF|d7 }|S |d7 }|S )z6Analyze conversation history for patterns and insightsrn   z:New conversation - establish rapport and scenario context.zConversation analysis (z exchanges):
   c                 S       g | ]}| d ddd qS )rw   r   N2   r\   .0itemr   r   r   
<listcomp>x       zCRoleplayProcessor._analyze_conversation_history.<locals>.<listcomp>NRecent topics: , 
rj   z=Early stage - focus on scenario establishment and engagement.rk   z;Development stage - introduce challenges and assess skills.z8Advanced stage - provide complex scenarios and feedback.r\   r]   r   )r3   rT   historyanalysisrecent_topicsr   r   r   r   m  s   z/RoleplayProcessor._analyze_conversation_historyc              
   C   s   |d }d|d  dd|d  dd|d  dd	d
}| |d|d  d| d}tjdtjdtjdtjdtjdi}| d| |d S )z5Build detailed character profile with stage awarenessrX   z@Experienced procurement manager at a growing company evaluating r~   z's solutions. You have budget authority but need to justify ROI. You're professional, detail-oriented, and have experience with similar implementations.zValued customer of z with a 2-year relationship. You have high expectations for service quality and personalized attention. You're generally professional but can become frustrated with poor service.z9Senior team member with 5+ years experience working with z. You have strong opinions about processes and value clear communication. You're results-oriented and expect professional leadership.zBusiness development manager representing a potential partner organization. You're skilled in negotiations, understand market dynamics, and have alternatives. You're professional but firm about your objectives.salescustomer_service
managementnegotiationz&Professional counterpart working with z in a z	 context.z:You're cautious and formal, gathering initial information.z7You're becoming more open and sharing relevant details.z7You're presenting real concerns and testing competence.z<You're engaging in detailed discussions and problem-solving.z>You're presenting complex challenges and evaluating solutions.z

Current demeanor: zProfessional and engaged.)r\   r
   r   r   r   r   r   )r3   rS   rR   r!   rX   base_profilesprofilestage_additionsr   r   r   r     s   
z3RoleplayProcessor._build_advanced_character_profilerX   c                 C   4   t jdt jdt jdt jdt jdt jdi}||dS )z5Get specific instructions based on conversation stagezaEstablish scenario context, introduce yourself professionally, and set the stage for interaction.zTBuild relationship, share relevant information, and establish trust and credibility.zQPresent realistic challenges, ask probing questions, and test initial competence.z\Engage in complex problem-solving, provide detailed scenarios, and assess skill application.zUPresent sophisticated challenges, test advanced skills, and provide nuanced feedback.zRSummarize outcomes, provide final assessment, and guide toward natural conclusion.z(Engage professionally and educationally.r
   r   r   r   r   r   r   r\   )r3   r!   rX   r   r   r   r   r     s   	z2RoleplayProcessor._get_stage_specific_instructionsc                 C   s   | dsdS |d }d}t|dkr%|d|d  ddd	d
  d7 }t|dkrAdd |dd	 D }|dd| d7 }| drP|d|d  d7 }|S )z"Build comprehensive memory summaryrn   z!No previous conversation history.zConversation Memory Summary:
rj   zLast exchange: rw   r   Nd   z...
r   c                 S   r   )rw   r   N   r   r   r   r   r   r     r   z;RoleplayProcessor._build_memory_summary.<locals>.<listcomp>r   r   r   r   rr   zCurrent query: r   )r3   rT   r   summarytopicsr   r   r   r     s   
$
z'RoleplayProcessor._build_memory_summaryc                 C   s    dddddd}| |d dS )	z&Get character description for roleplayzpotential enterprise clientzvalued customerzteam memberzbusiness partnerzexisting customer)r   r   r   r   crmrX   zbusiness professionalr   )r3   rS   character_mapr   r   r   r     s   z)RoleplayProcessor._get_roleplay_characterr   c           	   
      s   z2|  |d |}| jj| jdddd|dg|dddd	d
dI dH }|d d  }| ||W S  tyH } z	tdt| d}~ww )z$Generate contextually aware responserX   systemzYou are an expert business roleplay partner providing realistic, educational interactions that help professionals develop skills.rolerw   user?i  皙?皙?temperaturetop_p
max_tokensfrequency_penaltypresence_penaltymodelmessagesoptionsNmessagerw   zError generating response: )_get_optimal_temperaturer0   chatr-   strip_post_process_responserO   r*   )	r3   r   rS   r!   r:   r   r>   generated_responserV   r   r   r   rH     s6   z/RoleplayProcessor._generate_contextual_responsec              
   C   s\   ddddd}t jdt jdt jdt jd	t jd
i}||d}||d}tdtd|| S )z3Get optimal temperature based on category and stageffffff?g333333?g?g      ?r   grZ   r   g?g333333?333333?g      ?)	r
   r   r   r   r   r   r\   maxmin)r3   rX   r!   
base_tempsstage_adjustments	base_temp
adjustmentr   r   r   r     s   	z*RoleplayProcessor._get_optimal_temperaturer>   c                 C   sv   t dd|}t dd|}t dd|}dd |dD }t|dkr+|d	d
 }d|}|ds9|d7 }|S )z!Enhanced response post-processingz<[^>]*>r   z\*{1,2}[^*]*\*{1,2}z_{1,2}[^_]*_{1,2}c                 S      g | ]
}|  r|  qS r   r   )r   sr   r   r   r   %      z<RoleplayProcessor._post_process_response.<locals>.<listcomp>.r=   Nr   z. )resubsplitr]   r   endswith)r3   r>   rS   	sentences	processedr   r   r   r     s   

z(RoleplayProcessor._post_process_responsenew_responsec                 C   sl   ||t   t|d d}|| jvrg | j|< | j| | |g| }d}t||kr4|d| }|S )z5Enhanced memory management with intelligent retentionr<   )rt   
user_queryrA   turn_number   N)r   rM   rN   r]   r2   rz   )r3   r   r9   r   r:   memory_entryr?   max_memory_itemsr   r   r   rJ   /  s   





z-RoleplayProcessor._update_conversation_memoryc                 C   s:   || j v r| j | }t |_| jd7  _||_dS dS )z.Update session context with latest interactionr<   N)r1   r   rM   r$   r"   r!   )r3   r   r!   r>   r:   contextr   r   r   rK   P  s   



z)RoleplayProcessor._update_session_contextc              
   C   sf   || j vr	ddiS | j | }| j|g }||j|j|jj|jt	 |j
  d t||j|jd	S )z#Get comprehensive session analyticserrorzSession not found<   )	r   r   r    r!   r"   duration_minutesmemory_entriesperformance_scoretopics_covered)r1   r2   r\   r   r    r!   rL   r"   r   rM   r#   total_secondsr]   r%   r&   )r3   r   r   memoryr   r   r   get_session_analytics^  s   

z'RoleplayProcessor.get_session_analytics   hours_thresholdc                 C   sj   t  t|d }g }| j D ]\}}|j|k r|| q|D ]}| j|= || jv r0| j|= q!t|S )z&Clean up sessions older than threshold)hours)	r   rM   r   r1   itemsr$   rz   r2   r]   )r3   r   cutoff_timesessions_to_remover   r   r   r   r   cleanup_old_sessionsr  s   


z&RoleplayProcessor.cleanup_old_sessionsc                 C   sP   |sdS d}|D ]}| dd}| dd}|d| d| d	7 }q|d
7 }|S )z'Build skills context for roleplay focusz6No specific skills targeted for this roleplay session.zTarget Skills for Development:
skill_idUnknown
skill_namezUnknown Skill- z (ID: z)
zT
Focus on creating scenarios and challenges that help develop these specific skills.r   )r3   r7   skills_textskillr   r  r   r   r   r     s   z'RoleplayProcessor._build_skills_contextrt   c	                    s0  z{|  ||||||||}	d|  d|d   d|d  d|j  d|j d| d	|d
  d|d   d|d  d| | d|	 d| d| d}
| jj| jdddd|
dgdddddddI dH }|d  d!  }| 	||||}|W S  t
y } z| ||d |W  Y d}~S d}~ww )"zh
        Generate intelligent suggested responses for the user based on AI response and context
        z
    You are an expert business training consultant generating intelligent response suggestions for roleplay participants.
    === CONTEXT ===
    User Type: z
    Roleplay Category: rX   r   r~   r   r   z0
    === AI ROLEPLAY PARTNER'S RESPONSE ===
    z-
    === SCENARIO DETAILS ===
    Objective: r   r   r   z
    Additional Context: r   z(
    === SKILLS BEING DEVELOPED ===
    z-
    === RESPONSE GENERATION CONTEXT ===
    zl
    === RESPONSE GENERATION INSTRUCTIONS ===
    Generate exactly 4 professional response options that the a    could use to reply to the AI partner.
    Each response should:
    1. Be contextually appropriate to the AI partner's message
    2. Advance the conversation constructively
    3. Demonstrate the target skills being developed
    4. Match the user type (a  ) and conversation stage
    5. Be 15-40 words long
    6. Sound natural and professional
    7. Show different approaches (e.g., direct, consultative, relationship-building)
    User Type Guidelines:
    - ADMIN: Focus on strategic, systematic, and analytical responses
    - MANAGER: Focus on leadership, team-oriented, and results-driven responses
    - LEARNER: Focus on learning-oriented, question-asking, and skill-building responses
    Response Types to Include:
    1. Direct/Assertive Response
    2. Consultative/Question-based Response
    3. Relationship-building/Collaborative Response
    4. Analytical/Strategic Response
    Format your response as exactly 4 responses, one per line, without numbering or bullets:
    r   zYou are an expert business training consultant specializing in roleplay response development and professional communication coaching.r   r   r   r      r   r   r   r   Nr   rw   )"_build_response_generation_contextr   rL   r"   _format_skills_for_promptr0   r   r-   r   _parse_and_validate_responsesrO   _get_fallback_responses)r3   rt   r   rS   rR   r!   rT   rQ   r7   r}   suggestions_promptr>   r@   	responsesrV   r   r   r   rI     st   
	
)z/RoleplayProcessor._generate_suggested_responsesc	                 C   sZ   |  ||d }	| ||}
| ||d }d|	 d|
 d| d| ||d  d	}|S )z3Build comprehensive context for response generationrX   z
    AI RESPONSE ANALYSIS:
    z&
    SKILLS DEVELOPMENT GUIDANCE:
    z
    STAGE-SPECIFIC FOCUS:
    z#
    USER TYPE CONSIDERATIONS:
    z
    )'_analyze_ai_response_for_user_responses_get_skills_response_guidance_get_stage_response_focus#_get_user_type_response_preferences)r3   rt   r   rS   rR   r!   rT   rQ   r7   response_analysisskills_guidancestage_focusr   r   r   r   r    s   z4RoleplayProcessor._build_response_generation_contextc                 C   s   |sdS d dd |D S )z"Format skills for prompt inclusionzNo specific skills targeted.r   c                 S   s   g | ]}| d dqS )r  r  r   )r   r  r   r   r   r     s    z?RoleplayProcessor._format_skills_for_prompt.<locals>.<listcomp>)r   )r3   r7   r   r   r   r    s   z+RoleplayProcessor._format_skills_for_promptc                    s   d v }t  fdddD }t  fdddD }t  fdddD }d	}|d
| d7 }|d| d7 }|d| d7 }|d| d7 }|rO|d7 }|S |rW|d7 }|S |r_|d7 }|S |rg|d7 }|S |d7 }|S )z;Analyze AI response to identify user response opportunities?c                 3       | ]	}|   v V  qd S Nr   r   wordrt   r   r   	<genexpr>       zLRoleplayProcessor._analyze_ai_response_for_user_responses.<locals>.<genexpr>)concernworriedissueproblem	challengec                 3   r  r  r  r  r  r   r   r  !  r  )needrequirewantzlooking forc                 3   r  r  r  r  r  r   r   r  "  r  )buthowever	expensivecostbudgetzAI response type analysis:
z- Contains questions: r   z- Expresses concerns: z- Makes requests: z- Shows objections: zLRecommended approach: Address objections with value proposition and evidencezQRecommended approach: Acknowledge concerns and provide reassurance with specificszORecommended approach: Provide comprehensive answers and ask follow-up questionszFRecommended approach: Fulfill request and expand with additional valuezLRecommended approach: Build on the conversation and advance the relationship)any)r3   rt   rX   has_questionhas_concernhas_requesthas_objectionr   r   r  r   r    s.   
z9RoleplayProcessor._analyze_ai_response_for_user_responsesc                 C   s   |sdS d}|D ]>}| dd }d|v r|d7 }qd|v s#d|v r(|d	7 }qd
|v r1|d7 }qd|v r:|d7 }q|d| dd d7 }q|S )z4Get skills-specific guidance for response generationz3Focus on general professional communication skills.z#Skills-specific response guidance:
r  r   r   z\- Negotiation: Use collaborative language, explore win-win solutions, ask probing questions
consultativesellingzj- Consultative Selling: Focus on understanding needs, ask discovery questions, provide tailored solutions
communicationzX- Communication: Use clear, empathetic language, active listening, and appropriate tone

leadershipzG- Leadership: Show confidence, provide direction, inspire and motivate
r  r  z5: Apply skill-specific techniques and best practices
r   )r3   r7   r!   r  r  r  r   r   r   r  8  s   



z/RoleplayProcessor._get_skills_response_guidancec                 C   r   )z!Get stage-specific response focuszWFocus on professional introduction, establishing credibility, and setting positive tonezLFocus on building trust, finding common ground, and showing genuine interestzUFocus on understanding challenges, asking clarifying questions, and showing expertisezKFocus on demonstrating skills, providing solutions, and handling objectionszMFocus on complex problem-solving, strategic thinking, and advanced techniqueszPFocus on summarizing value, confirming next steps, and maintaining relationshipsz<Focus on professional and contextually appropriate responsesr   )r3   r!   rX   stage_focusesr   r   r   r  P  s   	z+RoleplayProcessor._get_stage_response_focusc                 C   s   dddd}| |dS )z+Get user type specific response preferenceszjFocus on strategic thinking, data-driven responses, system-level considerations, and organizational impactzaFocus on team implications, process optimization, results orientation, and stakeholder managementz_Focus on skill application, learning opportunities, asking good questions, and seeking feedbackadminmanagerlearnerz=Focus on professional development and effective communicationr   )r3   r   rX   preferencesr   r   r   r  ^  s
   z5RoleplayProcessor._get_user_type_response_preferencesr@   c           	      C   s   dd | dD }g }|D ]1}tdd|}|d}|r0|d  s0|d  |dd	  }|r?t|  d
kr?|| qt|dkrL|d	d S | ||d t	j
}|| d	d S )z&Parse and validate generated responsesc                 S   r   r   r   )r   rr   r   r   r   s  r   zCRoleplayProcessor._parse_and_validate_responses.<locals>.<listcomp>r   z^[\d\.\-\*\+\s]*r   z"'r   r<   Nrk   r=   rX   )r   r   r   r   isupperupperr]   rz   r
  r
   r   )	r3   r@   r   rS   r7   r  cleaned_responsesr>   fallback_responsesr   r   r   r	  i  s   


z/RoleplayProcessor._parse_and_validate_responsesc                 C   sD   dg didg didg did}| |i }| |g d}|S )z,Get fallback responses when generation failsr   )zXI'd like to understand the strategic implications of this solution for our organization.zUCan you provide data on how this has performed for similar companies in our industry?zHWhat are the long-term scalability considerations we should be aware of?z9How does this align with our current business objectives?)zJHow will this solution impact my team's current workflow and productivity?zOI need to understand the training requirements and timeline for implementation.zHWhat ongoing support can we expect from your team during the transition?zKWhat metrics should we track to measure the success of this implementation?)zOThat's interesting. Can you help me understand the key benefits in more detail?zKWhat questions should I be asking to better evaluate this type of solution?zGHow do other customers typically approach this decision-making process?zYWhat are some common challenges with this type of solution and how can they be addressed?r4  )zKThat's a valid point. Let me think about how this applies to our situation.zNI appreciate the information. Can you elaborate on the implementation process?zGThis sounds promising. What would be the best next step for us to take?zAHow does this compare to other solutions we might be considering?r   )r3   r   rX   r!   fallback_setsuser_fallbacksr  r   r   r   r
    s   		z)RoleplayProcessor._get_fallback_responsesr  )r   ),r   r   r   r4   r*   r   r(   r   r   r   rW   tupler   rB   r[   r
   rE   rF   rC   rD   rG   r   r   r   r   r   rH   r+   r   r   rJ   rK   r   r   r   rI   r  r  r  r  r  r  r	  r
  r   r   r   r   r,   "   s   

	


M


O


#"


	
K


 


)

!



	

a


	

#"

""r,   )r.   jsonr   r   typingr   r   r   r   ra   asyncior   rc   dataclassesr   enumr	   r
   r   r,   r   r   r   r   <module>   s    