Public Access
Auto-updater, limites CPU 60% et facturation corrigés
Build and Push Docker Image / build-and-push (push) Successful in 1m55s
Build and Push Docker Image / build-and-push (push) Successful in 1m55s
This commit is contained in:
1 parent
71d6f51ee0
commit
b4ed2947d4
15 files changed
+7413
-122
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import os
|
||||
import json
|
||||
import requests
|
||||
import threading
|
||||
import time
|
||||
from modules.logger import log_event
|
||||
|
||||
CATALOGUE_FILE = "/DATA/AppData/MULTI-IA-AETHAS38/catalogue_dynamique.json"
|
||||
|
||||
def _do_update():
|
||||
ollama_host = os.getenv("OLLAMA_HOST", "http://192.168.1.20:11434")
|
||||
try:
|
||||
# MAJ locale Abliterated
|
||||
resp_local = requests.post(
|
||||
f"{ollama_host}/api/pull",
|
||||
json={"name": "richardyoung/llama-3.2-3b-instruct-abliterated"},
|
||||
timeout=300
|
||||
)
|
||||
if resp_local.status_code == 200:
|
||||
log_event("INFO", "UPDATER", "Modèle local Abliterated vérifié/mis à jour.")
|
||||
|
||||
# MAJ du catalogue OpenRouter (Gratuits ET Payants)
|
||||
resp_or = requests.get("https://openrouter.ai/api/v1/models", timeout=30)
|
||||
if resp_or.status_code == 200:
|
||||
data = resp_or.json().get("data", [])
|
||||
modeles_gratuits = []
|
||||
modeles_payants = []
|
||||
|
||||
for m in data:
|
||||
pricing = m.get("pricing", {})
|
||||
# Gratuits purs
|
||||
if pricing.get("prompt") == "0" and pricing.get("completion") == "0":
|
||||
modeles_gratuits.append(m["id"])
|
||||
# Ciblage des payants ultra-performants (Claude & OpenAI)
|
||||
elif "claude-3.5-sonnet" in m["id"].lower() or "gpt-4o" in m["id"].lower():
|
||||
modeles_payants.append(m["id"])
|
||||
|
||||
with open(CATALOGUE_FILE, "w", encoding="utf-8") as f:
|
||||
json.dump({"free_models": modeles_gratuits, "paid_models": modeles_payants}, f)
|
||||
log_event("INFO", "UPDATER", f"Catalogue dynamique mis à jour ({len(modeles_gratuits)} gratuits, {len(modeles_payants)} payants).")
|
||||
|
||||
except Exception as e:
|
||||
log_event("ERROR", "UPDATER", f"Erreur lors de la MAJ auto : {e}")
|
||||
|
||||
def trigger_update_now():
|
||||
"""Déclenchement forcé du scan en cas d'erreur de modèle."""
|
||||
threading.Thread(target=_do_update, daemon=True).start()
|
||||
|
||||
def update_models_background():
|
||||
_do_update()
|
||||
while True:
|
||||
time.sleep(7200) # Attente 2 heures
|
||||
_do_update()
|
||||
|
||||
threading.Thread(target=update_models_background, daemon=True).start()
|
||||
Reference in new issue
Block a user