possible fix for broken pipe due to timeouts - send some data first

This commit is contained in:
Concedo 2026-02-17 20:29:24 +08:00
parent b6bb9c914e
commit a82a429fba

View file

@ -3476,15 +3476,14 @@ class KcppServerRequestHandler(http.server.SimpleHTTPRequestHandler):
async def handle_sse_stream(self, genparams, api_format):
global friendlymodelname, currfinishreason
# if tools, do not send anything - OAI tool calls will be handled with fakestreaming!
using_openai_tools = genparams.get('using_openai_tools', False)
if api_format == 4 and using_openai_tools:
return
self.send_response(200)
self.send_header("X-Accel-Buffering", "no")
self.send_header("cache-control", "no-cache")
self.send_header("connection", "keep-alive")
self.end_headers(content_type='text/event-stream')
if api_format == 4 and using_openai_tools: # if tools, do not send anything else - OAI tool calls will be handled with fakestreaming!
return
encap_in_thinking = False
encap_first_loop = True
@ -4850,12 +4849,6 @@ Change Mode<br>
self.end_headers(content_type='application/json')
self.wfile.write(genresp)
elif api_format == 4 and genparams.get('using_openai_tools', False): #special case, fake streaming for openai tool calls
self.send_response(200)
self.send_header("X-Accel-Buffering", "no")
self.send_header("cache-control", "no-cache")
self.send_header("connection", "keep-alive")
self.end_headers(content_type='text/event-stream')
content_text = None
toolsdata_res = []
try: