ciyidogan commited on
Commit
c3841ff
·
verified ·
1 Parent(s): 4198501

Update controllers/config_controller.py

Browse files
Files changed (1) hide show
  1. controllers/config_controller.py +35 -0
controllers/config_controller.py CHANGED
@@ -32,6 +32,41 @@ def reload_config():
32
  threading.Thread(target=background_reload, daemon=True).start()
33
  return {"status": "accepted", "message": "Config reload started in background."}
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  # === API CRUD ===
36
 
37
  @router.get("/list_apis")
 
32
  threading.Thread(target=background_reload, daemon=True).start()
33
  return {"status": "accepted", "message": "Config reload started in background."}
34
 
35
+ # === ENVIRONMENT SETTINGS ===
36
+
37
+ @router.get("/get_settings")
38
+ def get_settings():
39
+ settings = {
40
+ "work_mode": service_config.work_mode,
41
+ "cloud_token": service_config.cloud_token,
42
+ "system_prompt": service_config.system_prompt,
43
+ "llm_inference_service_url": service_config.llm_inference_service_url
44
+ }
45
+ log("⚙️ Retrieved current environment settings.")
46
+ return settings
47
+
48
+ @router.post("/update_settings")
49
+ async def update_settings(request: Request):
50
+ data = await request.json()
51
+ updated = []
52
+
53
+ if "work_mode" in data:
54
+ service_config.work_mode = data["work_mode"]
55
+ updated.append("work_mode")
56
+ if "cloud_token" in data:
57
+ service_config.cloud_token = data["cloud_token"]
58
+ updated.append("cloud_token")
59
+ if "system_prompt" in data:
60
+ service_config.system_prompt = data["system_prompt"]
61
+ updated.append("system_prompt")
62
+ if "llm_inference_service_url" in data:
63
+ service_config.llm_inference_service_url = data["llm_inference_service_url"]
64
+ updated.append("llm_inference_service_url")
65
+
66
+ save_config()
67
+ log(f"✏️ Updated environment settings: {', '.join(updated)}")
68
+ return {"message": f"Updated settings: {', '.join(updated)}"}
69
+
70
  # === API CRUD ===
71
 
72
  @router.get("/list_apis")