File size: 1,719 Bytes
a9dc537 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
"""
Quick test of SPARKNET core functionality
"""
import asyncio
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from src.llm.ollama_client import OllamaClient
from src.utils.gpu_manager import get_gpu_manager
from src.tools.gpu_tools import GPUMonitorTool
from loguru import logger
async def test_ollama():
"""Test Ollama client"""
print("\n=== Testing Ollama Client ===")
client = OllamaClient(default_model="gemma2:2b")
# Test simple generation
response = client.generate(
prompt="Say 'Hello from SPARKNET!' and nothing else.",
temperature=0.1,
)
print(f"Response: {response[:100]}")
return True
async def test_gpu():
"""Test GPU manager"""
print("\n=== Testing GPU Manager ===")
gpu_manager = get_gpu_manager()
print(gpu_manager.monitor())
return True
async def test_tools():
"""Test tools"""
print("\n=== Testing Tools ===")
gpu_tool = GPUMonitorTool()
result = await gpu_tool.execute()
print(f"Tool Success: {result.success}")
print(f"Output Preview: {result.output[:200] if result.output else 'None'}")
return True
async def main():
"""Run all tests"""
print("="*60)
print("SPARKNET Basic Functionality Test")
print("="*60)
try:
# Test GPU
await test_gpu()
# Test Ollama
await test_ollama()
# Test Tools
await test_tools()
print("\n" + "="*60)
print("✓ All tests passed!")
print("="*60)
except Exception as e:
print(f"\n✗ Test failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(main())
|