feat(perf): Optimize KV-Cache to Q4_K and fix Hermes Context bounds
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user