TatTwamAI / agents /tools /_init_old.py
Jayashree Sridhar
First Version
20d720d
raw
history blame
4.37 kB
"""
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())}")