zhangtao commited on
Commit
650d572
1 Parent(s): 0a8f41c

again 修改

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -31,13 +31,14 @@ def chat_stream_completion(messages, history, system_prompt):
31
  messages=messages_prompts,
32
  stream=True
33
  )
34
- partial_message = ""
35
  for chunk in response:
36
  print(json.dumps(chunk, ensure_ascii=False, indent=2))
37
- if len(chunk['choices'][0]) != 0:
38
- partial_message = partial_message + \
39
- chunk['choices'][0]['content']
40
- yield partial_message
 
41
 
42
 
43
  gr.ChatInterface(chat_stream_completion,
 
31
  messages=messages_prompts,
32
  stream=True
33
  )
34
+ partial_message = []
35
  for chunk in response:
36
  print(json.dumps(chunk, ensure_ascii=False, indent=2))
37
+ partial_message.append(chunk)
38
+ # if len(chunk['choices'][0]) != 0:
39
+ # partial_message = partial_message + \
40
+ # chunk['choices'][0]['content']
41
+ yield json.dumps(partial_message, ensure_ascii=False, indent=2)
42
 
43
 
44
  gr.ChatInterface(chat_stream_completion,