sentence-counter-tool / word_counter.py
Chris4K's picture
Rename token_counter.py to word_counter.py
c5f1f1e
raw
history blame
339 Bytes
from transformers import AutoTokenizer
from transformers import Tool
class WordCounterTool(Tool):
name = "word_counter"
description = "This is a tool for counting word of an input."
inputs = ["text"]
outputs = ["text"]
def __call__(self, prompt: str):
words = str.split(" ")
return len(words)