File size: 4,368 Bytes
20d720d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
"""
Agent Tools module for Personal Coach CrewAI Application
Contains specialized tools for each agent's functionality
"""
from typing import TYPE_CHECKING, Dict, Any
# Version info
__version__ = "1.0.0"
# Lazy imports
if TYPE_CHECKING:
from .voice_tools import VoiceTools, MultilingualSTT, MultilingualTTS
from .llm_tools import LLMTools, MistralModel, PromptGenerator
from .knowledge_tools import KnowledgeTools, RAGPipeline, ContextBuilder
from .validation_tools import ValidationTools, ValidationResult
# Public API
__all__ = [
# Voice tools
"VoiceTools",
"MultilingualSTT",
"MultilingualTTS",
# LLM tools
"LLMTools",
"MistralModel",
"PromptGenerator",
# Knowledge tools
"KnowledgeTools",
"RAGPipeline",
"ContextBuilder",
# Validation tools
"ValidationTools",
"ValidationResult",
# Utility functions
"create_tool_suite",
"get_tool_by_name",
# Constants
"SUPPORTED_LANGUAGES",
"TOOL_CATEGORIES"
]
# Constants
SUPPORTED_LANGUAGES = [
"en", "es", "fr", "de", "it", "pt", "ru", "zh",
"ja", "ko", "hi", "ar", "bn", "pa", "te", "mr",
"ta", "ur", "gu", "kn", "ml", "or"
]
TOOL_CATEGORIES = {
"VOICE": ["speech_to_text", "text_to_speech", "language_detection"],
"LLM": ["generate_response", "generate_questions", "summarize", "paraphrase"],
"KNOWLEDGE": ["search_knowledge", "extract_wisdom", "find_practices"],
"VALIDATION": ["validate_response", "check_safety", "analyze_tone"]
}
# Factory functions
def create_tool_suite(config) -> Dict[str, Any]:
"""
Create a complete suite of tools for all agents
Args:
config: Configuration object
Returns:
dict: Dictionary of initialized tools
"""
from .voice_tools import VoiceTools
from .llm_tools import LLMTools
from .knowledge_tools import KnowledgeTools
from .validation_tools import ValidationTools
tools = {
"voice": VoiceTools(config),
"llm": LLMTools(config),
"knowledge": KnowledgeTools(config),
"validation": ValidationTools(config)
}
return tools
def get_tool_by_name(tool_name: str, config):
"""
Get a specific tool by name
Args:
tool_name: Name of the tool
config: Configuration object
Returns:
Tool instance or None
"""
tool_mapping = {
"voice": lambda c: __import__("agents.tools.voice_tools", fromlist=["VoiceTools"]).VoiceTools(c),
"llm": lambda c: __import__("agents.tools.llm_tools", fromlist=["LLMTools"]).LLMTools(c),
"knowledge": lambda c: __import__("agents.tools.knowledge_tools", fromlist=["KnowledgeTools"]).KnowledgeTools(c),
"validation": lambda c: __import__("agents.tools.validation_tools", fromlist=["ValidationTools"]).ValidationTools(c)
}
tool_factory = tool_mapping.get(tool_name.lower())
if tool_factory:
return tool_factory(config)
return None
# Tool registry for CrewAI
def register_tools_with_crew():
"""
Register all tools with CrewAI framework
Returns a list of tool configurations for CrewAI
"""
tool_configs = [
{
"name": "speech_to_text",
"description": "Convert speech in any language to text",
"category": "VOICE"
},
{
"name": "text_to_speech",
"description": "Convert text to natural speech in multiple languages",
"category": "VOICE"
},
{
"name": "search_knowledge",
"description": "Search through spiritual and self-help texts",
"category": "KNOWLEDGE"
},
{
"name": "generate_response",
"description": "Generate empathetic and helpful responses",
"category": "LLM"
},
{
"name": "validate_response",
"description": "Ensure response safety and appropriateness",
"category": "VALIDATION"
}
]
return tool_configs
# Initialization check
import os
if os.getenv("DEBUG_MODE", "false").lower() == "true":
print(f"Agent Tools module v{__version__} initialized")
print(f"Supported languages: {len(SUPPORTED_LANGUAGES)}")
print(f"Tool categories: {list(TOOL_CATEGORIES.keys())}") |