Update Decision Engine for WP-25: Bump version to 1.0.2, enhance robustness by pre-initializing stream variables to prevent KeyErrors, and fix template mismatches in strategy definitions. Ensure compatibility with updated YAML configuration for multi-stream retrieval strategies.
This commit is contained in:
1 parent
bb6959a090
commit
ed3f3e5588
2 files changed
+28
-31
No files matched your search
@@ -3,11 +3,12 @@ FILE: app/core/retrieval/decision_engine.py
|
||||
DESCRIPTION: Der Agentic Orchestrator für WP-25.
|
||||
Realisiert Multi-Stream Retrieval, Intent-basiertes Routing
|
||||
und parallele Wissens-Synthese.
|
||||
VERSION: 1.0.1
|
||||
VERSION: 1.0.2
|
||||
STATUS: Active
|
||||
FIX:
|
||||
- Behebung eines potenziellen KeyError bei fehlender 'FACT_WHAT' Strategie (Fallback-Resilienz).
|
||||
- Einführung einer mehrstufigen Sicherheitskaskade für die Strategiewahl.
|
||||
- WP-25 ROBUSTNESS: Pre-Initialization aller Stream-Variablen zur Vermeidung von KeyErrors.
|
||||
- Behebung von Template-Mismatches bei unvollständigen Strategie-Definitionen.
|
||||
- Erhalt der Sicherheitskaskade für die Strategiewahl.
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
@@ -167,12 +168,20 @@ class DecisionEngine:
|
||||
template = self.llm_service.get_prompt(template_key, provider=provider)
|
||||
system_prompt = self.llm_service.get_prompt("system_prompt", provider=provider)
|
||||
|
||||
template_vars = {**stream_results, "query": query}
|
||||
# WP-25 ROBUSTNESS FIX:
|
||||
# Wir stellen sicher, dass alle Variablen, die im Template vorkommen könnten,
|
||||
# zumindest mit einem leeren String initialisiert sind.
|
||||
all_possible_streams = ["values_stream", "facts_stream", "biography_stream", "risk_stream", "tech_stream"]
|
||||
template_vars = {s: "" for s in all_possible_streams}
|
||||
|
||||
# Überschreiben mit tatsächlichen Ergebnissen
|
||||
template_vars.update(stream_results)
|
||||
template_vars["query"] = query
|
||||
|
||||
prepend = strategy.get("prepend_instruction", "")
|
||||
|
||||
try:
|
||||
# Sicherheitscheck: Sind alle benötigten Platzhalter im Template vorhanden?
|
||||
# Im Fehlerfall Fallback auf eine einfache Zusammenführung
|
||||
final_prompt = template.format(**template_vars)
|
||||
if prepend:
|
||||
final_prompt = f"{prepend}\n\n{final_prompt}"
|
||||
@@ -197,7 +206,7 @@ class DecisionEngine:
|
||||
except KeyError as e:
|
||||
logger.error(f"Template Variable mismatch in '{template_key}': Missing {e}")
|
||||
# Fallback: Einfaches Aneinanderreihen der gefundenen Stream-Inhalte
|
||||
fallback_context = "\n\n".join(stream_results.values())
|
||||
fallback_context = "\n\n".join([v for v in stream_results.values() if v])
|
||||
return await self.llm_service.generate_raw_response(
|
||||
f"Beantworte: {query}\n\nKontext:\n{fallback_context}",
|
||||
system=system_prompt,
|
||||
|
||||
Reference in new issue
Block a user