Rebuild profile router as secure recoverable v2

This commit is contained in:
Mikei386
2026-08-20 13:41:00 +02:00
parent bdd6c08643
commit fd4a3055e8
18 changed files with 1162 additions and 129 deletions
+5
View File
@@ -58,6 +58,9 @@ class Handler(BaseHTTPRequestHandler):
self._json(404, {"error": {"message": "not found"}})
def _completion(self, body: dict) -> dict:
delay = body.get("mock_delay", 0)
if isinstance(delay, (int, float)) and 0 < delay <= 10:
time.sleep(delay)
model = body.get("model")
if body.get("tools"):
name = body["tools"][0]["function"]["name"]
@@ -84,6 +87,8 @@ class Handler(BaseHTTPRequestHandler):
"finish_reason": finish}],
"usage": {"prompt_tokens": 10, "completion_tokens": 5,
"total_tokens": 15},
"mock_ctx": current_ctx(),
"mock_authorization": self.headers.get("Authorization"),
}
def _stream(self, body: dict) -> None: