File size: 488 Bytes
6230b38
 
 
 
 
 
538b711
b2746c2
 
 
 
 
 
 
 
 
538b711
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from smolagents import tool
from transformers import pipeline

summarizer = pipeline("summarization")

@tool
def summarize(input: str) -> str:
    """
    Returns a summarized version of the input text.

    Args:
        input (str): The text to be summarized.

    Returns:
        str: Concise summary of the input.
    """
    if len(input) < 50:
        return input
    result = summarizer(input, max_length=100, min_length=25, do_sample=False)
    return result[0]['summary_text']