vortex-omega-final / test_god_bootstrap.py
RDS777's picture
Upload 1772 files
89c2dc5 verified
Raw
History Blame Contribute Delete
4.31 kB
#!/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())