refactor(services): reorganize services into thematic subpackages
- Move audio-related services into services.audio package - Move quote processing services into services.quotes package - Move interaction and feedback services into services.interaction package - Move monitoring services into services.monitoring package - Move automation services into services.automation package - Update import statements across project to use new package structure - Add __init__.py files with explicit exports for each subpackage - Re-export commonly used services from services/__init__.py for convenience
This commit is contained in:
@@ -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__)
|
||||
|
||||
|
||||
21
main.py
21
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,
|
||||
|
||||
55
services/__init__.py
Normal file
55
services/__init__.py
Normal file
@@ -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',
|
||||
]
|
||||
74
services/audio/__init__.py
Normal file
74
services/audio/__init__.py
Normal file
@@ -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',
|
||||
]
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
19
services/automation/__init__.py
Normal file
19
services/automation/__init__.py
Normal file
@@ -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',
|
||||
]
|
||||
@@ -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__)
|
||||
45
services/interaction/__init__.py
Normal file
45
services/interaction/__init__.py
Normal file
@@ -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',
|
||||
]
|
||||
@@ -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__)
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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__)
|
||||
|
||||
29
services/monitoring/__init__.py
Normal file
29
services/monitoring/__init__.py
Normal file
@@ -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',
|
||||
]
|
||||
@@ -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__)
|
||||
|
||||
33
services/quotes/__init__.py
Normal file
33
services/quotes/__init__.py
Normal file
@@ -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',
|
||||
]
|
||||
@@ -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}")
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user