smgc commited on
Commit
ee90599
1 Parent(s): 2ceda68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -89,7 +89,12 @@ def messages():
89
  json_body = request.json
90
  model = json_body.get('model', 'claude-3-opus-20240229') # 动态获取模型,默认 claude-3-opus-20240229
91
  stream = json_body.get('stream', True) # 默认为True
92
- previous_messages = "\n\n".join([msg['content'] for msg in json_body['messages']])
 
 
 
 
 
93
  msg_id = str(uuid.uuid4())
94
  response_event = Event()
95
  response_text = []
 
89
  json_body = request.json
90
  model = json_body.get('model', 'claude-3-opus-20240229') # 动态获取模型,默认 claude-3-opus-20240229
91
  stream = json_body.get('stream', True) # 默认为True
92
+
93
+ # 确保 msg['content'] 是字符串,如果是列表则将其 join 成字符串
94
+ previous_messages = "\n\n".join(
95
+ [msg['content'] if isinstance(msg['content'], str) else " ".join(msg['content']) for msg in json_body['messages']]
96
+ )
97
+
98
  msg_id = str(uuid.uuid4())
99
  response_event = Event()
100
  response_text = []