HydraLLM: बुद्धिमान ऑर्केस्ट्रेटर

HydraLLM एक context-aware gateway है, जिसे कई LLM resources का कुशलतापूर्वक उपयोग करने के लिए डिज़ाइन किया गया है। यह Gemini / Groq / Cerebras के बीच requests को route करता है, provider-विशिष्ट circuit breakers, random key rotation (quota-aware cooldown सहित), real-time web augmentation प्रदान करता है, और OpenAI-compatible API को सख्त Clean Architecture (Domain फिर Services फिर Adapters फिर API) के ऊपर बनाता है।

  • संस्करण: 1.3.0 (pyproject.toml)
  • Python: 3.10+
  • रन entry point: python main.py
  • एकीकृत UI: http://localhost:8000/ui
  • OpenAI-compatible endpoint: POST /v1/chat/completions

HydraLLM तकनीकी विनिर्देशन (SPEC)

1. अवलोकन

HydraLLM एक high-availability LLM gateway है जो Clean Architecture का पालन करता है। यह multi-provider के बीच बुद्धिमान routing, circuit breaker-आधारित failure isolation, और real-time web augmentation प्रदान करता है, तथा OpenAI API specification को पूरी तरह support करता है।

2. मुख्य component विनिर्देशन

2.1 Gateway (src/services/gateway.py)

  • Orchestration: session load -> context analysis -> web augmentation -> resilient execution -> persistence flow का समन्वय।
  • तकनीकी routing reasons: सभी responses में decision basis को स्पष्ट constants के रूप में शामिल किया जाता है।
    • USER_HINT: उपयोगकर्ता द्वारा स्पष्ट रूप से निर्दिष्ट
    • TOKEN_OPTIMIZED: token count-आधारित optimization
    • WEB_INTENT_SEARCH: web search intent analysis result
    • MULTIMODAL_ANALYSIS: image processing की आवश्यकता का पता लगाना
    • KEY_AVAILABILITY: key status और failover result

2.2 Context Analyzer (src/services/analyzer.py)

  • Routing algorithm: token length, multimodal है या नहीं, और web search intent का विश्लेषण करके सर्वोत्तम RoutingDecision तैयार करता है।
  • Dynamic availability filtering: KeyManager की real-time status को दर्शाते हुए, जिन providers के पास active keys नहीं हैं उनके models को विकल्पों से बाहर रखा जाता है।

2.3 Key Manager (src/services/key_manager.py)

  • Key rotation: active key pool के भीतर random selection और usage tracking।
  • Failure management: error type के अनुसार अलग-अलग cooldown लागू।
    • 403 Forbidden: 24 घंटे (key-स्तर पर स्थायी failure handling)
    • 429 Rate Limit / Quota: 1 घंटा
    • अन्य communication errors: 5 मिनट

2.4 Web Context Service (src/services/web_context_service.py)

  • Data augmentation: Playwright/Scrapling-आधारित real-time information collection और prompt injection।
  • Performance tracking: scraping_metrics table के माध्यम से success rate, collected character count, और latency रिकॉर्ड की जाती है।

3. Resilience और recovery patterns (Troubleshooting Insights)

  • Concurrency Guard: KeyManager और SessionManager की write operations पर asyncio.Lock और threading.Lock लागू करके high-load स्थितियों में data integrity सुनिश्चित की जाती है।
  • Self-Healing Scraper: browser instance crash का पता चलने पर automatic restart mechanism सक्रिय होता है।
  • Unpacking Guard: augmentation data processing के दौरान होने वाली NoneType errors को रोकने के लिए सख्त return type (tuple[list, str | None]) और guard का पालन किया जाता है।

अभी कोई टिप्पणी नहीं है.

अभी कोई टिप्पणी नहीं है.