Spaces:
Build error
Build error
| #!/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()) | |