feat: add conversation-scoped yolo controls
This commit is contained in:
@@ -531,6 +531,52 @@ class PhebyServer:
|
||||
**({"request_id": request_id} if request_id else {}),
|
||||
})
|
||||
|
||||
async def _handle_yolo_current(self, client, message, request_id):
|
||||
conversation_id = str(message.get("conversation_id", ""))
|
||||
if not ConversationRouter.is_valid_conversation_id(conversation_id):
|
||||
await client.send_json(proto.error_event(
|
||||
proto.ERR_BAD_REQUEST, "Invalid conversation_id", request_id))
|
||||
return
|
||||
result = await self.bridge.yolo_snapshot(conversation_id)
|
||||
if not result.get("ok"):
|
||||
await client.send_json(proto.error_event(
|
||||
result.get("code", proto.ERR_INTERNAL),
|
||||
result.get("message", "YOLO state unavailable"), request_id))
|
||||
return
|
||||
await client.send_json({
|
||||
"type": proto.S_YOLO_SNAPSHOT,
|
||||
"enabled": bool(result.get("enabled")),
|
||||
"scope": result.get("scope", "conversation"),
|
||||
"conversation_id": conversation_id,
|
||||
**({"request_id": request_id} if request_id else {}),
|
||||
})
|
||||
|
||||
async def _handle_yolo_set(self, client, message, request_id):
|
||||
conversation_id = str(message.get("conversation_id", ""))
|
||||
enabled = message.get("enabled")
|
||||
if not ConversationRouter.is_valid_conversation_id(conversation_id) \
|
||||
or not isinstance(enabled, bool):
|
||||
await client.send_json(proto.error_event(
|
||||
proto.ERR_BAD_REQUEST,
|
||||
"conversation_id and boolean enabled are required", request_id))
|
||||
return
|
||||
result = await self.bridge.set_yolo(conversation_id, enabled)
|
||||
if not result.get("ok"):
|
||||
await client.send_json(proto.error_event(
|
||||
result.get("code", proto.ERR_INTERNAL),
|
||||
result.get("message", "YOLO change failed"), request_id))
|
||||
return
|
||||
event = {
|
||||
"type": proto.S_YOLO_CHANGED,
|
||||
"enabled": bool(result.get("enabled")),
|
||||
"scope": result.get("scope", "conversation"),
|
||||
"conversation_id": conversation_id,
|
||||
**({"request_id": request_id} if request_id else {}),
|
||||
}
|
||||
await client.send_json(event)
|
||||
await self.broadcast({k: v for k, v in event.items()
|
||||
if k != "request_id"})
|
||||
|
||||
async def _handle_models_list(self, client, message, request_id):
|
||||
conversation_id = message.get("conversation_id")
|
||||
snapshot = await self.bridge.models_snapshot(
|
||||
@@ -617,6 +663,8 @@ class PhebyServer:
|
||||
proto.C_MODEL_CURRENT: _handle_model_current,
|
||||
proto.C_REASONING_SET: _handle_reasoning_set,
|
||||
proto.C_REASONING_CURRENT: _handle_reasoning_current,
|
||||
proto.C_YOLO_SET: _handle_yolo_set,
|
||||
proto.C_YOLO_CURRENT: _handle_yolo_current,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user