Skip to content

Commit

Permalink
Merge pull request #4541 from oobabooga/dev
Browse files Browse the repository at this point in the history
Merge dev branch
  • Loading branch information
oobabooga authored Nov 9, 2023
2 parents f7534b2 + 372d712 commit 07d66e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions extensions/api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def build_parameters(body, chat=False):
if str(character) == "None":
character = "Assistant"

name1, name2, _, greeting, context, _ = load_character_memoized(character, str(body.get('your_name', shared.settings['name1'])), '', instruct=False)
name1_instruct, name2_instruct, _, _, context_instruct, turn_template = load_character_memoized(instruction_template, '', '', instruct=True)
name1, name2, _, greeting, context, _, _ = load_character_memoized(character, str(body.get('your_name', shared.settings['name1'])), '', instruct=False)
name1_instruct, name2_instruct, _, _, context_instruct, turn_template, _ = load_character_memoized(instruction_template, '', '', instruct=True)
generate_params.update({
'mode': str(body.get('mode', 'chat')),
'name1': str(body.get('name1', name1)),
Expand Down
8 changes: 8 additions & 0 deletions extensions/openai/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ async def generator():
async with streaming_semaphore:
response = OAIcompletions.stream_completions(to_dict(request_data), is_legacy=is_legacy)
for resp in response:
disconnected = await request.is_disconnected()
if disconnected:
break

yield {"data": json.dumps(resp)}

return EventSourceResponse(generator()) # SSE streaming
Expand All @@ -110,6 +114,10 @@ async def generator():
async with streaming_semaphore:
response = OAIcompletions.stream_chat_completions(to_dict(request_data), is_legacy=is_legacy)
for resp in response:
disconnected = await request.is_disconnected()
if disconnected:
break

yield {"data": json.dumps(resp)}

return EventSourceResponse(generator()) # SSE streaming
Expand Down

0 comments on commit 07d66e4

Please sign in to comment.