deeme commited on
Commit
746f985
·
verified ·
1 Parent(s): b09319c

Upload free_ask_internet.py

Browse files
Files changed (1) hide show
  1. free_ask_internet.py +5 -7
free_ask_internet.py CHANGED
@@ -218,8 +218,7 @@ def summary_gpt(message, model:str, debug=False):
218
  'Authorization': 'Bearer {}'.format(pooltoken),
219
  }
220
  response = requests.post( apiurl + '/chat/completions', headers=headers, json=json_data )
221
-
222
- # 检查响应内容是否为空
223
  if not response.text:
224
  return "Empty response from the server"
225
 
@@ -228,16 +227,15 @@ def summary_gpt(message, model:str, debug=False):
228
  except json.JSONDecodeError:
229
  return msgs
230
 
231
- # 检查响应中是否有 choices 字段,并且至少有一个元素
232
  if 'choices' in response_json and response_json['choices']:
233
- # 检查 choices 中的第一个元素是否有 message 字段
234
  if 'message' in response_json['choices'][0]:
235
  res = response_json['choices'][0]['message'].get('content', '')
236
  else:
237
- res = ''
238
  else:
239
- res = ''
240
-
241
  #print(res)
242
  return res
243
 
 
218
  'Authorization': 'Bearer {}'.format(pooltoken),
219
  }
220
  response = requests.post( apiurl + '/chat/completions', headers=headers, json=json_data )
221
+ # 检查响应内容是否为空
 
222
  if not response.text:
223
  return "Empty response from the server"
224
 
 
227
  except json.JSONDecodeError:
228
  return msgs
229
 
230
+ # 检查响应中是否有choices字段,并且至少有一个元素
231
  if 'choices' in response_json and response_json['choices']:
232
+ # 检查choices中的第一个元素是否有message字段
233
  if 'message' in response_json['choices'][0]:
234
  res = response_json['choices'][0]['message'].get('content', '')
235
  else:
236
+ res = msgs
237
  else:
238
+ res = msgs
 
239
  #print(res)
240
  return res
241