fix: don't send headers twice when streaming
This commit is contained in:
parent
b2eaec4261
commit
9281c2801f
1 changed files with 8 additions and 6 deletions
14
koboldcpp.py
14
koboldcpp.py
|
@ -572,12 +572,14 @@ class ServerRequestHandler(http.server.SimpleHTTPRequestHandler):
|
|||
newprompt = fullprompt
|
||||
|
||||
gen = asyncio.run(self.handle_request(genparams, newprompt, basic_api_flag, kai_sse_stream_flag))
|
||||
try:
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
self.wfile.write(json.dumps(gen).encode())
|
||||
except:
|
||||
print("Generate: The response could not be sent, maybe connection was terminated?")
|
||||
|
||||
if not kai_sse_stream_flag:
|
||||
try:
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
self.wfile.write(json.dumps(gen).encode())
|
||||
except:
|
||||
print("Generate: The response could not be sent, maybe connection was terminated?")
|
||||
|
||||
return
|
||||
finally:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue