|
""" |
|
CrewAI Agent Definitions using modular tool containers |
|
""" |
|
|
|
from crewai import Agent |
|
from agents.tools import VoiceTools, LLMTools, KnowledgeTools, ValidationTools |
|
|
|
|
|
voice_tools = VoiceTools() |
|
llm_tools = LLMTools() |
|
knowledge_tools = KnowledgeTools() |
|
validation_tools = ValidationTools() |
|
|
|
def create_conversation_agent(llm) -> Agent: |
|
"""Agent 1: Conversation Handler with emotional intelligence""" |
|
return Agent( |
|
role="Empathetic Conversation Handler", |
|
goal="Understand user's emotional state and needs through compassionate dialogue", |
|
backstory="""You are a highly empathetic listener trained in counseling psychology |
|
and multicultural communication. You understand nuances in different languages and |
|
cultural contexts. Your strength lies in making people feel heard and understood.""", |
|
tools=[ |
|
voice_tools.detect_emotion, |
|
voice_tools.generate_reflective_questions |
|
], |
|
llm=llm, |
|
verbose=True, |
|
allow_delegation=False |
|
) |
|
|
|
def create_wisdom_agent(llm) -> Agent: |
|
"""Agent 2: Wisdom Keeper with knowledge from spiritual texts""" |
|
return Agent( |
|
role="Wisdom Keeper and Spiritual Guide", |
|
goal="Provide personalized guidance drawing from ancient wisdom and modern psychology", |
|
backstory="""You are a learned guide who has deeply studied various spiritual texts, |
|
philosophical works, and modern psychology. You excel at finding relevant wisdom |
|
that speaks to each person's unique situation and presenting it in an accessible way.""", |
|
tools=[ |
|
knowledge_tools.search_knowledge, |
|
knowledge_tools.extract_wisdom, |
|
knowledge_tools.suggest_practices, |
|
llm_tools.mistral_chat, |
|
llm_tools.generate_advice |
|
], |
|
llm=llm, |
|
verbose=True, |
|
allow_delegation=False |
|
) |
|
|
|
def create_validation_agent(llm) -> Agent: |
|
"""Agent 3: Guardian ensuring safe and appropriate responses""" |
|
return Agent( |
|
role="Response Guardian and Quality Validator", |
|
goal="Ensure all responses are safe, appropriate, and truly helpful", |
|
backstory="""You are a careful guardian who ensures all guidance is ethical, |
|
safe, and beneficial. You have expertise in mental health awareness and |
|
understand the importance of appropriate boundaries in coaching.""", |
|
tools=[ |
|
validation_tools.check_safety if hasattr(validation_tools, 'check_safety') else validation_tools.validate_response, |
|
validation_tools.validate_tone if hasattr(validation_tools, 'validate_tone') else None, |
|
validation_tools.refine_response if hasattr(validation_tools, 'refine_response') else None |
|
], |
|
llm=llm, |
|
verbose=True, |
|
allow_delegation=False |
|
) |
|
|
|
def create_interaction_agent(llm) -> Agent: |
|
"""Agent 4: Interaction Manager for natural dialogue""" |
|
return Agent( |
|
role="Conversation Flow Manager", |
|
goal="Create natural, engaging dialogue that helps users on their journey", |
|
backstory="""You are a skilled facilitator who ensures conversations flow |
|
naturally and meaningfully. You understand the importance of pacing, follow-up |
|
questions, and creating a safe space for exploration.""", |
|
tools=[ |
|
llm_tools.summarize_conversation |
|
], |
|
llm=llm, |
|
verbose=True, |
|
allow_delegation=False |
|
) |