Compare commits
2 Commits
7804aa4d76
...
5ac1f7fa8c
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ac1f7fa8c | |||
| 834b2ea188 |
21
bot/api.py
21
bot/api.py
@@ -72,17 +72,9 @@ api_requests_logger = get_logger('api.requests')
|
|||||||
# ========== GPU Selection Helper ==========
|
# ========== GPU Selection Helper ==========
|
||||||
def get_current_gpu_url():
|
def get_current_gpu_url():
|
||||||
"""Get the URL for the currently selected GPU"""
|
"""Get the URL for the currently selected GPU"""
|
||||||
gpu_state_file = os.path.join(os.path.dirname(__file__), "memory", "gpu_state.json")
|
from config_manager import config_manager
|
||||||
try:
|
if config_manager.get_gpu() == "amd":
|
||||||
with open(gpu_state_file, "r") as f:
|
|
||||||
state = json.load(f)
|
|
||||||
current_gpu = state.get("current_gpu", "nvidia")
|
|
||||||
if current_gpu == "amd":
|
|
||||||
return globals.LLAMA_AMD_URL
|
return globals.LLAMA_AMD_URL
|
||||||
else:
|
|
||||||
return globals.LLAMA_URL
|
|
||||||
except:
|
|
||||||
# Default to NVIDIA if state file doesn't exist
|
|
||||||
return globals.LLAMA_URL
|
return globals.LLAMA_URL
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
@@ -697,13 +689,8 @@ def cleanup_bipolar_webhooks():
|
|||||||
@app.get("/gpu-status")
|
@app.get("/gpu-status")
|
||||||
def get_gpu_status():
|
def get_gpu_status():
|
||||||
"""Get current GPU selection"""
|
"""Get current GPU selection"""
|
||||||
gpu_state_file = os.path.join(os.path.dirname(__file__), "memory", "gpu_state.json")
|
from config_manager import config_manager
|
||||||
try:
|
return {"gpu": config_manager.get_gpu()}
|
||||||
with open(gpu_state_file, "r") as f:
|
|
||||||
state = json.load(f)
|
|
||||||
return {"gpu": state.get("current_gpu", "nvidia")}
|
|
||||||
except:
|
|
||||||
return {"gpu": "nvidia"}
|
|
||||||
|
|
||||||
@app.post("/gpu-select")
|
@app.post("/gpu-select")
|
||||||
async def select_gpu(request: Request):
|
async def select_gpu(request: Request):
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ Uses Pydantic for type-safe configuration loading from:
|
|||||||
- config.yaml (all other configuration)
|
- config.yaml (all other configuration)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ Handles:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Optional, Union
|
from typing import Any, Dict, Optional
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
|||||||
|
|
||||||
scheduler = AsyncIOScheduler()
|
scheduler = AsyncIOScheduler()
|
||||||
|
|
||||||
GUILD_SETTINGS = {}
|
|
||||||
|
|
||||||
# Stores last 5 exchanges per user (as deque)
|
# Stores last 5 exchanges per user (as deque)
|
||||||
conversation_history = defaultdict(lambda: deque(maxlen=5))
|
conversation_history = defaultdict(lambda: deque(maxlen=5))
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ from apscheduler.triggers.interval import IntervalTrigger
|
|||||||
from apscheduler.triggers.cron import CronTrigger
|
from apscheduler.triggers.cron import CronTrigger
|
||||||
from apscheduler.triggers.date import DateTrigger
|
from apscheduler.triggers.date import DateTrigger
|
||||||
import random
|
import random
|
||||||
from datetime import datetime, timedelta
|
|
||||||
from utils.logger import get_logger
|
from utils.logger import get_logger
|
||||||
|
|
||||||
logger = get_logger('server')
|
logger = get_logger('server')
|
||||||
@@ -94,9 +93,9 @@ class ServerManager:
|
|||||||
self.repair_config()
|
self.repair_config()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to load server config: {e}")
|
logger.error(f"Failed to load server config: {e}")
|
||||||
self._create_default_config()
|
logger.info("Starting with zero servers — add servers via the API or dashboard")
|
||||||
else:
|
else:
|
||||||
self._create_default_config()
|
logger.info("No servers_config.json found — starting with zero servers")
|
||||||
|
|
||||||
def repair_config(self):
|
def repair_config(self):
|
||||||
"""Repair corrupted configuration data and save it back"""
|
"""Repair corrupted configuration data and save it back"""
|
||||||
@@ -122,22 +121,6 @@ class ServerManager:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to repair config: {e}")
|
logger.error(f"Failed to repair config: {e}")
|
||||||
|
|
||||||
def _create_default_config(self):
|
|
||||||
"""Create default configuration for backward compatibility"""
|
|
||||||
default_server = ServerConfig(
|
|
||||||
guild_id=759889672804630530,
|
|
||||||
guild_name="Default Server",
|
|
||||||
autonomous_channel_id=761014220707332107,
|
|
||||||
autonomous_channel_name="miku-chat",
|
|
||||||
bedtime_channel_ids=[761014220707332107],
|
|
||||||
enabled_features={"autonomous", "bedtime", "monday_video"},
|
|
||||||
autonomous_interval_minutes=10,
|
|
||||||
conversation_detection_interval_minutes=3
|
|
||||||
)
|
|
||||||
self.servers[default_server.guild_id] = default_server
|
|
||||||
self.save_config()
|
|
||||||
logger.info("Created default server configuration")
|
|
||||||
|
|
||||||
def save_config(self):
|
def save_config(self):
|
||||||
"""Save server configurations to file"""
|
"""Save server configurations to file"""
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user