Spaces:
Building
Building
Update controllers/admin_controller.py
Browse files
controllers/admin_controller.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
from fastapi import APIRouter, Request
|
2 |
from core import service_config, llm_models
|
3 |
from llm_model import LLMModel
|
4 |
-
from intent_utils import background_training
|
5 |
from log import log
|
6 |
import json, os, shutil, threading
|
7 |
|
@@ -33,7 +32,6 @@ async def reload_config(request: Request):
|
|
33 |
os.makedirs(temp_path, exist_ok=True)
|
34 |
|
35 |
llm_config = incoming_project["llm"]
|
36 |
-
intents = incoming_project["intents"]
|
37 |
|
38 |
temp_instance = LLMModel()
|
39 |
|
@@ -42,15 +40,6 @@ async def reload_config(request: Request):
|
|
42 |
log(f"🆕 Yeni proje '{project_name}' tespit edildi, yükleme başlatılıyor...")
|
43 |
|
44 |
temp_instance.setup(service_config, llm_config, temp_path)
|
45 |
-
intent_model_path = os.path.join(temp_path, "intent", "trained_model")
|
46 |
-
background_training(
|
47 |
-
project_name,
|
48 |
-
intents,
|
49 |
-
llm_config["intent_model_id"],
|
50 |
-
intent_model_path,
|
51 |
-
llm_config["train_confidence_treshold"]
|
52 |
-
)
|
53 |
-
temp_instance.load_intent_model(intent_model_path)
|
54 |
|
55 |
if os.path.exists(project_path):
|
56 |
shutil.rmtree(project_path)
|
@@ -76,22 +65,6 @@ async def reload_config(request: Request):
|
|
76 |
temp_instance.model = llm_models[project_name].model
|
77 |
temp_instance.tokenizer = llm_models[project_name].tokenizer
|
78 |
|
79 |
-
# Intent değiştiyse yeniden eğit
|
80 |
-
if current_project["intents"] != intents:
|
81 |
-
intent_model_path = os.path.join(temp_path, "intent", "trained_model")
|
82 |
-
background_training(
|
83 |
-
project_name,
|
84 |
-
intents,
|
85 |
-
llm_config["intent_model_id"],
|
86 |
-
intent_model_path,
|
87 |
-
llm_config["train_confidence_treshold"]
|
88 |
-
)
|
89 |
-
temp_instance.load_intent_model(intent_model_path)
|
90 |
-
else:
|
91 |
-
temp_instance.intent_model = llm_models[project_name].intent_model
|
92 |
-
temp_instance.intent_tokenizer = llm_models[project_name].intent_tokenizer
|
93 |
-
temp_instance.intent_label2id = llm_models[project_name].intent_label2id
|
94 |
-
|
95 |
if os.path.exists(project_path):
|
96 |
shutil.rmtree(project_path)
|
97 |
shutil.copytree(temp_path, project_path)
|
@@ -104,10 +77,9 @@ async def reload_config(request: Request):
|
|
104 |
except Exception as e:
|
105 |
log(f"❌ reload_config background hatası: {e}")
|
106 |
|
107 |
-
# Arka planda başlat
|
108 |
threading.Thread(target=background_reload, daemon=True).start()
|
109 |
|
110 |
return {
|
111 |
"status": "accepted",
|
112 |
"message": f"'{project_name}' için güncelleme arka planda başlatıldı. İşlem loglardan takip edilebilir."
|
113 |
-
}
|
|
|
1 |
from fastapi import APIRouter, Request
|
2 |
from core import service_config, llm_models
|
3 |
from llm_model import LLMModel
|
|
|
4 |
from log import log
|
5 |
import json, os, shutil, threading
|
6 |
|
|
|
32 |
os.makedirs(temp_path, exist_ok=True)
|
33 |
|
34 |
llm_config = incoming_project["llm"]
|
|
|
35 |
|
36 |
temp_instance = LLMModel()
|
37 |
|
|
|
40 |
log(f"🆕 Yeni proje '{project_name}' tespit edildi, yükleme başlatılıyor...")
|
41 |
|
42 |
temp_instance.setup(service_config, llm_config, temp_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
if os.path.exists(project_path):
|
45 |
shutil.rmtree(project_path)
|
|
|
65 |
temp_instance.model = llm_models[project_name].model
|
66 |
temp_instance.tokenizer = llm_models[project_name].tokenizer
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
if os.path.exists(project_path):
|
69 |
shutil.rmtree(project_path)
|
70 |
shutil.copytree(temp_path, project_path)
|
|
|
77 |
except Exception as e:
|
78 |
log(f"❌ reload_config background hatası: {e}")
|
79 |
|
|
|
80 |
threading.Thread(target=background_reload, daemon=True).start()
|
81 |
|
82 |
return {
|
83 |
"status": "accepted",
|
84 |
"message": f"'{project_name}' için güncelleme arka planda başlatıldı. İşlem loglardan takip edilebilir."
|
85 |
+
}
|