78 lines
2.9 KiB
Markdown
78 lines
2.9 KiB
Markdown
# Module Structure - serviceAi
|
|
|
|
## Übersicht
|
|
|
|
Das `mainServiceAi.py` Modul wurde in mehrere Submodule aufgeteilt, um die Übersichtlichkeit zu verbessern.
|
|
|
|
## Modulstruktur
|
|
|
|
### Hauptmodul
|
|
- **mainServiceAi.py** (~800 Zeilen)
|
|
- Initialisierung (`__init__`, `create`, `ensureAiObjectsInitialized`)
|
|
- Public API (`callAiPlanning`, `callAiContent`)
|
|
- Routing zu Submodulen
|
|
- Helper-Methoden
|
|
|
|
### Submodule
|
|
|
|
1. **subJsonResponseHandling.py** (bereits vorhanden)
|
|
- JSON Response Merging
|
|
- Section Merging
|
|
- Fragment Detection
|
|
|
|
2. **subResponseParsing.py** (~200 Zeilen)
|
|
- `ResponseParser.extractSectionsFromResponse()` - Extrahiert Sections aus AI-Responses
|
|
- `ResponseParser.shouldContinueGeneration()` - Entscheidet ob Generation fortgesetzt werden soll
|
|
- `ResponseParser._isStuckInLoop()` - Loop-Detection
|
|
- `ResponseParser.extractDocumentMetadata()` - Extrahiert Metadaten
|
|
- `ResponseParser.buildFinalResultFromSections()` - Baut finales JSON
|
|
|
|
3. **subDocumentIntents.py** (~300 Zeilen)
|
|
- `DocumentIntentAnalyzer.clarifyDocumentIntents()` - Analysiert Dokument-Intents
|
|
- `DocumentIntentAnalyzer.resolvePreExtractedDocument()` - Löst pre-extracted Dokumente auf
|
|
- `DocumentIntentAnalyzer._buildIntentAnalysisPrompt()` - Baut Intent-Analyse-Prompt
|
|
|
|
4. **subContentExtraction.py** (~600 Zeilen)
|
|
- `ContentExtractor.extractAndPrepareContent()` - Extrahiert und bereitet Content vor
|
|
- `ContentExtractor.extractTextFromImage()` - Vision AI für Bilder
|
|
- `ContentExtractor.processTextContentWithAi()` - AI-Verarbeitung von Text
|
|
- `ContentExtractor._isBinary()` - Helper für Binary-Check
|
|
|
|
5. **subStructureGeneration.py** (~200 Zeilen)
|
|
- `StructureGenerator.generateStructure()` - Generiert Dokument-Struktur
|
|
- `StructureGenerator._buildStructurePrompt()` - Baut Struktur-Prompt
|
|
|
|
6. **subStructureFilling.py** (~400 Zeilen)
|
|
- `StructureFiller.fillStructure()` - Füllt Struktur mit Content
|
|
- `StructureFiller._buildSectionGenerationPrompt()` - Baut Section-Generation-Prompt
|
|
- `StructureFiller._findContentPartById()` - Helper für ContentPart-Suche
|
|
- `StructureFiller._needsAggregation()` - Entscheidet ob Aggregation nötig
|
|
|
|
7. **subAiCallLooping.py** (~400 Zeilen)
|
|
- `AiCallLooper.callAiWithLooping()` - Haupt-Looping-Logik
|
|
- `AiCallLooper._defineKpisFromPrompt()` - KPI-Definition
|
|
|
|
## Verwendung
|
|
|
|
Alle Submodule werden über das Hauptmodul `AiService` verwendet:
|
|
|
|
```python
|
|
# Initialisierung
|
|
aiService = await AiService.create(serviceCenter)
|
|
|
|
# Submodule werden automatisch initialisiert
|
|
# aiService.responseParser
|
|
# aiService.intentAnalyzer
|
|
# aiService.contentExtractor
|
|
# etc.
|
|
```
|
|
|
|
## Migration
|
|
|
|
Die öffentliche API bleibt unverändert. Interne Methoden wurden in Submodule verschoben:
|
|
|
|
- `_extractSectionsFromResponse` → `responseParser.extractSectionsFromResponse`
|
|
- `_clarifyDocumentIntents` → `intentAnalyzer.clarifyDocumentIntents`
|
|
- `_extractAndPrepareContent` → `contentExtractor.extractAndPrepareContent`
|
|
- etc.
|
|
|