Update FastAPI application and related services for WP-25a: Enhance lifespan management with Mixture of Experts (MoE) integrity checks, improve logging and error handling in LLMService, and integrate profile-driven orchestration across components. Bump versions for main application, ingestion services, and LLM profiles to reflect new features and optimizations.
This commit is contained in:
1 parent
9a98093e70
commit
9b906bbabf
9 files changed
+408
-195
No files matched your search
@@ -3,13 +3,14 @@ FILE: app/core/retrieval/decision_engine.py
|
||||
DESCRIPTION: Der Agentic Orchestrator für MindNet (WP-25a Edition).
|
||||
Realisiert Multi-Stream Retrieval, Intent-basiertes Routing
|
||||
und die neue Pre-Synthesis Kompression (Module A).
|
||||
VERSION: 1.2.0 (WP-25a: Mixture of Experts Support)
|
||||
VERSION: 1.2.1 (WP-25a: Profile-Driven Orchestration & Optimized Cascade)
|
||||
STATUS: Active
|
||||
FIX:
|
||||
- WP-25a: Vollständige Integration der llm_profile-Steuerung für Synthese und Kompression.
|
||||
- WP-25a: Implementierung der _compress_stream_content Logik zur Inhaltsverdichtung.
|
||||
- WP-25a: Volle Integration der Profil-Kaskade (Delegation an LLMService v3.5.2).
|
||||
- WP-25a: Dynamische Nutzung des 'router_profile' für die Intent-Erkennung.
|
||||
- WP-25a: Parallelisierte Kompression überlanger Wissens-Streams.
|
||||
- WP-25: Beibehaltung von Stream-Tracing und Pre-Initialization Robustness.
|
||||
- COMPATIBILITY: Erhalt aller Methoden-Signaturen für den System-Merge.
|
||||
- CLEANUP: Entfernung redundanter Fallback-Blocks (jetzt im LLMService).
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
@@ -77,16 +78,19 @@ class DecisionEngine:
|
||||
return await self._generate_final_answer(strategy_key, strategy, query, stream_results)
|
||||
|
||||
async def _determine_strategy(self, query: str) -> str:
|
||||
"""Nutzt den LLM-Router zur Wahl der Such-Strategie."""
|
||||
prompt_key = self.config.get("settings", {}).get("router_prompt_key", "intent_router_v1")
|
||||
router_profile = self.config.get("settings", {}).get("router_profile")
|
||||
"""Nutzt den LLM-Router zur Wahl der Such-Strategie via router_profile."""
|
||||
settings_cfg = self.config.get("settings", {})
|
||||
prompt_key = settings_cfg.get("router_prompt_key", "intent_router_v1")
|
||||
# WP-25a: Nutzt das spezialisierte Profil für das Routing
|
||||
router_profile = settings_cfg.get("router_profile")
|
||||
|
||||
router_prompt_template = self.llm_service.get_prompt(prompt_key)
|
||||
if not router_prompt_template:
|
||||
return "FACT_WHAT"
|
||||
|
||||
full_prompt = router_prompt_template.format(query=query)
|
||||
try:
|
||||
# Der Router nutzt den Standard-Provider (auto)
|
||||
# Der LLMService übernimmt hier über das Profil bereits die Fallback-Kaskade
|
||||
response = await self.llm_service.generate_raw_response(
|
||||
full_prompt, max_retries=1, priority="realtime", profile_name=router_profile
|
||||
)
|
||||
@@ -128,7 +132,7 @@ class DecisionEngine:
|
||||
# Formatierung der Hits in Text
|
||||
formatted_context = self._format_stream_context(res)
|
||||
|
||||
# WP-25a: Kompressions-Check
|
||||
# WP-25a: Kompressions-Check (Inhaltsverdichtung)
|
||||
stream_cfg = library.get(name, {})
|
||||
threshold = stream_cfg.get("compression_threshold", 4000)
|
||||
|
||||
@@ -152,7 +156,6 @@ class DecisionEngine:
|
||||
"""
|
||||
WP-25a Module A: Inhaltsverdichtung via Experten-Modell.
|
||||
"""
|
||||
# Falls kein Profil definiert, nutzen wir das Default-Profil der Strategie
|
||||
compression_prompt = (
|
||||
f"Du bist ein Wissens-Analyst. Reduziere den folgenden Wissens-Stream '{stream_name}' "
|
||||
f"auf die Informationen, die für die Beantwortung der Frage '{query}' absolut notwendig sind.\n\n"
|
||||
@@ -220,8 +223,6 @@ class DecisionEngine:
|
||||
profile = strategy.get("llm_profile")
|
||||
template_key = strategy.get("prompt_template", "rag_template")
|
||||
|
||||
# Hier nutzen wir noch den Provider-String für get_prompt (Kompatibilität zu prompts.yaml)
|
||||
# Der llm_service löst das Profil erst bei generate_raw_response auf.
|
||||
template = self.llm_service.get_prompt(template_key)
|
||||
system_prompt = self.llm_service.get_prompt("system_prompt")
|
||||
|
||||
@@ -238,25 +239,21 @@ class DecisionEngine:
|
||||
if prepend:
|
||||
final_prompt = f"{prepend}\n\n{final_prompt}"
|
||||
|
||||
# WP-25a: MoE Call
|
||||
# WP-25a: MoE Call mit automatisierter Kaskade im LLMService
|
||||
# (Frühere manuelle Fallback-Blocks wurden entfernt, da v3.5.2 dies intern löst)
|
||||
response = await self.llm_service.generate_raw_response(
|
||||
final_prompt, system=system_prompt, profile_name=profile, priority="realtime"
|
||||
)
|
||||
|
||||
# Fallback bei leerer Antwort auf lokales Modell
|
||||
if not response or len(response.strip()) < 5:
|
||||
return await self.llm_service.generate_raw_response(
|
||||
final_prompt, system=system_prompt, provider="ollama", priority="realtime"
|
||||
)
|
||||
|
||||
return response
|
||||
|
||||
except KeyError as e:
|
||||
logger.error(f"Template Variable mismatch in '{template_key}': Missing {e}")
|
||||
fallback_context = "\n\n".join([v for v in stream_results.values() if v])
|
||||
# WP-25a FIX: Nutzt auch im Fallback das Strategie-Profil für Konsistenz
|
||||
return await self.llm_service.generate_raw_response(
|
||||
f"Beantworte: {query}\n\nKontext:\n{fallback_context}",
|
||||
system=system_prompt, priority="realtime"
|
||||
system=system_prompt, priority="realtime", profile_name=profile
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Final Synthesis failed: {e}")
|
||||
|
||||
Reference in new issue
Block a user