mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-06-07 14:17:09 -04:00
Fix API issues
This commit is contained in:
parent
126b3a768f
commit
83bfd5c64b
1 changed files with 10 additions and 8 deletions
|
@ -114,8 +114,8 @@ async def openai_completions(request: Request, request_data: CompletionRequest):
|
|||
|
||||
if request_data.stream:
|
||||
async def generator():
|
||||
try:
|
||||
async with streaming_semaphore:
|
||||
try:
|
||||
response = OAIcompletions.stream_completions(to_dict(request_data), is_legacy=is_legacy)
|
||||
async for resp in iterate_in_threadpool(response):
|
||||
disconnected = await request.is_disconnected()
|
||||
|
@ -124,6 +124,7 @@ async def openai_completions(request: Request, request_data: CompletionRequest):
|
|||
|
||||
yield {"data": json.dumps(resp)}
|
||||
finally:
|
||||
stop_everything_event()
|
||||
return
|
||||
|
||||
return EventSourceResponse(generator()) # SSE streaming
|
||||
|
@ -145,8 +146,8 @@ async def openai_chat_completions(request: Request, request_data: ChatCompletion
|
|||
|
||||
if request_data.stream:
|
||||
async def generator():
|
||||
try:
|
||||
async with streaming_semaphore:
|
||||
try:
|
||||
response = OAIcompletions.stream_chat_completions(to_dict(request_data), is_legacy=is_legacy)
|
||||
async for resp in iterate_in_threadpool(response):
|
||||
disconnected = await request.is_disconnected()
|
||||
|
@ -155,6 +156,7 @@ async def openai_chat_completions(request: Request, request_data: ChatCompletion
|
|||
|
||||
yield {"data": json.dumps(resp)}
|
||||
finally:
|
||||
stop_everything_event()
|
||||
return
|
||||
|
||||
return EventSourceResponse(generator()) # SSE streaming
|
||||
|
|
Loading…
Add table
Reference in a new issue