Spaces:
Sleeping
Sleeping
File size: 750 Bytes
3ccf31a 84d475c 3ccf31a cc63aca 3ccf31a 84d475c 3ccf31a 84d475c 3ccf31a 84d475c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Add parent directory to Python path
import sys, os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from scripts.t5_model import summarize_with_t5
from scripts.bart_model import summarize_with_bart
def summarize_text(text: str, model_type: str = "t5-small") -> str:
"""
Summarizes input text using either T5 or BART.
"""
if not text.strip():
return "No input text provided."
if model_type == "Get a super short summary (*t5*)":
return summarize_with_t5(text)
elif model_type == "Summarise long text (*bart*)":
return summarize_with_bart(text)
else:
return "Invalid model type. Choose 'Get a super short summary (*t5*)' or 'Summarise long text (*bart*)'." |