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

Upload 2 files

Browse files
Files changed (1) hide show
  1. free_ask_internet.py +1 -18
free_ask_internet.py CHANGED
@@ -218,24 +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
- if not response.text:
223
- return "Empty response from the server"
224
-
225
- try:
226
- response_json = response.json()
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
 
 
218
  'Authorization': 'Bearer {}'.format(pooltoken),
219
  }
220
  response = requests.post( apiurl + '/chat/completions', headers=headers, json=json_data )
221
+ res = json.loads(response.text)['choices'][0]['message']['content']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  #print(res)
223
  return res
224