File size: 2,321 Bytes
58c4fec | 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 | """
CRANE AI Sistem Yapılandırması
"""
import os
from typing import Dict, Any
# Hugging Face Token güvenlik için ortam değişkeninden okunur
HF_TOKEN = os.getenv("HF_TOKEN", "")
# Model Yapılandırması
MODELS = {
"code_module": {
"model_id": "deepseek-ai/deepseek-coder-1.3b-instruct",
"task": "code_generation",
"max_tokens": 2048,
"temperature": 0.1,
"priority": 1
},
"chat_module": {
"model_id": "Qwen/Qwen2.5-1.5B-Instruct",
"task": "chat",
"max_tokens": 1024,
"temperature": 0.7,
"priority": 2
},
"reason_module": {
"model_id": "microsoft/Phi-3-mini-4k-instruct",
"task": "reasoning",
"max_tokens": 1024,
"temperature": 0.3,
"priority": 3
},
"fast_module": {
"model_id": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
"task": "quick_response",
"max_tokens": 512,
"temperature": 0.8,
"priority": 4
}
}
# Router Yapılandırması
ROUTER_CONFIG = {
"confidence_threshold": 0.6,
"max_concurrent_requests": 4,
"timeout": 30,
"fallback_model": "fast_module"
}
# Memory Yapılandırması
MEMORY_CONFIG = {
"max_slots": 10,
"slot_size": 1024,
"cleanup_interval": 300 # 5 dakika
}
# API Yapılandırması
API_CONFIG = {
"host": "0.0.0.0",
"port": 8000,
"workers": 1
}
# Sistem Limitleri
SYSTEM_LIMITS = {
"max_input_length": 4096,
"max_output_length": 2048,
"max_concurrent_users": 10
}
# Logging
LOGGING_CONFIG = {
"level": "INFO",
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
"file": "logs/crane_ai.log"
}
def get_model_config(model_name: str) -> Dict[str, Any]:
"""Belirli bir model için yapılandırma döndürür"""
return MODELS.get(model_name, MODELS["fast_module"])
def get_device():
"""Kullanılacak cihazı belirler"""
try:
import torch
if torch.cuda.is_available():
return "cuda"
elif torch.backends.mps.is_available():
return "mps"
else:
return "cpu"
except ImportError:
return "cpu"
# Cihaz yapılandırması
DEVICE = get_device() |