Spaces:
Sleeping
Sleeping
Update token_counter.py
Browse files- token_counter.py +5 -7
token_counter.py
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
from transformers import AutoTokenizer
|
2 |
from transformers import Tool
|
3 |
|
4 |
-
class
|
5 |
-
name = "
|
6 |
-
description = "This is a tool for counting
|
7 |
inputs = ["text"]
|
8 |
outputs = ["text"]
|
9 |
|
10 |
def __call__(self, prompt: str):
|
11 |
-
|
12 |
-
|
13 |
-
tokens = tokenizer(prompt)["input_ids"]
|
14 |
-
return f"{len(tokens)}"
|
15 |
|
|
|
1 |
from transformers import AutoTokenizer
|
2 |
from transformers import Tool
|
3 |
|
4 |
+
class WordCounterTool(Tool):
|
5 |
+
name = "word_counter"
|
6 |
+
description = "This is a tool for counting word of an input."
|
7 |
inputs = ["text"]
|
8 |
outputs = ["text"]
|
9 |
|
10 |
def __call__(self, prompt: str):
|
11 |
+
words = str.split(" ")
|
12 |
+
return len(words)
|
|
|
|
|
13 |
|