diff --git a/commands/slash_commands.py b/commands/slash_commands.py index 529d440..995e7eb 100644 --- a/commands/slash_commands.py +++ b/commands/slash_commands.py @@ -18,7 +18,7 @@ from discord import app_commands from core.database import DatabaseManager from core.consent_manager import ConsentManager from core.memory_manager import MemoryManager, MemoryType -from services.quote_explanation import QuoteExplanationService, ExplanationDepth +from services.quotes.quote_explanation import QuoteExplanationService, ExplanationDepth logger = logging.getLogger(__name__) diff --git a/main.py b/main.py index 92ad1bf..b4cc7d2 100644 --- a/main.py +++ b/main.py @@ -12,6 +12,7 @@ import os import signal import sys from pathlib import Path +from typing import Dict, List, Optional, Any import discord from discord.ext import commands @@ -22,11 +23,11 @@ from core.database import DatabaseManager from core.ai_manager import AIProviderManager from core.memory_manager import MemoryManager from core.consent_manager import ConsentManager -from services.audio_recorder import AudioRecorderService -from services.speaker_diarization import SpeakerDiarization -from services.quote_analyzer import QuoteAnalyzer -from services.tts_service import TTSService -from services.response_scheduler import ResponseScheduler +from services.audio.audio_recorder import AudioRecorderService +from services.audio.speaker_diarization import SpeakerDiarizationService +from services.quotes.quote_analyzer import QuoteAnalyzer +from services.audio.tts_service import TTSService +from services.automation.response_scheduler import ResponseScheduler from utils.metrics import MetricsCollector from utils.audio_processor import AudioProcessor @@ -172,7 +173,7 @@ class QuoteBot(commands.Bot): ) # Speaker diarization - from services.speaker_diarization import SpeakerDiarizationService + from services.audio.speaker_diarization import SpeakerDiarizationService self.speaker_diarization = SpeakerDiarizationService( self.db_manager, self.consent_manager, @@ -181,7 +182,7 @@ class QuoteBot(commands.Bot): await self.speaker_diarization.initialize() # Transcription service - from services.transcription_service import TranscriptionService + from services.audio.transcription_service import TranscriptionService self.transcription_service = TranscriptionService( self.ai_manager, self.db_manager, @@ -191,7 +192,7 @@ class QuoteBot(commands.Bot): await self.transcription_service.initialize() # Laughter detection service - from services.laughter_detection import LaughterDetector + from services.audio.laughter_detection import LaughterDetector self.laughter_detector = LaughterDetector( AudioProcessor(), self.db_manager @@ -199,7 +200,7 @@ class QuoteBot(commands.Bot): await self.laughter_detector.initialize() # Quote analysis engine - from services.quote_analyzer import QuoteAnalyzer + from services.quotes.quote_analyzer import QuoteAnalyzer self.quote_analyzer = QuoteAnalyzer( self.ai_manager, self.memory_manager, @@ -209,7 +210,7 @@ class QuoteBot(commands.Bot): await self.quote_analyzer.initialize() # Response scheduling system - from services.response_scheduler import ResponseScheduler + from services.automation.response_scheduler import ResponseScheduler self.response_scheduler = ResponseScheduler( self.db_manager, self.ai_manager, diff --git a/services/__init__.py b/services/__init__.py new file mode 100644 index 0000000..a2c7905 --- /dev/null +++ b/services/__init__.py @@ -0,0 +1,55 @@ +""" +Services Package + +Discord Voice Chat Quote Bot services organized into thematic packages: + +- audio: Audio processing, recording, transcription, TTS, speaker analysis +- quotes: Quote analysis, scoring, and explanation services +- interaction: User feedback, tagging, and Discord UI components +- monitoring: Health monitoring, metrics, and system tracking +- automation: Response scheduling and automated workflows + +Each package is self-contained with its own __init__.py file providing +clean imports for all classes and functions within that domain. +""" + +# Import all subpackages for convenient access +from . import audio +from . import quotes +from . import interaction +from . import monitoring +from . import automation + +# Re-export commonly used classes for convenience +from .audio import ( + AudioRecorderService, TranscriptionService, TTSService, + SpeakerDiarizationService, SpeakerRecognitionService, LaughterDetector +) +from .quotes import QuoteAnalyzer, QuoteExplanationService +from .interaction import FeedbackSystem, UserAssistedTaggingService +from .monitoring import HealthMonitor, HealthEndpoints +from .automation import ResponseScheduler + +__all__ = [ + # Subpackages + 'audio', + 'quotes', + 'interaction', + 'monitoring', + 'automation', + + # Commonly used services + 'AudioRecorderService', + 'TranscriptionService', + 'TTSService', + 'SpeakerDiarizationService', + 'SpeakerRecognitionService', + 'LaughterDetector', + 'QuoteAnalyzer', + 'QuoteExplanationService', + 'FeedbackSystem', + 'UserAssistedTaggingService', + 'HealthMonitor', + 'HealthEndpoints', + 'ResponseScheduler', +] \ No newline at end of file diff --git a/services/audio/__init__.py b/services/audio/__init__.py new file mode 100644 index 0000000..ebe80ae --- /dev/null +++ b/services/audio/__init__.py @@ -0,0 +1,74 @@ +""" +Audio Processing Services Package + +Contains all audio-related processing services including recording, transcription, +text-to-speech, speaker diarization, speaker recognition, and laughter detection. +""" + +from .audio_recorder import AudioRecorderService, AudioSink, AudioClip, AudioBuffer +from .transcription_service import ( + TranscriptionService, + TranscribedSegment, + TranscriptionSession +) +from .tts_service import ( + TTSService, + TTSProvider, + TTSRequest, + TTSResult +) +from .speaker_diarization import ( + SpeakerDiarizationService, + SpeakerSegment, + DiarizationResult +) +from .speaker_recognition import ( + SpeakerRecognitionService, + VoiceEmbedding, + SpeakerProfile, + RecognitionResult, + EnrollmentStatus, + RecognitionMethod +) +from .laughter_detection import ( + LaughterDetector, + LaughterSegment, + LaughterAnalysis +) + +__all__ = [ + # Audio Recording + 'AudioRecorderService', + 'AudioSink', + 'AudioClip', + 'AudioBuffer', + + # Transcription + 'TranscriptionService', + 'TranscribedSegment', + 'TranscriptionSession', + + # Text-to-Speech + 'TTSService', + 'TTSProvider', + 'TTSRequest', + 'TTSResult', + + # Speaker Diarization + 'SpeakerDiarizationService', + 'SpeakerSegment', + 'DiarizationResult', + + # Speaker Recognition + 'SpeakerRecognitionService', + 'VoiceEmbedding', + 'SpeakerProfile', + 'RecognitionResult', + 'EnrollmentStatus', + 'RecognitionMethod', + + # Laughter Detection + 'LaughterDetector', + 'LaughterSegment', + 'LaughterAnalysis', +] \ No newline at end of file diff --git a/services/audio_recorder.py b/services/audio/audio_recorder.py similarity index 100% rename from services/audio_recorder.py rename to services/audio/audio_recorder.py diff --git a/services/laughter_detection.py b/services/audio/laughter_detection.py similarity index 100% rename from services/laughter_detection.py rename to services/audio/laughter_detection.py diff --git a/services/speaker_diarization.py b/services/audio/speaker_diarization.py similarity index 100% rename from services/speaker_diarization.py rename to services/audio/speaker_diarization.py diff --git a/services/speaker_recognition.py b/services/audio/speaker_recognition.py similarity index 99% rename from services/speaker_recognition.py rename to services/audio/speaker_recognition.py index 0732655..d660728 100644 --- a/services/speaker_recognition.py +++ b/services/audio/speaker_recognition.py @@ -27,7 +27,7 @@ from sklearn.cluster import DBSCAN from core.database import DatabaseManager from core.ai_manager import AIProviderManager from utils.audio_processor import AudioProcessor -from services.speaker_diarization import SpeakerSegment, DiarizationResult +from .speaker_diarization import SpeakerSegment, DiarizationResult logger = logging.getLogger(__name__) diff --git a/services/transcription_service.py b/services/audio/transcription_service.py similarity index 99% rename from services/transcription_service.py rename to services/audio/transcription_service.py index 01ca8c5..890dbf9 100644 --- a/services/transcription_service.py +++ b/services/audio/transcription_service.py @@ -16,7 +16,7 @@ import json from core.ai_manager import AIProviderManager, TranscriptionResult from core.database import DatabaseManager -from services.speaker_diarization import SpeakerDiarizationService, SpeakerSegment, DiarizationResult +from .speaker_diarization import SpeakerDiarizationService, SpeakerSegment, DiarizationResult from utils.audio_processor import AudioProcessor logger = logging.getLogger(__name__) diff --git a/services/tts_service.py b/services/audio/tts_service.py similarity index 100% rename from services/tts_service.py rename to services/audio/tts_service.py diff --git a/services/automation/__init__.py b/services/automation/__init__.py new file mode 100644 index 0000000..c8b0bc6 --- /dev/null +++ b/services/automation/__init__.py @@ -0,0 +1,19 @@ +""" +Automation Services Package + +Contains all automated scheduling and response management services including +configurable threshold-based responses and timing management. +""" + +from .response_scheduler import ( + ResponseScheduler, + ResponseType, + ScheduledResponse +) + +__all__ = [ + # Response Scheduling + 'ResponseScheduler', + 'ResponseType', + 'ScheduledResponse', +] \ No newline at end of file diff --git a/services/response_scheduler.py b/services/automation/response_scheduler.py similarity index 99% rename from services/response_scheduler.py rename to services/automation/response_scheduler.py index 723d0e2..2c77af3 100644 --- a/services/response_scheduler.py +++ b/services/automation/response_scheduler.py @@ -19,7 +19,7 @@ import discord from core.database import DatabaseManager from core.ai_manager import AIProviderManager -from services.quote_analyzer import QuoteAnalysis +from ..quotes.quote_analyzer import QuoteAnalysis from config.settings import Settings logger = logging.getLogger(__name__) diff --git a/services/interaction/__init__.py b/services/interaction/__init__.py new file mode 100644 index 0000000..86530eb --- /dev/null +++ b/services/interaction/__init__.py @@ -0,0 +1,45 @@ +""" +User Interaction Services Package + +Contains all user interaction and feedback services including RLHF feedback +collection, Discord UI components, and user-assisted speaker tagging. +""" + +from .feedback_system import ( + FeedbackSystem, + FeedbackType, + FeedbackSentiment, + FeedbackPriority, + FeedbackEntry, + FeedbackAnalysis +) +from .feedback_modals import ( + FeedbackRatingModal, + CategoryFeedbackModal +) +from .user_assisted_tagging import ( + UserAssistedTaggingService, + TaggingSessionStatus, + SpeakerTag, + TaggingSession +) + +__all__ = [ + # Feedback System + 'FeedbackSystem', + 'FeedbackType', + 'FeedbackSentiment', + 'FeedbackPriority', + 'FeedbackEntry', + 'FeedbackAnalysis', + + # Feedback UI Components + 'FeedbackRatingModal', + 'CategoryFeedbackModal', + + # User-Assisted Tagging + 'UserAssistedTaggingService', + 'TaggingSessionStatus', + 'SpeakerTag', + 'TaggingSession', +] \ No newline at end of file diff --git a/services/feedback_modals.py b/services/interaction/feedback_modals.py similarity index 99% rename from services/feedback_modals.py rename to services/interaction/feedback_modals.py index fa4df05..ab59cd8 100644 --- a/services/feedback_modals.py +++ b/services/interaction/feedback_modals.py @@ -12,7 +12,7 @@ from typing import Optional import discord -from services.feedback_system import FeedbackSystem, FeedbackType, FeedbackPriority +from .feedback_system import FeedbackSystem, FeedbackType, FeedbackPriority logger = logging.getLogger(__name__) diff --git a/services/feedback_system.py b/services/interaction/feedback_system.py similarity index 99% rename from services/feedback_system.py rename to services/interaction/feedback_system.py index d449192..9e21ffb 100644 --- a/services/feedback_system.py +++ b/services/interaction/feedback_system.py @@ -138,7 +138,7 @@ class FeedbackSystem: await self._load_existing_feedback() # Start background tasks - from services.feedback_modals import feedback_processing_worker, analysis_update_worker + from .feedback_modals import feedback_processing_worker, analysis_update_worker self._feedback_processing_task = asyncio.create_task(feedback_processing_worker(self)) self._analysis_update_task = asyncio.create_task(analysis_update_worker(self)) diff --git a/services/user_assisted_tagging.py b/services/interaction/user_assisted_tagging.py similarity index 99% rename from services/user_assisted_tagging.py rename to services/interaction/user_assisted_tagging.py index efc854f..6f00f57 100644 --- a/services/user_assisted_tagging.py +++ b/services/interaction/user_assisted_tagging.py @@ -19,8 +19,8 @@ import discord from discord.ext import commands from core.database import DatabaseManager -from services.speaker_diarization import SpeakerDiarizationService, DiarizationResult, SpeakerSegment -from services.transcription_service import TranscriptionService, TranscribedSegment +from ..audio.speaker_diarization import SpeakerDiarizationService, DiarizationResult, SpeakerSegment +from ..audio.transcription_service import TranscriptionService, TranscribedSegment logger = logging.getLogger(__name__) diff --git a/services/monitoring/__init__.py b/services/monitoring/__init__.py new file mode 100644 index 0000000..1e9eaf8 --- /dev/null +++ b/services/monitoring/__init__.py @@ -0,0 +1,29 @@ +""" +Monitoring Services Package + +Contains all health monitoring and system tracking services including +Prometheus metrics, health checks, and HTTP monitoring endpoints. +""" + +from .health_monitor import ( + HealthMonitor, + HealthStatus, + MetricType, + HealthCheckResult, + SystemMetrics, + ComponentMetrics +) +from .health_endpoints import HealthEndpoints + +__all__ = [ + # Health Monitoring + 'HealthMonitor', + 'HealthStatus', + 'MetricType', + 'HealthCheckResult', + 'SystemMetrics', + 'ComponentMetrics', + + # Health Endpoints + 'HealthEndpoints', +] \ No newline at end of file diff --git a/services/health_endpoints.py b/services/monitoring/health_endpoints.py similarity index 99% rename from services/health_endpoints.py rename to services/monitoring/health_endpoints.py index 9c0036b..465691d 100644 --- a/services/health_endpoints.py +++ b/services/monitoring/health_endpoints.py @@ -14,7 +14,7 @@ from aiohttp import web, ClientSession from aiohttp.web_response import Response import aiohttp_cors -from services.health_monitor import HealthMonitor +from .health_monitor import HealthMonitor logger = logging.getLogger(__name__) diff --git a/services/health_monitor.py b/services/monitoring/health_monitor.py similarity index 100% rename from services/health_monitor.py rename to services/monitoring/health_monitor.py diff --git a/services/quotes/__init__.py b/services/quotes/__init__.py new file mode 100644 index 0000000..ffb72c4 --- /dev/null +++ b/services/quotes/__init__.py @@ -0,0 +1,33 @@ +""" +Quote Processing Services Package + +Contains all quote analysis and processing services including multi-dimensional +scoring, explanation generation, and analysis transparency features. +""" + +from .quote_analyzer import ( + QuoteAnalyzer, + QuoteScores, + QuoteAnalysis +) +from .quote_explanation import ( + QuoteExplanationService, + ExplanationDepth, + ScoreExplanation, + QuoteAnalysisExplanation +) +from .quote_explanation_helpers import QuoteExplanationHelpers + +__all__ = [ + # Quote Analysis + 'QuoteAnalyzer', + 'QuoteScores', + 'QuoteAnalysis', + + # Quote Explanation + 'QuoteExplanationService', + 'ExplanationDepth', + 'ScoreExplanation', + 'QuoteAnalysisExplanation', + 'QuoteExplanationHelpers', +] \ No newline at end of file diff --git a/services/quote_analyzer.py b/services/quotes/quote_analyzer.py similarity index 100% rename from services/quote_analyzer.py rename to services/quotes/quote_analyzer.py diff --git a/services/quote_explanation.py b/services/quotes/quote_explanation.py similarity index 99% rename from services/quote_explanation.py rename to services/quotes/quote_explanation.py index 294aa7e..ca10365 100644 --- a/services/quote_explanation.py +++ b/services/quotes/quote_explanation.py @@ -145,7 +145,7 @@ class QuoteExplanationService: analysis_metadata = await self._get_analysis_metadata(quote_id) # Generate category explanations - from services.quote_explanation_helpers import QuoteExplanationHelpers + from .quote_explanation_helpers import QuoteExplanationHelpers category_explanations = await QuoteExplanationHelpers.generate_category_explanations( self, quote_data, analysis_metadata, depth ) @@ -186,7 +186,7 @@ class QuoteExplanationService: self.explanation_cache[quote_id] = explanation # Store in database for future reference - from services.quote_explanation_helpers import QuoteExplanationHelpers + from .quote_explanation_helpers import QuoteExplanationHelpers await QuoteExplanationHelpers.store_explanation(self, explanation) logger.debug(f"Generated explanation for quote {quote_id} with depth {depth.value}") diff --git a/services/quote_explanation_helpers.py b/services/quotes/quote_explanation_helpers.py similarity index 99% rename from services/quote_explanation_helpers.py rename to services/quotes/quote_explanation_helpers.py index 20c2afb..bac0463 100644 --- a/services/quote_explanation_helpers.py +++ b/services/quotes/quote_explanation_helpers.py @@ -11,7 +11,7 @@ import json from datetime import datetime from typing import Dict, List, Optional, Any -from services.quote_explanation import QuoteExplanationService, ExplanationDepth, ScoreExplanation +from .quote_explanation import QuoteExplanationService, ExplanationDepth, ScoreExplanation logger = logging.getLogger(__name__) diff --git a/ui/components.py b/ui/components.py index 8d8ed13..f32daec 100644 --- a/ui/components.py +++ b/ui/components.py @@ -18,7 +18,7 @@ from discord import ui from core.database import DatabaseManager from core.consent_manager import ConsentManager from core.memory_manager import MemoryManager -from services.quote_analyzer import QuoteAnalyzer +from services.quotes.quote_analyzer import QuoteAnalyzer logger = logging.getLogger(__name__)