Hmjz100 commited on
Commit
d23327b
·
1 Parent(s): fcb8510

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -90,7 +90,6 @@ def predict(openai_gptapi_key, model, system_msg, inputs, top_p, temperature, ma
90
  partial_words = ""
91
 
92
  counter=0
93
- complete_response = ""
94
  for chunk in response.iter_lines():
95
  # 跳过第一个块
96
  if counter == 0:
@@ -98,6 +97,7 @@ def predict(openai_gptapi_key, model, system_msg, inputs, top_p, temperature, ma
98
  continue
99
  # 检查每行是否非空
100
  if chunk.decode() :
 
101
  chunk = chunk.decode()
102
  # 将每行解码为响应数据,因为响应数据是以字节形式返回的
103
  if len(chunk) > 12 and "content" in json.loads(chunk[6:])['choices'][0]['delta']:
@@ -110,8 +110,7 @@ def predict(openai_gptapi_key, model, system_msg, inputs, top_p, temperature, ma
110
  complete_response = " ".join([item[1] for item in chat])
111
  token_counter+=1
112
  yield chat, history, chat_counter, response # 类似于 {chatbot: chat, state: history}
113
-
114
- print(f"[{current_time}] 聊天:模型回复 - {complete_response}")
115
 
116
  # 重置文本框
117
  def reset_textbox():
 
90
  partial_words = ""
91
 
92
  counter=0
 
93
  for chunk in response.iter_lines():
94
  # 跳过第一个块
95
  if counter == 0:
 
97
  continue
98
  # 检查每行是否非空
99
  if chunk.decode() :
100
+ complete_response = ""
101
  chunk = chunk.decode()
102
  # 将每行解码为响应数据,因为响应数据是以字节形式返回的
103
  if len(chunk) > 12 and "content" in json.loads(chunk[6:])['choices'][0]['delta']:
 
110
  complete_response = " ".join([item[1] for item in chat])
111
  token_counter+=1
112
  yield chat, history, chat_counter, response # 类似于 {chatbot: chat, state: history}
113
+ print(f"[{current_time}] 聊天:模型回复 - {complete_response}")
 
114
 
115
  # 重置文本框
116
  def reset_textbox():