Spaces:
Runtime error
Runtime error
Update app.py
Browse filesSwitch to google/pegasus-xsum for better summarization
9 unmodified lines101112131415161718192021229 unmodified linesprint(f"HF_TOKEN loaded: {len(HF_TOKEN) if HF_TOKEN else 0} characters")try:client = InferenceClient(model="facebook/mbart-large-50", token=HF_TOKEN)def generate_summary(text):for _ in range(3):try:response = client.summarization(text)print(f"API Response: {response}")# 优先使用 generated_text,如果为空则尝试 summary_textif hasattr(response, 'generated_text') and response.generated_text:return response.generated_textelif hasattr(response, 'summary_text') and response.summary_text:9 unmodified lines1011121314151617181920219 unmodified linesprint(f"HF_TOKEN loaded: {len(HF_TOKEN) if HF_TOKEN else 0} characters")try:client = InferenceClient(model="google/pegasus-xsum", token=HF_TOKEN)def generate_summary(text):for _ in range(3):try:response = client.summarization(text, max_length=50, min_length=10, num_beams=4)print(f"API Response: {response}")if hasattr(response, 'generated_text') and response.generated_text:return response.generated_textelif hasattr(response, 'summary_text') and response.summary_text:
app.py+2-3