Spaces:
Running
Running
| # trend_tool.py | |
| from typing import Dict, Any, List | |
| from trend_predictor import predict_trends | |
| class TrendTool: | |
| """ | |
| Wrapper-Klasse zur Kapselung der Trend_Predictor-Berechnungen. | |
| Stellt komfortable Schnittstellen für Einzel- und Batchanalysen bereit. | |
| """ | |
| def __init__(self, debug_mode: bool = False): | |
| if debug_mode: | |
| print("[SkyOS System Log] TrendTool erfolgreich instanziiert.") | |
| def analyze_trend( | |
| self, | |
| name: str, | |
| share_rate: float, | |
| comment_depth: float, | |
| hook_score: float, | |
| narrative: float, | |
| saturation: float | |
| ) -> Dict[str, Any]: | |
| """Analysiert einen einzelnen Trend und gibt das flache Ergebnis zurück.""" | |
| trends = [ | |
| { | |
| "name": name, | |
| "share_rate": share_rate, | |
| "comment_depth": comment_depth, | |
| "hook_score": hook_score, | |
| "narrative": narrative, | |
| "saturation": saturation | |
| } | |
| ] | |
| result = predict_trends(trends) | |
| if not result: | |
| return { | |
| "status": "error", | |
| "message": "Keine Trenddaten berechnet." | |
| } | |
| return { | |
| "status": "success", | |
| "module": "trend_tool", | |
| "result": result[0] | |
| } | |
| def analyze_trends( | |
| self, | |
| trends: List[Dict[str, Any]] | |
| ) -> Dict[str, Any]: | |
| """Verarbeitet eine Batch-Liste von Trends parallel.""" | |
| result = predict_trends(trends) | |
| return { | |
| "status": "success", | |
| "module": "trend_tool", | |
| "count": len(result), | |
| "results": result | |
| } | |