mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-03-14 15:57:27 +00:00
API: Use FastAPI streaming instead of sse_starlette
sse_starlette kept firing a ping response if it was taking too long to set an event. Rather than using a hacky workaround, switch to FastAPI's inbuilt streaming response and construct SSE requests with a utility function. This helps the API become more robust and removes an extra requirement. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
5
utils.py
5
utils.py
@@ -26,4 +26,7 @@ def get_generator_error(exception: Exception):
|
||||
|
||||
# Log and send the exception
|
||||
print(f"\n{generator_error.error.trace}")
|
||||
return generator_error.json()
|
||||
return get_sse_packet(generator_error.json(ensure_ascii = False))
|
||||
|
||||
def get_sse_packet(json_data: str):
|
||||
return f"data: {json_data}\n\n"
|
||||
|
||||
Reference in New Issue
Block a user