# AGENT CONVERSATIONNEL RPA VISION V3 ## Vision & Architecture **Date**: 14 janvier 2026 **Statut**: Document de conception **Objectif**: Piloter le systรจme RPA par langage naturel --- ## 1. CONCEPT Permettre aux utilisateurs de commander le systรจme RPA en langage naturel : ``` ๐Ÿ‘ค "Envoie les factures impayรฉes de plus de 30 jours aux clients concernรฉs" ๐Ÿค– Agent โ†’ Comprend l'intention โ†’ Trouve les workflows pertinents โ†’ Extrait les paramรจtres (30 jours) โ†’ Demande confirmation โ†’ Exรฉcute et rapporte le rรฉsultat ``` --- ## 2. CE QUI EXISTE Dร‰Jร€ ### 2.1 Interface de Commande | Composant | Fichier | Description | |-----------|---------|-------------| | **Command Interface** | `command_interface/app.py` | Interface web style Spotlight avec WebSocket | | **CLI** | `cli.py` | Ligne de commande (status, record, play, list) | | **Agent Tray** | `agent_v0/tray_ui.py` | Application systรจme tray | ### 2.2 Matching Sรฉmantique (Dร‰Jร€ IMPLร‰MENTร‰) **Fichier**: `core/workflow/semantic_matcher.py` ```python class SemanticMatcher: def find_workflow(self, user_query: str) -> WorkflowMatch: """ Trouve le workflow correspondant ร  une requรชte naturelle. Retourne: - workflow_id, workflow_name - confidence score - extracted_params (paramรจtres extraits de la phrase) - match_reason """ ``` **Fonctionnalitรฉs**: - Matching par embeddings sรฉmantiques - Matching par mots-clรฉs et tags - Extraction automatique de paramรจtres - Support multi-langue (FR/EN) **Exemple**: ```python matcher = SemanticMatcher("data/workflows") result = matcher.find_workflow("facturer le client Acme") # โ†’ workflow: "facturation_client" # โ†’ params: {client: "Acme"} # โ†’ confidence: 0.87 ``` ### 2.3 Intรฉgration LLM/Ollama (Dร‰Jร€ IMPLร‰MENTร‰) **Fichier**: `core/gpu/ollama_manager.py` ```python class OllamaManager: def __init__(self, model="qwen3-vl:8b"): self.endpoint = "http://localhost:11434" def load_model(self) -> bool def unload_model(self) -> bool def is_available() -> bool ``` ### 2.4 Exรฉcution de Workflows (Dร‰Jร€ IMPLร‰MENTร‰) | Composant | Fichier | Rรดle | |-----------|---------|------| | **ActionExecutor** | `core/execution/action_executor.py` | Exรฉcute les actions individuelles | | **WorkflowChainer** | `core/workflow/workflow_chainer.py` | Chaรฎne plusieurs workflows | | **WorkflowPipeline** | `core/pipeline/workflow_pipeline.py` | Orchestration complรจte | ### 2.5 Composition Avancรฉe (Dร‰Jร€ IMPLร‰MENTร‰) **Fichier**: `core/workflow/composition_models.py` - `ChainConfig` : Chaรฎnage de workflows - `LoopConfig` : Boucles paramรฉtrรฉes - `BranchConfig` : Branchements conditionnels - `TriggerConfig` : Dรฉclencheurs programmรฉs - `ExecutionContext` : Contexte d'exรฉcution ### 2.6 API REST (Dร‰Jร€ IMPLร‰MENTร‰) **Fichier**: `server/api_core.py` ``` POST /api/core/capture โ†’ Capture d'รฉcran POST /api/core/detect โ†’ Dรฉtection UI POST /api/core/embed โ†’ Gรฉnรฉration embeddings POST /api/core/match โ†’ Matching d'รฉcran ``` --- ## 3. ARCHITECTURE CIBLE ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ INTERFACES UTILISATEUR โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Chat Web โ”‚ CLI โ”‚ Vocal โ”‚ API REST โ”‚ Tray โ”‚ โ”‚ (React) โ”‚ (existant) โ”‚ (Whisper) โ”‚ (existant) โ”‚(existantโ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ AGENT CONVERSATIONNEL โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Intent โ”‚ โ”‚ Workflow โ”‚ โ”‚ Parameter โ”‚ โ”‚ โ”‚ โ”‚ Parser โ”‚ โ”‚ Matcher โ”‚ โ”‚ Extractor โ”‚ โ”‚ โ”‚ โ”‚ (LLM) โ”‚ โ”‚ (existant) โ”‚ โ”‚ (existant) โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Confirmation โ”‚ โ”‚ Context โ”‚ โ”‚ Response โ”‚ โ”‚ โ”‚ โ”‚ Loop โ”‚ โ”‚ Manager โ”‚ โ”‚ Generator โ”‚ โ”‚ โ”‚ โ”‚ (ร  faire) โ”‚ โ”‚ (existant) โ”‚ โ”‚ (LLM) โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ MOTEUR D'EXร‰CUTION โ”‚ โ”‚ (existant) โ”‚ โ”‚ โ”‚ โ”‚ ActionExecutor โ† WorkflowChainer โ† WorkflowPipeline โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` --- ## 4. COMPOSANTS ร€ Dร‰VELOPPER ### 4.1 Intent Parser (NOUVEAU) **Objectif**: Comprendre l'intention de l'utilisateur via LLM ```python class IntentParser: def __init__(self, ollama: OllamaManager): self.ollama = ollama def parse(self, user_input: str) -> Intent: """ Analyse l'entrรฉe utilisateur et retourne l'intention. Intents possibles: - EXECUTE_WORKFLOW: Exรฉcuter un workflow existant - LIST_WORKFLOWS: Lister les workflows disponibles - GET_STATUS: Obtenir le statut d'une exรฉcution - SCHEDULE_WORKFLOW: Planifier une exรฉcution - CHAIN_WORKFLOWS: Enchaรฎner plusieurs workflows - HELP: Demander de l'aide - CANCEL: Annuler une action en cours """ prompt = f""" Analyse cette demande utilisateur et identifie l'intention. Demande: "{user_input}" Rรฉponds en JSON: {{ "intent": "EXECUTE_WORKFLOW|LIST_WORKFLOWS|...", "confidence": 0.0-1.0, "entities": {{...}} }} """ response = self.ollama.generate(prompt) return Intent.from_json(response) ``` ### 4.2 Confirmation Loop (NOUVEAU) **Objectif**: Demander confirmation avant actions critiques ```python class ConfirmationLoop: def __init__(self): self.critical_actions = ["delete", "send", "execute", "modify"] def needs_confirmation(self, workflow: Workflow, params: dict) -> bool: """Dรฉtermine si une confirmation est nรฉcessaire.""" # Actions critiques if any(action in workflow.name.lower() for action in self.critical_actions): return True # Beaucoup d'รฉlรฉments impactรฉs if params.get("count", 0) > 10: return True return False def generate_confirmation_message(self, workflow: Workflow, params: dict) -> str: """Gรฉnรจre le message de confirmation.""" return f""" Je vais exรฉcuter "{workflow.name}": - Paramรจtres: {params} - ร‰lรฉments impactรฉs: {params.get('count', 'inconnu')} Confirmes-tu ? (oui/non) """ ``` ### 4.3 Response Generator (NOUVEAU) **Objectif**: Gรฉnรฉrer des rรฉponses naturelles ```python class ResponseGenerator: def __init__(self, ollama: OllamaManager): self.ollama = ollama def generate(self, execution_result: ExecutionResult, context: dict) -> str: """Gรฉnรจre une rรฉponse naturelle ร  partir du rรฉsultat.""" if execution_result.status == "SUCCESS": return self._success_response(execution_result) elif execution_result.status == "FAILED": return self._error_response(execution_result) else: return self._pending_response(execution_result) def _success_response(self, result: ExecutionResult) -> str: # Utiliser le LLM pour gรฉnรฉrer une rรฉponse naturelle prompt = f""" Gรฉnรจre une rรฉponse courte et naturelle pour ce rรฉsultat: - Action: {result.action} - Statut: Succรจs - Dรฉtails: {result.details} Exemple: "C'est fait ! 23 factures ont รฉtรฉ envoyรฉes." """ return self.ollama.generate(prompt) ``` ### 4.4 Conversation Manager (NOUVEAU) **Objectif**: Gรฉrer le contexte de conversation multi-tours ```python class ConversationManager: def __init__(self): self.history: List[Message] = [] self.context: dict = {} self.pending_confirmation: Optional[PendingAction] = None def add_message(self, role: str, content: str): self.history.append(Message(role=role, content=content, timestamp=now())) def get_context_for_llm(self) -> str: """Retourne le contexte pour le LLM.""" recent = self.history[-10:] # 10 derniers messages return "\n".join([f"{m.role}: {m.content}" for m in recent]) def set_pending_confirmation(self, action: PendingAction): self.pending_confirmation = action def handle_confirmation_response(self, response: str) -> Optional[PendingAction]: if response.lower() in ["oui", "yes", "ok", "confirme"]: action = self.pending_confirmation self.pending_confirmation = None return action elif response.lower() in ["non", "no", "annule", "cancel"]: self.pending_confirmation = None return None ``` --- ## 5. FLUX DE CONVERSATION ### 5.1 Flux Standard ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ USER INPUT โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Intent Parser โ”‚ โ”€โ”€โ”€โ”€ "Quelle est l'intention ?" โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Workflow Matcherโ”‚ โ”€โ”€โ”€โ”€ "Quel workflow correspond ?" โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚Param Extractor โ”‚ โ”€โ”€โ”€โ”€ "Quels paramรจtres ?" โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Needs Confirm? โ”‚โ”€โ”€YESโ”€โ–ถโ”‚ Ask User โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ NO โ”‚ โ”‚ โ”‚ โ–ผ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Execute โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”‚ User Confirms โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚Response Generateโ”‚ โ”€โ”€โ”€โ”€ "Gรฉnรฉrer rรฉponse naturelle" โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ USER OUTPUT โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### 5.2 Exemple de Conversation ``` ๐Ÿ‘ค User: "Facture les clients du secteur santรฉ" ๐Ÿค– Agent: [IntentParser] โ†’ Intent: EXECUTE_WORKFLOW [WorkflowMatcher] โ†’ Match: "facturation_client" (confidence: 0.92) [ParamExtractor] โ†’ Params: {secteur: "santรฉ"} [ConfirmationLoop] โ†’ Needs confirmation: YES (action critique) ๐Ÿค– Agent: "J'ai trouvรฉ le workflow 'Facturation Client'. Je vais facturer tous les clients du secteur Santรฉ. 3 clients concernรฉs. Je lance ?" ๐Ÿ‘ค User: "Oui vas-y" ๐Ÿค– Agent: [ConversationManager] โ†’ Confirmation reรงue [ActionExecutor] โ†’ Execute workflow [ResponseGenerator] โ†’ Generate response ๐Ÿค– Agent: "C'est fait ! 3 factures gรฉnรฉrรฉes : - Hรดpital Saint-Louis : 12,450โ‚ฌ - Clinique du Parc : 8,200โ‚ฌ - Labo Mรฉdical Plus : 3,100โ‚ฌ Total : 23,750โ‚ฌ" ``` --- ## 6. INTร‰GRATION AVEC L'EXISTANT ### 6.1 Points d'Intรฉgration | Nouveau Composant | S'intรจgre avec | Comment | |-------------------|----------------|---------| | IntentParser | OllamaManager | Utilise le LLM pour parser | | ConversationManager | SemanticMatcher | Passe la query au matcher | | ConfirmationLoop | WorkflowChainer | Intercepte avant exรฉcution | | ResponseGenerator | ExecutionResult | Transforme rรฉsultat en texte | ### 6.2 Fichiers ร  Crรฉer ``` core/ โ””โ”€โ”€ agent/ โ”œโ”€โ”€ __init__.py โ”œโ”€โ”€ intent_parser.py # Nouveau โ”œโ”€โ”€ confirmation_loop.py # Nouveau โ”œโ”€โ”€ response_generator.py # Nouveau โ”œโ”€โ”€ conversation_manager.py # Nouveau โ””โ”€โ”€ conversational_agent.py # Nouveau (orchestrateur) ``` ### 6.3 Classe Principale ```python # core/agent/conversational_agent.py class ConversationalAgent: """Agent conversationnel pour piloter RPA Vision.""" def __init__(self): # Composants existants self.ollama = OllamaManager() self.matcher = SemanticMatcher("data/workflows") self.executor = ActionExecutor() self.chainer = WorkflowChainer() # Nouveaux composants self.intent_parser = IntentParser(self.ollama) self.confirmation = ConfirmationLoop() self.response_gen = ResponseGenerator(self.ollama) self.conversation = ConversationManager() async def process_message(self, user_input: str) -> str: """Traite un message utilisateur et retourne la rรฉponse.""" # 1. Ajouter au contexte self.conversation.add_message("user", user_input) # 2. Vรฉrifier si c'est une rรฉponse ร  une confirmation if self.conversation.pending_confirmation: return await self._handle_confirmation(user_input) # 3. Parser l'intention intent = self.intent_parser.parse(user_input) # 4. Router selon l'intention if intent.type == "EXECUTE_WORKFLOW": return await self._handle_execute(intent) elif intent.type == "LIST_WORKFLOWS": return await self._handle_list() elif intent.type == "HELP": return self._handle_help() else: return "Je n'ai pas compris. Peux-tu reformuler ?" async def _handle_execute(self, intent: Intent) -> str: # Trouver le workflow match = self.matcher.find_workflow(intent.query) if match.confidence < 0.5: return f"Je n'ai pas trouvรฉ de workflow correspondant ร  '{intent.query}'" # Vรฉrifier si confirmation nรฉcessaire if self.confirmation.needs_confirmation(match.workflow, match.params): self.conversation.set_pending_confirmation( PendingAction(workflow=match.workflow, params=match.params) ) return self.confirmation.generate_confirmation_message( match.workflow, match.params ) # Exรฉcuter directement result = await self.executor.execute(match.workflow, match.params) return self.response_gen.generate(result) ``` --- ## 7. INTERFACES UTILISATEUR ### 7.1 Chat Web (Extension de command_interface) ```javascript // Extension de command_interface/static/app.js const ChatInterface = { async sendMessage(text) { const response = await fetch('/api/agent/chat', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({message: text}) }); return response.json(); }, displayMessage(role, content) { const bubble = document.createElement('div'); bubble.className = `message ${role}`; bubble.textContent = content; chatContainer.appendChild(bubble); } }; ``` ### 7.2 CLI Conversationnel ```python # Extension de cli.py @click.command() def chat(): """Mode conversation avec l'agent.""" agent = ConversationalAgent() print("๐Ÿค– Agent RPA Vision prรชt. Tapez 'quit' pour quitter.") while True: user_input = input("\n๐Ÿ‘ค Vous: ") if user_input.lower() in ['quit', 'exit', 'q']: print("๐Ÿ‘‹ Au revoir !") break response = asyncio.run(agent.process_message(user_input)) print(f"\n๐Ÿค– Agent: {response}") ``` ### 7.3 API REST ```python # Nouveaux endpoints dans server/api_core.py @app.route('/api/agent/chat', methods=['POST']) def agent_chat(): """Endpoint pour conversation avec l'agent.""" data = request.json message = data.get('message', '') session_id = data.get('session_id', 'default') # Rรฉcupรฉrer ou crรฉer l'agent pour cette session agent = get_or_create_agent(session_id) # Traiter le message response = asyncio.run(agent.process_message(message)) return jsonify({ 'response': response, 'session_id': session_id }) ``` --- ## 8. FONCTIONNALITร‰S AVANCร‰ES (FUTUR) ### 8.1 Apprentissage des Habitudes ```python class HabitLearner: """Apprend les habitudes de l'utilisateur.""" def analyze_patterns(self) -> List[Suggestion]: """Analyse l'historique et suggรจre des automatisations.""" # "Tous les lundis ร  9h tu lances le rapport RH" # โ†’ Suggรฉrer de planifier automatiquement ``` ### 8.2 Composition Intelligente ```python class WorkflowComposer: """Compose des workflows ร  partir d'objectifs.""" def compose_from_goal(self, goal: str) -> List[Workflow]: """ Dรฉcompose un objectif en sรฉquence de workflows. Exemple: "Assure-toi que tous les clients sont facturรฉs" โ†’ 1. Lister clients non facturรฉs โ†’ 2. Gรฉnรฉrer factures โ†’ 3. Envoyer par email โ†’ 4. Mettre ร  jour le CRM """ ``` ### 8.3 Mode Vocal ```python class VoiceInterface: """Interface vocale avec Whisper.""" def listen(self) -> str: """ร‰coute et transcrit.""" audio = self.record_audio() return whisper.transcribe(audio) def speak(self, text: str): """Synthรจse vocale.""" tts.speak(text) ``` --- ## 9. PLAN D'IMPLร‰MENTATION ### Phase 1 : MVP Conversationnel (1-2 semaines) - [ ] Crรฉer `core/agent/` structure - [ ] Implรฉmenter `IntentParser` basique - [ ] Implรฉmenter `ConversationManager` - [ ] Connecter avec `SemanticMatcher` existant - [ ] Ajouter endpoint `/api/agent/chat` - [ ] Tester avec CLI ### Phase 2 : Confirmation & Rรฉponses (1 semaine) - [ ] Implรฉmenter `ConfirmationLoop` - [ ] Implรฉmenter `ResponseGenerator` - [ ] Intรฉgrer avec `WorkflowChainer` - [ ] Tests end-to-end ### Phase 3 : Interface Chat Web (1 semaine) - [ ] ร‰tendre `command_interface` avec chat - [ ] UI React pour conversation - [ ] Historique des conversations - [ ] WebSocket pour temps rรฉel ### Phase 4 : Fonctionnalitรฉs Avancรฉes (2-3 semaines) - [ ] Apprentissage des habitudes - [ ] Composition intelligente - [ ] Mode vocal (optionnel) - [ ] Multi-utilisateurs --- ## 10. Mร‰TRIQUES DE SUCCรˆS | Mรฉtrique | Objectif | Mesure | |----------|----------|--------| | Taux de comprรฉhension | >90% | Intents correctement parsรฉs | | Taux de matching | >85% | Workflows correctement trouvรฉs | | Temps de rรฉponse | <2s | Latence moyenne | | Satisfaction utilisateur | >4/5 | Feedback utilisateurs | | Taux d'exรฉcution rรฉussie | >95% | Workflows exรฉcutรฉs sans erreur | --- ## CONCLUSION L'agent conversationnel est une extension naturelle du systรจme RPA Vision V3. Grรขce aux composants dรฉjร  implรฉmentรฉs (SemanticMatcher, OllamaManager, ActionExecutor), le dรฉveloppement peut se concentrer sur : 1. **Intent Parser** : Comprendre les intentions 2. **Confirmation Loop** : Sรฉcuriser les actions critiques 3. **Response Generator** : Rรฉponses naturelles 4. **Conversation Manager** : Contexte multi-tours **Estimation totale** : 4-6 semaines pour un MVP fonctionnel. --- *Document de conception - ร€ implรฉmenter aprรจs les dรฉmos*