# 🔍 Diagnostic - Workflows et Performance FAISS **Date**: 8 janvier 2026 - 00:15 **ProblĂšmes rapportĂ©s par l'utilisateur** : 1. ❌ Workflows : 8 sessions traitĂ©es mais seulement 2 workflows (dĂ©mo) visibles 2. ❌ Performance : Onglet affiche 0 pour FAISS, embeddings, temps moyen --- ## 🎯 ProblĂšme 1 - FAISS Non InitialisĂ© (Performance Ă  0) ### Cause Racine **Fichier** : `/opt/rpa_vision_v3/server/processing_pipeline.py` **Ligne** : 86 **Code actuel** (incorrect) : ```python self.faiss = FAISSManager(dimension=512) # ← dimension au singulier ``` **Code attendu** par FAISSManager : ```python def __init__(self, dimensions: int, # ← dimensions au pluriel index_type: str = "Flat", metric: str = "cosine", ...): ``` ### Erreur dans les Logs ``` 2026-01-07 22:09:17 [WARNING] processing_pipeline: Erreur init embeddings: FAISSManager.__init__() got an unexpected keyword argument 'dimension' ``` ### Impact 1. L'initialisation de FAISSManager Ă©choue 2. `self.embeddings_available` devient `False` 3. La mĂ©thode `_generate_embeddings()` est sautĂ©e 4. Aucun embedding n'est gĂ©nĂ©rĂ© ni indexĂ© dans FAISS 5. Le dashboard affiche 0 partout dans "Performance" ### Solution Corriger la typo : ```python # AVANT self.faiss = FAISSManager(dimension=512) # APRÈS self.faiss = FAISSManager(dimensions=512) ``` **ComplexitĂ©** : Triviale (1 caractĂšre Ă  ajouter) **Impact** : Les futures sessions auront leurs embeddings gĂ©nĂ©rĂ©s et indexĂ©s --- ## 🎯 ProblĂšme 2 - Workflows Non SauvegardĂ©s ### Cause Racine **Fichier** : `/opt/rpa_vision_v3/core/graph/graph_builder.py` **Lignes** : 539-545 **ProblĂšme** : IncompatibilitĂ© entre GraphBuilder et la nouvelle dĂ©finition de ScreenTemplate #### Code GraphBuilder (ancien, incompatible) ```python def _build_screen_template(self, states, prototype_embedding): return ScreenTemplate( embedding_prototype=prototype_embedding.tolist(), # ← N'existe plus similarity_threshold=0.85, # ← N'existe plus window_title_pattern=None, # ← N'existe plus required_text_patterns=[], # ← N'existe plus required_ui_elements=[], # ← N'existe plus ) ``` #### DĂ©finition Actuelle de ScreenTemplate ```python @dataclass class ScreenTemplate: window: WindowConstraint # ← Nouveau text: TextConstraint # ← Nouveau ui: UIConstraint # ← Nouveau embedding: EmbeddingPrototype # ← Nouveau (pas embedding_prototype) ``` #### DĂ©finition de EmbeddingPrototype ```python @dataclass class EmbeddingPrototype: provider: str # e.g., "openclip_ViT-B-32" vector_id: str # Chemin vers .npy du prototype min_cosine_similarity: float # Seuil de similaritĂ© sample_count: int # Nombre d'Ă©chantillons utilisĂ©s ``` ### Erreurs dans les Logs ``` 2026-01-07 22:09:41 [ERROR] processing_pipeline: Erreur construction workflow: ScreenTemplate.__init__() got an unexpected keyword argument 'embedding_prototype' ``` ``` 2026-01-07 22:03:03 [ERROR] processing_pipeline: Erreur construction workflow: 'str' object does not support item assignment ``` ### Impact 1. GraphBuilder tente de construire un workflow 2. Échoue Ă  la crĂ©ation du ScreenTemplate (incompatibilitĂ© API) 3. `workflow_created` reste Ă  `False` 4. Aucun fichier workflow n'est sauvegardĂ© 5. L'utilisateur ne voit que les 2 workflows dĂ©mo du 2 janvier ### Solution Réécrire `_build_screen_template()` pour utiliser la nouvelle API : ```python def _build_screen_template(self, states, prototype_embedding, cluster_id): """ Construire ScreenTemplate compatible avec nouvelle API """ # Sauvegarder le prototype embedding prototype_path = f"data/training/prototypes/cluster_{cluster_id}.npy" np.save(prototype_path, prototype_embedding) # CrĂ©er EmbeddingPrototype embedding_proto = EmbeddingPrototype( provider="openclip_ViT-B-32", vector_id=prototype_path, min_cosine_similarity=0.85, sample_count=len(states) ) # Extraire contraintes depuis les Ă©tats du cluster # TODO: Analyser les states pour extraire window_title, textes, etc. # CrĂ©er les contraintes (basiques pour l'instant) window_constraint = WindowConstraint( title_contains=None, # TODO: Extraire du cluster process_name=None ) text_constraint = TextConstraint( required_texts=[], # TODO: Extraire patterns communs forbidden_texts=[] ) ui_constraint = UIConstraint( required_roles=[], required_types=[], min_element_count=0 ) # CrĂ©er ScreenTemplate avec nouvelle API return ScreenTemplate( window=window_constraint, text=text_constraint, ui=ui_constraint, embedding=embedding_proto ) ``` **ComplexitĂ©** : Moyenne (refactoring complet de la mĂ©thode) **Impact** : Les futures sessions pourront crĂ©er de vrais workflows --- ## 📊 État Actuel du SystĂšme ### Workflows ```bash ls /opt/rpa_vision_v3/data/training/workflows/ # Output: demo_calculator.json demo_notepad.json ``` - ✅ 2 workflows dĂ©mo (créés le 2 janvier) - ❌ 0 workflows rĂ©els (GraphBuilder Ă©choue) ### Embeddings/FAISS ```bash ls /opt/rpa_vision_v3/data/training/embeddings/ # Output: (vide) ls /opt/rpa_vision_v3/data/training/faiss_index/ # Output: (vide) ``` - ❌ Aucun embedding gĂ©nĂ©rĂ© (FAISS non initialisĂ©) - ❌ Aucun index FAISS créé ### Screen States (OK) ```bash find /opt/rpa_vision_v3/data/training/screen_states -name "*.json" | wc -l # Output: 371 ``` - ✅ 371 screen states créés et sauvegardĂ©s --- ## 🔧 Plan de Correction ### Option 1 - Correction FAISS Seulement (RAPIDE) **Temps estimĂ©** : 5 minutes **ComplexitĂ©** : Triviale **Actions** : 1. Corriger typo `dimension` → `dimensions` dans processing_pipeline.py 2. RedĂ©marrer le worker 3. Capturer une nouvelle session de test 4. VĂ©rifier que les embeddings sont gĂ©nĂ©rĂ©s **RĂ©sultat** : - ✅ Performance FAISS affichera le nombre rĂ©el d'embeddings - ✅ Recherche par similaritĂ© fonctionnelle - ❌ Workflows toujours non créés (nĂ©cessite Option 2) --- ### Option 2 - Correction FAISS + Workflows (COMPLET) **Temps estimĂ©** : 30-45 minutes **ComplexitĂ©** : Moyenne **Actions** : 1. Corriger typo FAISS (comme Option 1) 2. Réécrire `_build_screen_template()` dans graph_builder.py 3. CrĂ©er dossier pour prototypes : `data/training/prototypes/` 4. RedĂ©marrer le worker 5. Capturer une nouvelle session de test 6. VĂ©rifier crĂ©ation du workflow **RĂ©sultat** : - ✅ Performance FAISS fonctionnelle - ✅ Workflows rĂ©els créés et visibles - ✅ SystĂšme complet et production-ready --- ### Option 3 - Reprocesser les Sessions Existantes (BONUS) **PrĂ©requis** : Option 1 ou 2 complĂ©tĂ©e **Temps estimĂ©** : 5 minutes + temps de traitement (dĂ©pend du volume) **Actions** : 1. Relancer le processing_pipeline sur les 8 sessions dĂ©jĂ  capturĂ©es 2. Les screen_states existent dĂ©jĂ , seuls embeddings/workflows seront gĂ©nĂ©rĂ©s **Commande** : ```bash for session_id in sess_20260107T*; do python3 /opt/rpa_vision_v3/server/processing_pipeline.py $session_id done ``` **RĂ©sultat** : - ✅ 371 embeddings gĂ©nĂ©rĂ©s rĂ©troactivement - ✅ 8 workflows créés depuis les sessions existantes - ✅ Dashboard complet sans recapturer de nouvelles sessions --- ## 🎯 Recommandation ### Pour DĂ©mo Imminente **Option 1** (FAISS seulement) + capturer 1-2 nouvelles sessions - Rapide (10 minutes total) - Affiche des vraies mĂ©triques Performance - Workflows restent en dĂ©mo mais c'est acceptable ### Pour Production-Ready **Option 2** (FAISS + Workflows) + **Option 3** (Reprocessing) - Complet (45-60 minutes) - Tous les bugs corrigĂ©s - 371 embeddings + 8 workflows rĂ©els - SystĂšme entiĂšrement fonctionnel --- ## 📝 Fichiers Ă  Modifier ### Correction FAISS ``` /opt/rpa_vision_v3/server/processing_pipeline.py Ligne 86 : dimension=512 → dimensions=512 ``` ### Correction Workflows ``` /opt/rpa_vision_v3/core/graph/graph_builder.py Lignes 539-545 : Réécrire _build_screen_template() ``` --- ## ✅ CritĂšres de SuccĂšs ### AprĂšs Option 1 (FAISS) - [ ] Logs montrent "Embeddings gĂ©nĂ©rĂ©s: X" (X > 0) - [ ] Fichiers .npy créés dans `data/training/embeddings/` - [ ] Index FAISS créé dans `data/training/faiss_index/` - [ ] Dashboard Performance affiche nombre > 0 ### AprĂšs Option 2 (Workflows) - [ ] Logs montrent "Workflow créé: True" - [ ] Fichiers .json créés dans `data/training/workflows/` - [ ] Dashboard Workflows affiche > 2 workflows - [ ] Aucune erreur "ScreenTemplate.__init__()" --- ## 💡 Notes Techniques ### Pourquoi le Code Est Incompatible ? Le projet a subi un **refactoring architectural majeur** entre : - **Version initiale** : ScreenTemplate avec champs simples (embedding_prototype, similarity_threshold) - **Version actuelle** : ScreenTemplate avec objets complexes (WindowConstraint, EmbeddingPrototype) Le GraphBuilder n'a **pas Ă©tĂ© mis Ă  jour** lors de ce refactoring. ### Impact sur les DonnĂ©es Existantes - ✅ Screen States : Format stable, pas d'impact - ❌ Embeddings : Jamais gĂ©nĂ©rĂ©s, pas d'impact (rien Ă  migrer) - ❌ Workflows : Jamais créés, pas d'impact (rien Ă  migrer) --- **Que veux-tu faire ?** 1. Option 1 (rapide, FAISS seulement) 2. Option 2 (complet, FAISS + Workflows) 3. Autre approche ?