jinv2 commited on
Commit
145c0bd
·
verified ·
1 Parent(s): 4a16b87

Update app.py

Browse files

Ensure direct access to response.summary_text

Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -16,7 +16,8 @@ try:
16
  try:
17
  response = client.summarization(text)
18
  print(f"API Response: {response}")
19
- return response[0]['summary_text'] if response and 'summary_text' in response[0] else "摘要生成失败,请重试。"
 
20
  except Exception as e:
21
  error_details = traceback.format_exc()
22
  print(f"尝试失败,错误类型: {type(e).__name__}, 错误详情: {str(e)}, 堆栈: {error_details}")
 
16
  try:
17
  response = client.summarization(text)
18
  print(f"API Response: {response}")
19
+ # 直接访问 response.summary_text
20
+ return response.summary_text if hasattr(response, 'summary_text') else "摘要生成失败,请重试。"
21
  except Exception as e:
22
  error_details = traceback.format_exc()
23
  print(f"尝试失败,错误类型: {type(e).__name__}, 错误详情: {str(e)}, 堆栈: {error_details}")