Cran-May commited on
Commit
5f95fd9
·
verified ·
1 Parent(s): 039937f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -31,10 +31,12 @@ def chat_fn(message, history, model, system_message, max_tokens, temperature, to
31
  history_list = history or []
32
  response_generator = respond(message, history_list, model, system_message, max_tokens, temperature, top_p, top_k, repeat_penalty)
33
 
34
- full_response = ""
35
- for current_history in response_generator:
36
- full_response = current_history[-1][1] # 获取最新的回复
37
- yield current_history, history # 在每次迭代中返回当前历史记录和历史记录
 
 
38
 
39
 
40
  def respond(
 
31
  history_list = history or []
32
  response_generator = respond(message, history_list, model, system_message, max_tokens, temperature, top_p, top_k, repeat_penalty)
33
 
34
+ for messages in response_generator:
35
+ # 转换 messages 为 Gradio Chatbot 接受的格式
36
+ chatbot_messages = []
37
+ for msg in messages:
38
+ chatbot_messages.append([msg["content"], msg["role"] == "assistant"]) # 直接使用字典中的值
39
+ yield chatbot_messages, history # yield 正确格式的消息列表
40
 
41
 
42
  def respond(