Spaces:
Sleeping
Sleeping
File size: 914 Bytes
6f4a389 | 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 typing import Any, Optional
class SimpleTool(Tool):
name = "summarize_topic"
description = "This agent uses a web search tool to getch search results for the provided topic and the summarizes them and\nreturns the summary"
inputs = {"topic":{"type":"string","description":"The topic to provide summary for"}}
output_type = "string"
def forward(self, topic: str) -> str:
"""
This agent uses a web search tool to getch search results for the provided topic and the summarizes them and
returns the summary
Args:
topic: The topic to provide summary for
"""
from transformers import pipeline
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
summary = summarizer(topic, max_length=100, min_length=30, do_sample=False)
return summary[0]['summary_text'] |