mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 08:07:56 +01:00
Add a /api/v1/stop-stream
API that allows the user to interrupt the generation (#2392)
This commit is contained in:
parent
ebcadc0042
commit
4715123f55
@ -5,7 +5,7 @@ from threading import Thread
|
||||
from extensions.api.util import build_parameters, try_start_cloudflared
|
||||
from modules import shared
|
||||
from modules.chat import generate_chat_reply
|
||||
from modules.text_generation import encode, generate_reply
|
||||
from modules.text_generation import encode, generate_reply, stop_everything_event
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
@ -78,6 +78,19 @@ class Handler(BaseHTTPRequestHandler):
|
||||
|
||||
self.wfile.write(response.encode('utf-8'))
|
||||
|
||||
elif self.path == '/api/v1/stop-stream':
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.end_headers()
|
||||
|
||||
stop_everything_event()
|
||||
|
||||
response = json.dumps({
|
||||
'results': 'success'
|
||||
})
|
||||
|
||||
self.wfile.write(response.encode('utf-8'))
|
||||
|
||||
elif self.path == '/api/v1/token-count':
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
|
Loading…
Reference in New Issue
Block a user