You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
732 B
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI(title="直播接管控制接口")
# 由 main.py 在启动前注入app.state.shared_config = <Manager().dict(...)>
app.shared_config = None
class ControlMode(BaseModel):
control_mode: int # 0=手动接管, 1=AI接管
@app.post("/control-mode", summary="更新直播间接管模式")
def update_control_mode(mode: ControlMode):
if app.shared_config is None:
return {"error": "服务未初始化"}
app.shared_config["control_mode"] = mode.control_mode
return {
"message": "模式更新成功",
"current_status": {
"control_mode": app.shared_config["control_mode"], # 0=手动, 1=AI
},
}