#!/usr/bin/env python3 """ tests/test_god_bootstrap.py Vérifie rapidement que le moteur GGUF et la recherche web fonctionnent. Lancer avec : python -m pytest tests/test_god_bootstrap.py -v ou directement : python tests/test_god_bootstrap.py """ import asyncio import os import sys sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) # ───────────────────────────────────────────── # Test 1 : moteur LLM (stub si pas de .gguf) # ───────────────────────────────────────────── async def test_llm_engine(): from agents.cognitive_engine import MultiLLMEngine, CognitiveAgent engine = MultiLLMEngine() info = engine.backend_info() print(f"[LLM] backend={info['backend']} model={info['model']}") resp = await engine.call( agent = None, system = "Tu es un assistant de test.", user = "Dis bonjour en une phrase.", max_tokens = 64, ) print(f"[LLM] réponse ({resp.latency:.2f}s) : {resp.content[:120]}") assert isinstance(resp.content, str), "La réponse doit être une chaîne" print("[LLM] ✅ OK\n") # ───────────────────────────────────────────── # Test 2 : agent spécialisé # ───────────────────────────────────────────── async def test_cognitive_agent(): from agents.cognitive_engine import CognitiveAgent, MultiLLMEngine engine = MultiLLMEngine() planner = CognitiveAgent("Planner", role="planner", temperature=0.2, engine=engine) resp = await planner.think("Décompose la tâche : créer une API REST Flask.", max_tokens=128) print(f"[Planner] {resp.content[:200]}") print("[Planner] ✅ OK\n") # ───────────────────────────────────────────── # Test 3 : recherche web (DuckDuckGo fallback) # ───────────────────────────────────────────── async def test_web_search(): from utils.web_search import web_search print("[WebSearch] Requête : 'Qwen3 8B GGUF benchmark'") resp = await web_search("Qwen3 8B GGUF benchmark", max_results=3, use_cache=False) print(f"[WebSearch] source={resp.source} résultats={len(resp.results)} latence={resp.latency:.2f}s") for r in resp.results: print(f" • {r.title[:60]} → {r.url[:60]}") assert resp.results or resp.error, "Doit renvoyer des résultats ou une erreur explicite" ctx = resp.as_context(max_chars=500) print(f"[WebSearch] Contexte LLM (extrait) :\n{ctx[:300]}") print("[WebSearch] ✅ OK\n") # ───────────────────────────────────────────── # Test 4 : arXiv # ───────────────────────────────────────────── async def test_arxiv(): from utils.web_search import search_arxiv print("[arXiv] Requête : 'mixture of experts efficient inference'") resp = await search_arxiv("mixture of experts efficient inference", max_results=3) print(f"[arXiv] {len(resp.results)} résultats en {resp.latency:.2f}s") for r in resp.results: print(f" • {r.title[:70]}") print("[arXiv] ✅ OK\n") # ───────────────────────────────────────────── # Main # ───────────────────────────────────────────── async def main(): print("=" * 60) print(" VORTEX GOD – Bootstrap Tests") print("=" * 60 + "\n") await test_llm_engine() await test_cognitive_agent() await test_web_search() await test_arxiv() print("=" * 60) print(" Tous les tests ont passé ✅") print("=" * 60) if __name__ == "__main__": asyncio.run(main())