from future import annotations
import bentoml
from transformers import pipeline
EXAMPLE_INPUT = "Breaking News: In an astonishing turn of events, the small town of Willow Creek has been taken by storm as local resident Jerry Thompson's cat, Whiskers, performed what witnesses are calling a 'miraculous and gravity-defying leap.' Eyewitnesses report that Whiskers, an otherwise unremarkable tabby cat, jumped a record-breaking 20 feet into the air to catch a fly. The event, which took place in Thompson's backyard, is now being investigated by scientists for potential breaches in the laws of physics. Local authorities are considering a town festival to celebrate what is being hailed as 'The Leap of the Century.'"
@bentoml.service(
resources={"cpu": "2"},
traffic={"timeout": 10},
)
class Summarization:
def __init__(self) -> None:
self.pipeline = pipeline('summarization')
@bentoml.api
def summarize(self, text: str = EXAMPLE_INPUT) -> str:
# Use bentoml.monitor as a context manager
with bentoml.monitor("text_summarization") as mon:
# Log the input data
mon.log(text, name="input_text", role="original_text", data_type="text")
result = self.pipeline(text)
summary_text = result[0]['summary_text']
# Log the output data
mon.log(summary_text, name="summarized_text", role="prediction", data_type="text")
return summary_text
Here we not able use artifacts how we can suppose we do that