diff --git a/.gitignore b/.gitignore new file mode 100755 index 00000000..48283f0a --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# Fichiers d'environnement (contiennent des tokens/clés sensibles) +.env +# Fichiers de configuration générés +config.json +whitelist.json +bridges.json +config.db +malware.json + +# Cache Python +__pycache__/ +*.pyc +*.pyo +*.pyd + +# Environnements virtuels +venv/ +env/ +.venv/ + +# IDE +.vscode/ +.idea/ + +# Logs +*.Logs +*.log +.data diff --git a/ia/__pycache__/memoire.cpython-312.pyc b/ia/__pycache__/memoire.cpython-312.pyc index 6e453755..bf750cdf 100644 Binary files a/ia/__pycache__/memoire.cpython-312.pyc and b/ia/__pycache__/memoire.cpython-312.pyc differ diff --git a/memoires/Victoria's_Vice_𝐈𝐈_™_(Maintenance)/768915179995004988.json b/memoires/Victoria's_Vice_𝐈𝐈_™_(Maintenance)/768915179995004988.json new file mode 100644 index 00000000..667d9421 --- /dev/null +++ b/memoires/Victoria's_Vice_𝐈𝐈_™_(Maintenance)/768915179995004988.json @@ -0,0 +1,11 @@ +{ + "resume_global": "", + "historique_recent": [ + { + "timestamp": "2026-03-21T16:12:34.189353+00:00", + "channel_id": 1432453132008554567, + "user_message": "<@1108087282692522105> <@1189193599594803272> \nJe suis la pour 18h si vous voulez !", + "bot_message": "" + } + ] +} \ No newline at end of file diff --git a/superviseur/__pycache__/bot.cpython-312.pyc b/superviseur/__pycache__/bot.cpython-312.pyc index 0df35638..59e831ce 100644 Binary files a/superviseur/__pycache__/bot.cpython-312.pyc and b/superviseur/__pycache__/bot.cpython-312.pyc differ diff --git a/superviseur/__pycache__/commands.cpython-312.pyc b/superviseur/__pycache__/commands.cpython-312.pyc index 6a399192..2b631f97 100644 Binary files a/superviseur/__pycache__/commands.cpython-312.pyc and b/superviseur/__pycache__/commands.cpython-312.pyc differ diff --git a/superviseur/__pycache__/dispatcher.cpython-312.pyc b/superviseur/__pycache__/dispatcher.cpython-312.pyc index b8c76f7b..94f48cf9 100644 Binary files a/superviseur/__pycache__/dispatcher.cpython-312.pyc and b/superviseur/__pycache__/dispatcher.cpython-312.pyc differ diff --git a/superviseur/__pycache__/llm.cpython-312.pyc b/superviseur/__pycache__/llm.cpython-312.pyc index 4b173213..15432415 100644 Binary files a/superviseur/__pycache__/llm.cpython-312.pyc and b/superviseur/__pycache__/llm.cpython-312.pyc differ diff --git a/superviseur/__pycache__/messaging.cpython-312.pyc b/superviseur/__pycache__/messaging.cpython-312.pyc index 58bd2664..e807a40b 100644 Binary files a/superviseur/__pycache__/messaging.cpython-312.pyc and b/superviseur/__pycache__/messaging.cpython-312.pyc differ diff --git a/superviseur/__pycache__/permissions.cpython-312.pyc b/superviseur/__pycache__/permissions.cpython-312.pyc index 43153238..887524c5 100644 Binary files a/superviseur/__pycache__/permissions.cpython-312.pyc and b/superviseur/__pycache__/permissions.cpython-312.pyc differ diff --git a/superviseur/__pycache__/voice.cpython-312.pyc b/superviseur/__pycache__/voice.cpython-312.pyc index 9527eaa3..5066ee2c 100644 Binary files a/superviseur/__pycache__/voice.cpython-312.pyc and b/superviseur/__pycache__/voice.cpython-312.pyc differ diff --git a/superviseur/llm.py b/superviseur/llm.py index c0a823ca..4af06ace 100644 --- a/superviseur/llm.py +++ b/superviseur/llm.py @@ -113,49 +113,54 @@ class LLMManager: """Extract JSON action objects from text more robustly.""" actions = [] - # Regex plus laxiste pour trouver des blocs JSON potentiels - # On cherche des blocs commençant par {"action" ou {'action' - matches = re.finditer(r'\{[\s\n]*[\"\']action[\"\'].*?\}', text, re.DOTALL) + # 1. Try to extract from markdown blocks if present + markdown_blocks = re.findall(r'```(?:json)?\s*(.*?)\s*```', text, re.DOTALL) + candidates = markdown_blocks if markdown_blocks else [text] - for match in matches: - json_str = match.group(0) + for candidate_text in candidates: + # Try to parse the whole text as a list or dict first try: - # Tentative de parsing standard - parsed = json.loads(json_str) - if isinstance(parsed, dict) and 'action' in parsed: - actions.append(parsed) - except json.JSONDecodeError: - # Si erreur, on tente de remplacer les simples quotes par des doubles - # (Cas fréquent si le LLM mélange les styles) - try: - # Remplacement très basique (peut échouer si contenu complexe) - json_corrected = json_str.replace("'", '"') - parsed = json.loads(json_corrected) - if isinstance(parsed, dict) and 'action' in parsed: + parsed = json.loads(candidate_text.strip()) + if isinstance(parsed, list): + for item in parsed: + if isinstance(item, dict) and 'action' in item: + if item not in actions: + actions.append(item) + if actions: return json.dumps(actions) + elif isinstance(parsed, dict) and 'action' in parsed: + if parsed not in actions: actions.append(parsed) - continue - except: pass + return json.dumps(actions) + except: + pass - # Méthode récursive des accolades si le bloc est tronqué ou complexe - start = match.start() + # Fallback: scan for { ... } using brace matching + start_indexes = [i for i, c in enumerate(candidate_text) if c == '{'] + for start in start_indexes: brace_count = 0 - for i in range(start, len(text)): - if text[i] == '{': brace_count += 1 - elif text[i] == '}': + for i in range(start, len(candidate_text)): + if candidate_text[i] == '{': + brace_count += 1 + elif candidate_text[i] == '}': brace_count -= 1 if brace_count == 0: + json_str = candidate_text[start:i+1] try: - candidate = text[start:i+1] - try: - parsed = json.loads(candidate) - except: - parsed = json.loads(candidate.replace("'", '"')) - + parsed = json.loads(json_str) if isinstance(parsed, dict) and 'action' in parsed: - actions.append(parsed) - break - except: pass - + if parsed not in actions: # avoid duplicates + actions.append(parsed) + except: + # Fallback with single quote replace + try: + parsed = json.loads(json_str.replace("'", '"')) + if isinstance(parsed, dict) and 'action' in parsed: + if parsed not in actions: + actions.append(parsed) + except: + pass + break # Move to next start brace + if actions: return json.dumps(actions) return None