File size: 3,884 Bytes
0b2210a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import sys
import os
import json
import subprocess
import time
import httpx
import asyncio
import torch

# Добавляем путь к корню проекта
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, PROJECT_ROOT)

async def check_server():
    print("⚡ БЫСТРАЯ ПРОВЕРКА СИСТЕМЫ AIColab")

    config = {}
    # 1. Проверка локальных моделей
    print("\n1. ЛОКАЛЬНЫЕ МОДЕЛИ:")
    try:
        from core.model_management import GptOssModel
        print("   ✅ GptOssModel импортирован")
        
        config_path = os.path.join(PROJECT_ROOT, 'config', 'models_config.json')
        with open(config_path, 'r', encoding='utf-8') as f:
            config = json.load(f)
        
        chief_config = config['active_models'].get('chief')
        if chief_config:
            print(f"   ✅ Конфиг Шефа: {chief_config['model_id']}")
            print(f"   ✅ Провайдер: {chief_config['provider']}")
        else:
            print("   ❌ Конфиг Шефа не найден")
            
    except Exception as e:
        print(f"   ❌ Ошибка: {e}")

    # 2. Проверка OpenRouter
    print("\n2. OPENROUTER МОДЕЛИ:")
    try:
        # Убедимся, что переменные окружения загружены
        from dotenv import load_dotenv
        load_dotenv(os.path.join(PROJECT_ROOT, '.env'))
        
        from core.model_management import OpenRouterModel
        print("   ✅ OpenRouterModel импортирован")
        
        if os.environ.get("OPENROUTER_API_KEY"):
            print("   ✅ API ключ установлен")
        else:
            print("   ❌ API ключ не найден")
            
        available = config.get("available_openrouter_models", [])
        print(f"   ✅ Доступно моделей: {len(available)}")
        if available:
            print(f"   📋 Первая модель: {available[0]}")
            
    except Exception as e:
        print(f"   ❌ Ошибка: {e}")

    # 3. Проверка GPU
    print("\n3. GPU СТАТУС:")
    try:
        print(f"   ✅ PyTorch: {torch.__version__}")
        print(f"   ✅ CUDA доступна: {torch.cuda.is_available()}")
        if torch.cuda.is_available():
            print(f"   ✅ GPU: {torch.cuda.get_device_name(0)}")
            print(f"   ✅ Память: {torch.cuda.get_device_properties(0).total_memory / 1024**3:.2f} GB")
    except Exception as e:
        print(f"   ❌ Ошибка: {e}")

    # 4. Проверка запуска сервера
    print("\n4. ПРОВЕРКА СЕРВЕРА:")
    try:
        python_exe = sys.executable
        # Запускаем сервер
        server = subprocess.Popen(
            [python_exe, "app.py"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            text=True,
            cwd=PROJECT_ROOT
        )
        
        print("   ⏳ Ожидание запуска сервера (5 сек)...")
        await asyncio.sleep(5)
        
        try:
            async with httpx.AsyncClient() as client:
                resp = await client.get("http://127.0.0.1:5000/", timeout=10)
                print(f"   ✅ Сервер запущен (статус: {resp.status_code})")
        except Exception as e:
            print(f"   ❌ Сервер не отвечает: {e}")
        
        server.terminate()
        try:
            server.wait(timeout=5)
        except:
            server.kill()
            
    except Exception as e:
        print(f"   ❌ Ошибка запуска сервера: {e}")

    print("\n" + "="*50)
    print("🏁 ПРОВЕРКА ЗАВЕРШЕНА")

if __name__ == "__main__":
    asyncio.run(check_server())