Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,9 @@ encodings = tiktoken.list_encoding_names()
|
|
5 |
encodings.reverse()
|
6 |
|
7 |
|
8 |
-
def calc(input: str, encoding: str) -> int:
|
9 |
tokens = tiktoken.get_encoding(encoding).encode(input)
|
10 |
-
return len(tokens)
|
11 |
|
12 |
|
13 |
gr.Interface(
|
@@ -21,7 +21,10 @@ gr.Interface(
|
|
21 |
info="The encoding to use. (GPT-3.5 and GPT-4 use cl100k_base as their encoding.)",
|
22 |
),
|
23 |
],
|
24 |
-
outputs=
|
|
|
|
|
|
|
25 |
title="Tiktoken Calculator",
|
26 |
allow_flagging="never",
|
27 |
-
).launch()
|
|
|
5 |
encodings.reverse()
|
6 |
|
7 |
|
8 |
+
def calc(input: str, encoding: str) -> (int, int):
|
9 |
tokens = tiktoken.get_encoding(encoding).encode(input)
|
10 |
+
return len(input), len(tokens)
|
11 |
|
12 |
|
13 |
gr.Interface(
|
|
|
21 |
info="The encoding to use. (GPT-3.5 and GPT-4 use cl100k_base as their encoding.)",
|
22 |
),
|
23 |
],
|
24 |
+
outputs=[
|
25 |
+
gr.Number(label="Character Count", type="int"),
|
26 |
+
gr.Number(label="Token Count", type="int"),
|
27 |
+
],
|
28 |
title="Tiktoken Calculator",
|
29 |
allow_flagging="never",
|
30 |
+
).launch()
|