Spaces:
Sleeping
Sleeping
Update app.py
Browse filesFix summarization API call by removing unsupported max_length
app.py
CHANGED
|
@@ -5,11 +5,10 @@ import time
|
|
| 5 |
try:
|
| 6 |
client = InferenceClient(model="sshleifer/distilbart-cnn-12-6")
|
| 7 |
def generate_summary(text):
|
| 8 |
-
prompt = text # 直接传入文本,无需额外提示
|
| 9 |
for _ in range(3): # 重试3次
|
| 10 |
try:
|
| 11 |
-
response = client.summarization(
|
| 12 |
-
return response[0]['summary_text']
|
| 13 |
except Exception as e:
|
| 14 |
print(f"尝试失败: {e}")
|
| 15 |
time.sleep(1)
|
|
|
|
| 5 |
try:
|
| 6 |
client = InferenceClient(model="sshleifer/distilbart-cnn-12-6")
|
| 7 |
def generate_summary(text):
|
|
|
|
| 8 |
for _ in range(3): # 重试3次
|
| 9 |
try:
|
| 10 |
+
response = client.summarization(inputs=text)
|
| 11 |
+
return response[0]['summary_text'] if response and 'summary_text' in response[0] else "摘要生成失败,请重试。"
|
| 12 |
except Exception as e:
|
| 13 |
print(f"尝试失败: {e}")
|
| 14 |
time.sleep(1)
|