Update documentation and technical references for Mindnet v3.1.1: Revise versioning across all documents to reflect the latest updates, including the integration of Lazy-Prompt-Orchestration and enhancements in AI model capabilities. Update context descriptions to clarify new features and improvements in prompt management, ingestion validation, and decision engine processes.
This commit is contained in:
1 parent
8505538b34
commit
62a00d1ac3
12 files changed
+732
-66
No files matched your search
@@ -1,10 +1,10 @@
|
||||
---
|
||||
doc_type: technical_reference
|
||||
audience: developer, architect
|
||||
scope: backend, chat, llm_service, traffic_control, resilience, agentic_rag, moe
|
||||
scope: backend, chat, llm_service, traffic_control, resilience, agentic_rag, moe, lazy_prompts
|
||||
status: active
|
||||
version: 3.0.0
|
||||
context: "Technische Implementierung des FastAPI-Routers, des hybriden LLMService (v3.5.2), WP-25 Agentic Multi-Stream RAG, WP-25a Mixture of Experts (MoE) und WP-20 Resilienz-Logik."
|
||||
version: 3.1.1
|
||||
context: "Technische Implementierung des FastAPI-Routers, des hybriden LLMService (v3.5.5), WP-25 Agentic Multi-Stream RAG, WP-25a Mixture of Experts (MoE), WP-25b Lazy-Prompt-Orchestration und WP-20 Resilienz-Logik."
|
||||
---
|
||||
|
||||
# Chat Backend & Agentic Multi-Stream RAG
|
||||
@@ -13,7 +13,7 @@ context: "Technische Implementierung des FastAPI-Routers, des hybriden LLMServic
|
||||
|
||||
Der zentrale Einstiegspunkt für jede Chatanfrage ist der **Hybrid Router** (`app/routers/chat.py`). Seit WP-25 agiert das System als **Agentic Orchestrator**, der Nutzeranfragen analysiert, in parallele Wissens-Streams aufteilt und diese zu einer kontextreichen, wertebasierten Antwort synthetisiert.
|
||||
|
||||
### 1.1 Intent-Erkennung (Hybrid-Modus)
|
||||
### 1.1 Intent-Erkennung (Hybrid-Modus - WP-25b)
|
||||
|
||||
Der Router nutzt einen **Hybrid-Modus** mit Keyword-Fast-Path und LLM-Slow-Path:
|
||||
|
||||
@@ -24,9 +24,11 @@ Der Router nutzt einen **Hybrid-Modus** mit Keyword-Fast-Path und LLM-Slow-Path:
|
||||
2. **Type Keywords (Interview-Modus):**
|
||||
* Lädt `types.yaml` und prüft `detection_keywords` für Objekt-Erkennung.
|
||||
* Wenn Match und keine Frage: **INTERVIEW Modus** (Datenerfassung).
|
||||
3. **LLM Slow-Path (Semantische Analyse):**
|
||||
3. **LLM Slow-Path (Semantische Analyse - WP-25b):**
|
||||
* Wenn unklar: Anfrage an `DecisionEngine._determine_strategy()` zur LLM-basierten Klassifizierung.
|
||||
* Nutzt `intent_router_v1` Prompt aus `prompts.yaml`.
|
||||
* **Lazy-Prompt-Loading:** Nutzt `prompt_key="intent_router_v1"` mit `variables={"query": query}`
|
||||
* **Ultra-robustes Parsing:** Regex-basierter Intent-Parser bereinigt Modell-Artefakte (z.B. `CODING[/S]` → `CODING`)
|
||||
* **Fallback:** Bei unklarem Intent → `FACT_WHAT`
|
||||
|
||||
### 1.2 Mixture of Experts (MoE) Architektur (WP-25a)
|
||||
|
||||
@@ -52,13 +54,32 @@ Der `LLMService` (v3.5.2) implementiert eine automatische Fallback-Logik:
|
||||
* **Synthese:** Nutzt `llm_profile` aus Strategie-Konfiguration
|
||||
* **Ingestion:** Nutzt `ingest_validator` für binäre Validierungen
|
||||
|
||||
### 1.3 Prompt-Auflösung (Bulletproof Resolution)
|
||||
### 1.3 Hierarchisches Prompt-Resolution-System (WP-25b)
|
||||
|
||||
Um Kompatibilitätsprobleme mit verschachtelten YAML-Prompts zu vermeiden, nutzt der Router die Methode `llm.get_prompt()`. Diese implementiert eine **Provider-Kaskade**:
|
||||
* **Spezifischer Provider:** Das System sucht zuerst nach einem Prompt für den aktiv konfigurierten Provider (z.B. `openrouter`).
|
||||
* **Cloud-Stil Fallback:** Existiert dieser nicht, erfolgt ein Fallback auf das `gemini`-Template.
|
||||
* **Basis-Fallback:** Als letzte Instanz wird das `ollama`-Template geladen.
|
||||
* **String-Garantie:** Die Methode garantiert die Rückgabe eines Strings (selbst bei verschachtelten YAML-Dicts), was 500-Fehler bei String-Operationen wie `.replace()` oder `.format()` verhindert.
|
||||
Seit WP-25b nutzt MindNet eine **dreistufige hierarchische Prompt-Auflösung** mit Lazy-Loading. Prompts werden erst im Moment des Modellaustauschs geladen, basierend auf dem exakt aktiven Modell.
|
||||
|
||||
**Hierarchische Auflösung (`llm_service.py` v3.5.5):**
|
||||
|
||||
1. **Level 1 (Modell-ID):** Suche nach exakten Übereinstimmungen für die Modell-ID (z.B. `google/gemini-2.0-flash-exp:free`).
|
||||
* **Vorteil:** Modell-spezifische Optimierungen (z.B. für Gemini 2.0, Llama 3.3, Qwen 2.5)
|
||||
* **Logging:** `🎯 [PROMPT-TRACE] Level 1 Match: Model-specific`
|
||||
|
||||
2. **Level 2 (Provider):** Fallback auf allgemeine Provider-Anweisungen (z.B. `openrouter` oder `ollama`).
|
||||
* **Vorteil:** Bewährte Standards aus v3.1.2 bleiben erhalten
|
||||
* **Logging:** `📡 [PROMPT-TRACE] Level 2 Match: Provider-fallback`
|
||||
|
||||
3. **Level 3 (Default):** Globaler Sicherheits-Satz zur Vermeidung von Fehlern bei unbekannten Konfigurationen.
|
||||
* **Fallback-Kette:** `default` → `gemini` → `ollama` → `""`
|
||||
* **Logging:** `⚓ [PROMPT-TRACE] Level 3 Match: Global Default`
|
||||
|
||||
**Lazy-Prompt-Orchestration:**
|
||||
* **Lazy Loading:** Prompts werden erst zur Laufzeit geladen, wenn das aktive Modell bekannt ist
|
||||
* **Parameter:** `prompt_key` und `variables` statt vorformatierter Strings
|
||||
* **Vorteil:** Maximale Resilienz bei Modell-Fallbacks (Cloud → Local)
|
||||
* **Traceability:** Vollständige Transparenz über genutzte Instruktionen via `[PROMPT-TRACE]` Logs
|
||||
|
||||
**String-Garantie:**
|
||||
Die Methode garantiert die Rückgabe eines Strings (selbst bei verschachtelten YAML-Dicts), was 500-Fehler bei String-Operationen wie `.replace()` oder `.format()` verhindert.
|
||||
|
||||
### 1.4 Multi-Stream Retrieval (WP-25)
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
doc_type: technical_reference
|
||||
audience: developer, admin
|
||||
scope: configuration, env, registry, scoring, resilience, modularization, agentic_rag, moe
|
||||
scope: configuration, env, registry, scoring, resilience, modularization, agentic_rag, moe, lazy_prompts
|
||||
status: active
|
||||
version: 3.0.0
|
||||
context: "Umfassende Referenztabellen für Umgebungsvariablen (inkl. Hybrid-Cloud & WP-76), YAML-Konfigurationen, Edge Registry Struktur, WP-25 Multi-Stream RAG und WP-25a Mixture of Experts (MoE) unter Berücksichtigung von WP-14."
|
||||
version: 3.1.1
|
||||
context: "Umfassende Referenztabellen für Umgebungsvariablen (inkl. Hybrid-Cloud & WP-76), YAML-Konfigurationen, Edge Registry Struktur, WP-25 Multi-Stream RAG, WP-25a Mixture of Experts (MoE) und WP-25b Lazy-Prompt-Orchestration unter Berücksichtigung von WP-14."
|
||||
---
|
||||
|
||||
# Konfigurations-Referenz
|
||||
@@ -302,13 +302,47 @@ Die Strategie `INTERVIEW` dient der strukturierten Datenerfassung.
|
||||
|
||||
> **Hinweis:** Da spezifische Schemas für Projekte oder Erfahrungen direkt in der `types.yaml` definiert werden, dient die `decision_engine.yaml` hier primär als Fallback für generische Datenaufnahmen.
|
||||
|
||||
### 5.6 Prompts-Konfiguration (`prompts.yaml` v3.1.2)
|
||||
### 5.6 Prompts-Konfiguration (`prompts.yaml` v3.2.2 - WP-25b)
|
||||
|
||||
Seit WP-25 nutzen die Synthese-Templates explizite Stream-Variablen:
|
||||
Seit WP-25b nutzt MindNet eine **hierarchische Prompt-Struktur** mit Lazy-Loading. Prompts werden erst zur Laufzeit geladen, basierend auf dem exakt aktiven Modell.
|
||||
|
||||
**Template-Struktur:**
|
||||
**Hierarchische Template-Struktur:**
|
||||
```yaml
|
||||
decision_synthesis_v1:
|
||||
# Level 1: Modell-spezifisch (höchste Priorität)
|
||||
"google/gemini-2.0-flash-exp:free": |
|
||||
WERTE & PRINZIPIEN (Identität):
|
||||
{values_stream}
|
||||
|
||||
OPERATIVE FAKTEN (Realität):
|
||||
{facts_stream}
|
||||
|
||||
RISIKO-RADAR (Konsequenzen):
|
||||
{risk_stream}
|
||||
|
||||
ENTSCHEIDUNGSFRAGE:
|
||||
{query}
|
||||
Nutze deine hohe Reasoning-Kapazität für eine tiefe Synthese.
|
||||
|
||||
"meta-llama/llama-3.3-70b-instruct:free": |
|
||||
Erstelle eine fundierte Synthese für die Frage: "{query}"
|
||||
Nutze die Daten: {values_stream}, {facts_stream} und {risk_stream}.
|
||||
Trenne klare Fakten von Erfahrungen. Bleibe strikt beim bereitgestellten Kontext.
|
||||
|
||||
# Level 2: Provider-Fallback (mittlere Priorität)
|
||||
openrouter: |
|
||||
WERTE & PRINZIPIEN (Identität):
|
||||
{values_stream}
|
||||
|
||||
OPERATIVE FAKTEN (Realität):
|
||||
{facts_stream}
|
||||
|
||||
RISIKO-RADAR (Konsequenzen):
|
||||
{risk_stream}
|
||||
|
||||
ENTSCHEIDUNGSFRAGE:
|
||||
{query}
|
||||
|
||||
ollama: |
|
||||
WERTE & PRINZIPIEN (Identität):
|
||||
{values_stream}
|
||||
@@ -321,13 +355,31 @@ decision_synthesis_v1:
|
||||
|
||||
ENTSCHEIDUNGSFRAGE:
|
||||
{query}
|
||||
|
||||
# Level 3: Global Default (niedrigste Priorität)
|
||||
default: |
|
||||
Synthetisiere die folgenden Informationen für: {query}
|
||||
{values_stream} | {facts_stream} | {risk_stream}
|
||||
```
|
||||
|
||||
**Auflösungs-Logik:**
|
||||
1. **Level 1:** Exakte Modell-ID (z.B. `google/gemini-2.0-flash-exp:free`)
|
||||
2. **Level 2:** Provider-Fallback (z.B. `openrouter`, `ollama`, `gemini`)
|
||||
3. **Level 3:** Global Default (`default` → `gemini` → `ollama` → `""`)
|
||||
|
||||
**Lazy-Loading:**
|
||||
* Prompts werden erst zur Laufzeit geladen, wenn das aktive Modell bekannt ist
|
||||
* **Parameter:** `prompt_key` und `variables` statt vorformatierter Strings
|
||||
* **Vorteil:** Maximale Resilienz bei Modell-Fallbacks (Cloud → Local)
|
||||
|
||||
**Pre-Initialization:**
|
||||
Alle möglichen Stream-Variablen werden vorab initialisiert (verhindert KeyErrors bei unvollständigen Konfigurationen).
|
||||
|
||||
**Provider-spezifische Templates:**
|
||||
Separate Versionen für Ollama, Gemini und OpenRouter.
|
||||
**PROMPT-TRACE Logging:**
|
||||
Das System protokolliert die genutzte Auflösungs-Ebene:
|
||||
* `🎯 [PROMPT-TRACE] Level 1 Match: Model-specific`
|
||||
* `📡 [PROMPT-TRACE] Level 2 Match: Provider-fallback`
|
||||
* `⚓ [PROMPT-TRACE] Level 3 Match: Global Default`
|
||||
|
||||
---
|
||||
|
||||
@@ -404,6 +456,261 @@ values_stream:
|
||||
|
||||
---
|
||||
|
||||
## 7. Konfigurations-Verbindungen & Datenfluss
|
||||
|
||||
Die vier zentralen Konfigurationsdateien (`types.yaml`, `decision_engine.yaml`, `llm_profiles.yaml`, `prompts.yaml`) arbeiten eng zusammen, um das agentische Multi-Stream RAG System zu steuern. Diese Sektion erklärt die Verbindungen und zeigt einen konkreten Praxisablauf.
|
||||
|
||||
### 7.1 Architektur-Übersicht
|
||||
|
||||
```mermaid
|
||||
graph TB
|
||||
subgraph "1. Typ-Definition (types.yaml)"
|
||||
T1[Typ: value<br/>chunking_profile: structured_strict<br/>retriever_weight: 1.00]
|
||||
T2[Typ: risk<br/>chunking_profile: sliding_short<br/>retriever_weight: 0.85]
|
||||
T3[Typ: project<br/>chunking_profile: sliding_smart_edges<br/>retriever_weight: 0.97]
|
||||
end
|
||||
|
||||
subgraph "2. Stream-Konfiguration (decision_engine.yaml)"
|
||||
D1[values_stream<br/>filter_types: value, principle, belief...<br/>llm_profile: identity_safe<br/>compression_profile: identity_safe]
|
||||
D2[risk_stream<br/>filter_types: risk, obstacle, bias<br/>llm_profile: synthesis_pro<br/>compression_profile: compression_fast]
|
||||
D3[facts_stream<br/>filter_types: project, decision, task...<br/>llm_profile: synthesis_pro<br/>compression_profile: compression_fast]
|
||||
end
|
||||
|
||||
subgraph "3. Strategie-Komposition (decision_engine.yaml)"
|
||||
S1[DECISION Strategie<br/>use_streams: values_stream, facts_stream, risk_stream<br/>llm_profile: synthesis_pro<br/>prompt_template: decision_synthesis_v1]
|
||||
end
|
||||
|
||||
subgraph "4. Experten-Profile (llm_profiles.yaml)"
|
||||
P1[synthesis_pro<br/>provider: openrouter<br/>model: google/gemini-2.0-flash-exp:free<br/>temperature: 0.7<br/>fallback_profile: synthesis_backup]
|
||||
P2[compression_fast<br/>provider: openrouter<br/>model: mistralai/mistral-7b-instruct:free<br/>temperature: 0.1<br/>fallback_profile: identity_safe]
|
||||
P3[identity_safe<br/>provider: ollama<br/>model: phi3:mini<br/>temperature: 0.2<br/>fallback_profile: null]
|
||||
end
|
||||
|
||||
subgraph "5. Prompt-Templates (prompts.yaml)"
|
||||
PR1[decision_synthesis_v1<br/>Level 1: google/gemini-2.0-flash-exp:free<br/>Level 2: openrouter<br/>Level 3: default]
|
||||
end
|
||||
|
||||
T1 -->|filter_types| D1
|
||||
T2 -->|filter_types| D2
|
||||
T3 -->|filter_types| D3
|
||||
|
||||
D1 -->|use_streams| S1
|
||||
D2 -->|use_streams| S1
|
||||
D3 -->|use_streams| S1
|
||||
|
||||
S1 -->|llm_profile| P1
|
||||
D1 -->|llm_profile| P3
|
||||
D2 -->|compression_profile| P2
|
||||
D3 -->|compression_profile| P2
|
||||
|
||||
S1 -->|prompt_template| PR1
|
||||
P1 -->|model lookup| PR1
|
||||
|
||||
style T1 fill:#e1f5ff
|
||||
style T2 fill:#e1f5ff
|
||||
style T3 fill:#e1f5ff
|
||||
style D1 fill:#fff4e1
|
||||
style D2 fill:#fff4e1
|
||||
style D3 fill:#fff4e1
|
||||
style S1 fill:#ffe1f5
|
||||
style P1 fill:#e1ffe1
|
||||
style P2 fill:#e1ffe1
|
||||
style P3 fill:#e1ffe1
|
||||
style PR1 fill:#f5e1ff
|
||||
```
|
||||
|
||||
### 7.2 Verbindungs-Matrix
|
||||
|
||||
| Von | Zu | Verbindung | Beschreibung |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **`types.yaml`** | **`decision_engine.yaml`** | `filter_types` | Streams filtern Notizen basierend auf Typen aus `types.yaml`. Die Liste `filter_types: ["value", "principle", "belief"]` muss exakt den Typ-Namen aus `types.yaml` entsprechen. |
|
||||
| **`types.yaml`** | **`decision_engine.yaml`** | `detection_keywords` | Keywords aus `types.yaml` werden für den Interview-Modus verwendet (z.B. "Projekt" + "neu" → `INTERVIEW`). |
|
||||
| **`decision_engine.yaml`** | **`llm_profiles.yaml`** | `router_profile` | Intent-Erkennung nutzt das Profil `compression_fast` für schnelle Klassifizierung. |
|
||||
| **`decision_engine.yaml`** | **`llm_profiles.yaml`** | `llm_profile` (Stream) | Jeder Stream definiert sein eigenes Profil für Retrieval und Kompression (z.B. `identity_safe` für Privacy). |
|
||||
| **`decision_engine.yaml`** | **`llm_profiles.yaml`** | `llm_profile` (Strategie) | Die finale Synthese nutzt das Strategie-Profil (z.B. `synthesis_pro` für DECISION). |
|
||||
| **`decision_engine.yaml`** | **`llm_profiles.yaml`** | `compression_profile` | Überlange Streams werden via `compression_profile` verdichtet (z.B. `compression_fast`). |
|
||||
| **`decision_engine.yaml`** | **`prompts.yaml`** | `prompt_template` | Strategien referenzieren Template-Keys (z.B. `decision_synthesis_v1`). |
|
||||
| **`llm_profiles.yaml`** | **`prompts.yaml`** | Hierarchische Auflösung | Das aktive Modell aus dem Profil bestimmt, welcher Prompt-Level geladen wird (Model-ID → Provider → Default). |
|
||||
| **`llm_profiles.yaml`** | **`llm_profiles.yaml`** | `fallback_profile` | Rekursive Fallback-Kaskade bei Fehlern (z.B. `synthesis_pro` → `synthesis_backup` → `identity_safe`). |
|
||||
|
||||
### 7.3 Praxisbeispiel: DECISION-Anfrage
|
||||
|
||||
**User-Anfrage:** `"Soll ich das neue Projekt starten?"`
|
||||
|
||||
#### Schritt 1: Intent-Erkennung
|
||||
|
||||
**Datei:** `decision_engine.yaml`
|
||||
```yaml
|
||||
settings:
|
||||
router_profile: "compression_fast" # → llm_profiles.yaml
|
||||
router_prompt_key: "intent_router_v1" # → prompts.yaml
|
||||
```
|
||||
|
||||
**Ablauf:**
|
||||
1. System prüft `trigger_keywords` in `DECISION` Strategie → findet `"soll ich"` → **Intent: DECISION**
|
||||
2. Falls kein Keyword-Match: LLM-Router nutzt `compression_fast` Profil aus `llm_profiles.yaml`
|
||||
3. Router lädt `intent_router_v1` aus `prompts.yaml` (hierarchisch basierend auf aktivem Modell)
|
||||
|
||||
#### Schritt 2: Stream-Aktivierung
|
||||
|
||||
**Datei:** `decision_engine.yaml`
|
||||
```yaml
|
||||
strategies:
|
||||
DECISION:
|
||||
use_streams: ["values_stream", "facts_stream", "risk_stream"]
|
||||
llm_profile: "synthesis_pro" # → llm_profiles.yaml
|
||||
prompt_template: "decision_synthesis_v1" # → prompts.yaml
|
||||
```
|
||||
|
||||
**Ablauf:**
|
||||
1. System aktiviert drei parallele Streams: `values_stream`, `facts_stream`, `risk_stream`
|
||||
|
||||
#### Schritt 3: Stream-Konfiguration & Typ-Filterung
|
||||
|
||||
**Datei:** `decision_engine.yaml` (Streams) + `types.yaml` (Typ-Definitionen)
|
||||
|
||||
```yaml
|
||||
# decision_engine.yaml
|
||||
values_stream:
|
||||
filter_types: ["value", "principle", "belief", "trait", "boundary", "need", "motivation"]
|
||||
llm_profile: "identity_safe" # → llm_profiles.yaml
|
||||
compression_profile: "identity_safe" # → llm_profiles.yaml
|
||||
query_template: "Welche meiner Werte und Prinzipien betreffen: {query}"
|
||||
|
||||
facts_stream:
|
||||
filter_types: ["project", "decision", "task", "goal", "event", "state"]
|
||||
llm_profile: "synthesis_pro" # → llm_profiles.yaml
|
||||
compression_profile: "compression_fast" # → llm_profiles.yaml
|
||||
query_template: "Status, Ressourcen und Fakten zu: {query}"
|
||||
|
||||
risk_stream:
|
||||
filter_types: ["risk", "obstacle", "bias"]
|
||||
llm_profile: "synthesis_pro" # → llm_profiles.yaml
|
||||
compression_profile: "compression_fast" # → llm_profiles.yaml
|
||||
query_template: "Gefahren, Hindernisse oder Risiken bei: {query}"
|
||||
```
|
||||
|
||||
**Ablauf:**
|
||||
1. **Values Stream:** Sucht in Qdrant nach Notizen mit `type IN ["value", "principle", "belief", ...]` (definiert in `types.yaml`)
|
||||
2. **Facts Stream:** Sucht nach Notizen mit `type IN ["project", "decision", "task", ...]` (definiert in `types.yaml`)
|
||||
3. **Risk Stream:** Sucht nach Notizen mit `type IN ["risk", "obstacle", "bias"]` (definiert in `types.yaml`)
|
||||
|
||||
#### Schritt 4: Profil-Auflösung & Modell-Auswahl
|
||||
|
||||
**Datei:** `llm_profiles.yaml`
|
||||
|
||||
```yaml
|
||||
synthesis_pro:
|
||||
provider: "openrouter"
|
||||
model: "google/gemini-2.0-flash-exp:free"
|
||||
temperature: 0.7
|
||||
fallback_profile: "synthesis_backup" # → Rekursiver Fallback
|
||||
|
||||
compression_fast:
|
||||
provider: "openrouter"
|
||||
model: "mistralai/mistral-7b-instruct:free"
|
||||
temperature: 0.1
|
||||
fallback_profile: "identity_safe"
|
||||
|
||||
identity_safe:
|
||||
provider: "ollama"
|
||||
model: "phi3:mini"
|
||||
temperature: 0.2
|
||||
fallback_profile: null # Terminaler Endpunkt
|
||||
```
|
||||
|
||||
**Ablauf:**
|
||||
1. **Values Stream:** Nutzt `identity_safe` → Ollama/phi3:mini (lokal, Privacy)
|
||||
2. **Facts Stream:** Nutzt `synthesis_pro` → OpenRouter/Gemini 2.0 (Cloud)
|
||||
3. **Risk Stream:** Nutzt `synthesis_pro` → OpenRouter/Gemini 2.0 (Cloud)
|
||||
4. **Kompression:** Falls Stream > `compression_threshold`, nutzt `compression_fast` → OpenRouter/Mistral 7B
|
||||
|
||||
#### Schritt 5: Prompt-Loading (Hierarchische Auflösung)
|
||||
|
||||
**Datei:** `prompts.yaml`
|
||||
|
||||
```yaml
|
||||
decision_synthesis_v1:
|
||||
# Level 1: Modell-spezifisch (höchste Priorität)
|
||||
"google/gemini-2.0-flash-exp:free": |
|
||||
Agiere als strategischer Partner für: {query}
|
||||
WERTE: {values_stream} | FAKTEN: {facts_stream} | RISIKEN: {risk_stream}
|
||||
Prüfe die Fakten gegen meine Werte. Zeige Zielkonflikte auf. Gib eine klare Empfehlung.
|
||||
|
||||
# Level 2: Provider-Fallback
|
||||
openrouter: |
|
||||
Strategische Multi-Stream Analyse für: {query}
|
||||
Werte-Basis: {values_stream} | Fakten: {facts_stream} | Risiken: {risk_stream}
|
||||
Bitte wäge ab und gib eine Empfehlung.
|
||||
|
||||
# Level 3: Global Default
|
||||
default: "Prüfe {query} gegen Werte {values_stream} und Fakten {facts_stream}."
|
||||
```
|
||||
|
||||
**Ablauf:**
|
||||
1. System hat `synthesis_pro` Profil geladen → Modell: `google/gemini-2.0-flash-exp:free`
|
||||
2. System sucht in `prompts.yaml` nach `decision_synthesis_v1`:
|
||||
- **Level 1:** Findet exakten Match für `google/gemini-2.0-flash-exp:free` → **Verwendet diesen Prompt**
|
||||
- Falls nicht gefunden: **Level 2** → `openrouter` Fallback
|
||||
- Falls nicht gefunden: **Level 3** → `default` Fallback
|
||||
3. Prompt wird mit Stream-Variablen formatiert: `{values_stream}`, `{facts_stream}`, `{risk_stream}`, `{query}`
|
||||
|
||||
#### Schritt 6: Finale Synthese
|
||||
|
||||
**Ablauf:**
|
||||
1. System ruft LLM auf mit:
|
||||
- **Profil:** `synthesis_pro` (OpenRouter/Gemini 2.0, Temperature 0.7)
|
||||
- **Prompt:** Level-1 Template aus `prompts.yaml` (modell-spezifisch optimiert)
|
||||
- **Variablen:** Formatierte Stream-Inhalte
|
||||
2. Falls Fehler (z.B. Rate-Limit 429):
|
||||
- **Fallback:** `synthesis_backup` (Llama 3.3)
|
||||
- **Prompt:** Automatisch Level-2 (`openrouter`) oder Level-3 (`default`) geladen
|
||||
3. Antwort wird an User zurückgegeben
|
||||
|
||||
### 7.4 Konfigurations-Synchronisation Checkliste
|
||||
|
||||
Beim Ändern einer Konfigurationsdatei müssen folgende Abhängigkeiten geprüft werden:
|
||||
|
||||
**✅ `types.yaml` ändern:**
|
||||
- [ ] Prüfe, ob `filter_types` in `decision_engine.yaml` Streams noch gültig sind
|
||||
- [ ] Prüfe, ob `detection_keywords` für Interview-Modus noch passen
|
||||
- [ ] Prüfe, ob `chunking_profile` noch existiert (in `types.yaml` definiert)
|
||||
|
||||
**✅ `decision_engine.yaml` ändern:**
|
||||
- [ ] Prüfe, ob alle `filter_types` in Streams existieren in `types.yaml`
|
||||
- [ ] Prüfe, ob alle `llm_profile` / `compression_profile` existieren in `llm_profiles.yaml`
|
||||
- [ ] Prüfe, ob alle `prompt_template` Keys existieren in `prompts.yaml`
|
||||
|
||||
**✅ `llm_profiles.yaml` ändern:**
|
||||
- [ ] Prüfe, ob `fallback_profile` Referenzen zirkulär sind (Schutz: `visited_profiles`)
|
||||
- [ ] Prüfe, ob alle referenzierten Profile existieren
|
||||
- [ ] Prüfe, ob Modell-IDs mit `prompts.yaml` Level-1 Keys übereinstimmen (optional, aber empfohlen)
|
||||
|
||||
**✅ `prompts.yaml` ändern:**
|
||||
- [ ] Prüfe, ob alle `prompt_template` Keys aus `decision_engine.yaml` existieren
|
||||
- [ ] Prüfe, ob Modell-spezifische Keys (Level 1) mit `llm_profiles.yaml` Modell-IDs übereinstimmen
|
||||
- [ ] Prüfe, ob alle Stream-Variablen (`{values_stream}`, `{facts_stream}`, etc.) initialisiert werden
|
||||
|
||||
### 7.5 Debugging-Tipps
|
||||
|
||||
**Problem:** Stream findet keine Notizen
|
||||
- **Prüfung:** `filter_types` in Stream stimmt mit Typ-Namen in `types.yaml` überein? (Case-sensitive!)
|
||||
- **Prüfung:** Existieren Notizen mit diesen Typen im Vault?
|
||||
|
||||
**Problem:** Falsches Modell wird verwendet
|
||||
- **Prüfung:** `llm_profile` in Stream/Strategie existiert in `llm_profiles.yaml`?
|
||||
- **Prüfung:** `fallback_profile` Kaskade führt zu unerwartetem Modell?
|
||||
|
||||
**Problem:** Prompt wird nicht gefunden
|
||||
- **Prüfung:** `prompt_template` Key existiert in `prompts.yaml`?
|
||||
- **Prüfung:** Hierarchische Auflösung (Level 1 → 2 → 3) funktioniert? (Logs: `[PROMPT-TRACE]`)
|
||||
|
||||
**Problem:** Kompression wird nicht ausgelöst
|
||||
- **Prüfung:** `compression_threshold` in Stream-Konfiguration gesetzt?
|
||||
- **Prüfung:** `compression_profile` existiert in `llm_profiles.yaml`?
|
||||
|
||||
---
|
||||
|
||||
Auszug aus der decision_engine.yaml
|
||||
```yaml
|
||||
strategies:
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
doc_type: technical_reference
|
||||
audience: developer, devops
|
||||
scope: backend, ingestion, smart_edges, edge_registry, modularization, moe
|
||||
scope: backend, ingestion, smart_edges, edge_registry, modularization, moe, lazy_prompts
|
||||
status: active
|
||||
version: 2.14.0
|
||||
context: "Detaillierte technische Beschreibung der Import-Pipeline, Two-Pass-Workflow (WP-15b), modularer Datenbank-Architektur (WP-14) und WP-25a profilgesteuerte Validierung. Integriert Mistral-safe Parsing und Deep Fallback."
|
||||
context: "Detaillierte technische Beschreibung der Import-Pipeline, Two-Pass-Workflow (WP-15b), modularer Datenbank-Architektur (WP-14), WP-25a profilgesteuerte Validierung und WP-25b Lazy-Prompt-Orchestration. Integriert Mistral-safe Parsing und Deep Fallback."
|
||||
---
|
||||
|
||||
# Ingestion Pipeline & Smart Processing
|
||||
@@ -50,10 +50,15 @@ Der Prozess ist **asynchron**, **idempotent** und wird nun in zwei logische Durc
|
||||
* Bei Änderungen löscht `purge_artifacts()` via `app.core.ingestion.ingestion_db` alle alten Chunks und Edges der Note.
|
||||
* Die Namensauflösung erfolgt nun über das modularisierte `database`-Paket.
|
||||
10. **Chunking anwenden:** Zerlegung des Textes basierend auf dem ermittelten Profil (siehe Kap. 3).
|
||||
11. **Smart Edge Allocation & Semantic Validation (WP-15b / WP-25a):**
|
||||
11. **Smart Edge Allocation & Semantic Validation (WP-15b / WP-25a / WP-25b):**
|
||||
* Der `SemanticAnalyzer` schlägt Kanten-Kandidaten vor.
|
||||
* **Validierung (WP-25a):** Jeder Kandidat wird durch das LLM semantisch gegen das Ziel im **LocalBatchCache** geprüft.
|
||||
* **Validierung (WP-25a/25b):** Jeder Kandidat wird durch das LLM semantisch gegen das Ziel im **LocalBatchCache** geprüft.
|
||||
* **Profilgesteuerte Validierung:** Nutzt das MoE-Profil `ingest_validator` (Temperature 0.0 für maximale Determinismus).
|
||||
* **Lazy-Prompt-Loading (WP-25b):** Nutzt `prompt_key="edge_validation"` mit `variables` statt vorformatierter Strings.
|
||||
* **Hierarchische Resolution:** Level 1 (Modell-ID) → Level 2 (Provider) → Level 3 (Default)
|
||||
* **Differenzierte Fehlerbehandlung (WP-25b):** Unterscheidung zwischen transienten (Netzwerk) und permanenten (Config) Fehlern:
|
||||
* **Transiente Fehler:** Timeout, Connection, Network → Kante wird erlaubt (Datenverlust vermeiden)
|
||||
* **Permanente Fehler:** Config, Validation, Invalid Response → Kante wird abgelehnt (Graph-Qualität schützen)
|
||||
* **Fallback-Kaskade:** Bei Fehlern erfolgt automatischer Fallback via `fallback_profile` (z.B. `compression_fast` → `identity_safe`).
|
||||
* **Traffic Control:** Nutzung der neutralen `clean_llm_text` Funktion zur Bereinigung von Steuerzeichen (<s>, [OUT]).
|
||||
* **Deep Fallback (v2.11.14):** Erkennt "Silent Refusals". Liefert die Cloud keine verwertbaren Kanten, wird ein lokaler Fallback via Ollama erzwungen.
|
||||
|
||||
Reference in new issue
Block a user