Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ def process_csv(file, calculate_openai, openai_model, calculate_anthropic, anthr
|
|
21 |
openai_encoding = tiktoken.encoding_for_model(openai_model)
|
22 |
except KeyError:
|
23 |
# Default encoding if model is not found
|
24 |
-
openai_encoding = tiktoken.get_encoding("cl100k_base")
|
25 |
|
26 |
token_counts_openai = {}
|
27 |
total_tokens_openai = 0
|
@@ -80,7 +80,7 @@ def main():
|
|
80 |
gr.Markdown("Upload a CSV file to see token counts per column and total tokens.")
|
81 |
|
82 |
with gr.Row():
|
83 |
-
file_input = gr.File(label="Upload CSV File", type="
|
84 |
|
85 |
with gr.Row():
|
86 |
calculate_openai = gr.Checkbox(label="Calculate tokens for OpenAI models")
|
@@ -88,12 +88,12 @@ def main():
|
|
88 |
|
89 |
with gr.Row():
|
90 |
openai_model = gr.Dropdown(
|
91 |
-
choices=['gpt-
|
92 |
label="Select OpenAI Model",
|
93 |
visible=False
|
94 |
)
|
95 |
anthropic_model = gr.Dropdown(
|
96 |
-
choices=['claude-
|
97 |
label="Select Anthropic Model",
|
98 |
visible=False
|
99 |
)
|
|
|
21 |
openai_encoding = tiktoken.encoding_for_model(openai_model)
|
22 |
except KeyError:
|
23 |
# Default encoding if model is not found
|
24 |
+
openai_encoding = tiktoken.get_encoding("cl100k_base") #("o200k_base") # https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
|
25 |
|
26 |
token_counts_openai = {}
|
27 |
total_tokens_openai = 0
|
|
|
80 |
gr.Markdown("Upload a CSV file to see token counts per column and total tokens.")
|
81 |
|
82 |
with gr.Row():
|
83 |
+
file_input = gr.File(label="Upload CSV File", type="filepath")
|
84 |
|
85 |
with gr.Row():
|
86 |
calculate_openai = gr.Checkbox(label="Calculate tokens for OpenAI models")
|
|
|
88 |
|
89 |
with gr.Row():
|
90 |
openai_model = gr.Dropdown(
|
91 |
+
choices=['gpt-4o', 'gpt-4o-mini', 'gpt-4'],
|
92 |
label="Select OpenAI Model",
|
93 |
visible=False
|
94 |
)
|
95 |
anthropic_model = gr.Dropdown(
|
96 |
+
choices=['claude-3-5-sonnet-latest', 'claude-3-5-haiku-latest', 'claude-3-opus-latest'],
|
97 |
label="Select Anthropic Model",
|
98 |
visible=False
|
99 |
)
|