feat(perf): Optimize KV-Cache to Q4_K and fix Hermes Context bounds

This commit is contained in:
Hitonabi
2026-07-07 17:11:50 +02:00
parent 97be0f1d00
commit edf1614e66
2 changed files with 14 additions and 2 deletions
+13 -1
View File
@@ -98,11 +98,23 @@ async def _proxy(path: str, request: Request):
client = request.app.state.gw_client # geteilter Keep-Alive-Client (siehe app.py lifespan)
if body.get("stream"):
req = client.build_request("POST", url, json=body, timeout=None)
r = await client.send(req, stream=True)
if r.status_code != 200:
await r.aread()
try:
resp_json = r.json()
except Exception:
resp_json = {"error": {"message": r.text, "type": "upstream_error"}}
return JSONResponse(resp_json, status_code=r.status_code, headers=routed)
async def gen():
async with client.stream("POST", url, json=body, timeout=None) as r:
try:
async for chunk in r.aiter_raw():
record_stream_chunk(chunk, alias)
yield chunk
finally:
await r.aclose()
return StreamingResponse(gen(), media_type="text/event-stream", headers=routed)
r = await client.post(url, json=body, timeout=600.0)