csujeong commited on
Commit
b92686c
1 Parent(s): 4f34e0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
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=gr.Number(label="Output"),
 
 
 
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()