Spaces:
Running
Running
traceforge space
Browse files- BUILD.json +1 -1
- traceforge/space/local_llm.py +4 -0
BUILD.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"built_at": "2026-10-27T12:
|
| 3 |
"commit": "623717d",
|
| 4 |
"files": 49,
|
| 5 |
"with_store": false,
|
|
|
|
| 1 |
{
|
| 2 |
+
"built_at": "2026-10-27T12:34:12",
|
| 3 |
"commit": "623717d",
|
| 4 |
"files": 49,
|
| 5 |
"with_store": false,
|
traceforge/space/local_llm.py
CHANGED
|
@@ -40,6 +40,7 @@ _server_url: Optional[str] = None
|
|
| 40 |
LAST_ERROR: Optional[str] = None
|
| 41 |
REQUESTS = 0
|
| 42 |
LAST_REQUEST: Optional[dict] = None
|
|
|
|
| 43 |
|
| 44 |
# A Space can carry HTTP(S)_PROXY for outbound traffic; urllib would then
|
| 45 |
# route the loopback call through it and the local server would never see
|
|
@@ -169,6 +170,8 @@ class _Handler(BaseHTTPRequestHandler):
|
|
| 169 |
traceback.print_exc()
|
| 170 |
self._send(500, {"error": f"local model failed: {e}"})
|
| 171 |
return
|
|
|
|
|
|
|
| 172 |
self._send(200, {
|
| 173 |
"id": "local-0",
|
| 174 |
"object": "chat.completion",
|
|
@@ -270,6 +273,7 @@ def health() -> dict:
|
|
| 270 |
"ping": _ping(),
|
| 271 |
"requests": REQUESTS,
|
| 272 |
"last_request": LAST_REQUEST,
|
|
|
|
| 273 |
"proxy": {k: v for k, v in os.environ.items()
|
| 274 |
if "proxy" in k.lower()},
|
| 275 |
"last_error": LAST_ERROR,
|
|
|
|
| 40 |
LAST_ERROR: Optional[str] = None
|
| 41 |
REQUESTS = 0
|
| 42 |
LAST_REQUEST: Optional[dict] = None
|
| 43 |
+
LAST_RESPONSE: Optional[str] = None
|
| 44 |
|
| 45 |
# A Space can carry HTTP(S)_PROXY for outbound traffic; urllib would then
|
| 46 |
# route the loopback call through it and the local server would never see
|
|
|
|
| 170 |
traceback.print_exc()
|
| 171 |
self._send(500, {"error": f"local model failed: {e}"})
|
| 172 |
return
|
| 173 |
+
global LAST_RESPONSE
|
| 174 |
+
LAST_RESPONSE = (text or "")[:800]
|
| 175 |
self._send(200, {
|
| 176 |
"id": "local-0",
|
| 177 |
"object": "chat.completion",
|
|
|
|
| 273 |
"ping": _ping(),
|
| 274 |
"requests": REQUESTS,
|
| 275 |
"last_request": LAST_REQUEST,
|
| 276 |
+
"last_response": LAST_RESPONSE,
|
| 277 |
"proxy": {k: v for k, v in os.environ.items()
|
| 278 |
if "proxy" in k.lower()},
|
| 279 |
"last_error": LAST_ERROR,
|