```python from typing import Dict, Any from .models_registry import model_registry async def extract_chart_features(image_bytes: bytes) -> Dict[str, Any]: # First get OCR data ocr_data = await model_registry.run_ocr(image_bytes) # Then get visual analysis vision_data = await model_registry.analyze_chart_image(image_bytes) # Combine results return { "trend": vision_data.get("trend", "unknown"), "key_levels": extract_key_levels(ocr_data.get("text", "")), "patterns": vision_data.get("patterns", []), "timeframe": infer_timeframe(ocr_data.get("text", "")), "raw_ocr": ocr_data } def extract_key_levels(ocr_text: str) -> list: # Simple heuristic to find numbers in OCR text import re numbers = re.findall(r"\d+\.\d+", ocr_text) return sorted([float(n) for n in numbers], reverse=True) def infer_timeframe(ocr_text: str) -> str: if "1D" in ocr_text or "daily" in ocr_text.lower(): return "1D" elif "4H" in ocr_text or "4h" in ocr_text: return "4h" elif "1H" in ocr_text or "1h" in ocr_text: return "1h" elif "15M" in ocr_text or "15m" in ocr_text: return "15m" return "1h" # default ```