luminoussg commited on
Commit
169e43b
·
verified ·
1 Parent(s): ececca0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import tiktoken
3
  import json
 
4
 
5
  # Function to count tokens in the dataset based on the "messages" field
6
  def count_tokens(json_file, encoding_name):
@@ -58,6 +59,15 @@ with gr.Blocks() as app:
58
  json_input = gr.File(label="Upload JSON/JSONL File")
59
  encoding_dropdown = gr.Dropdown(choices=encoding_options, label="Select Encoding", value="o200k_base (gpt-4o, gpt-4o-mini)")
60
 
 
 
 
 
 
 
 
 
 
61
  # Output for individual conversation token counts
62
  conversation_output = gr.JSON(label="Token Counts per Conversation")
63
 
 
1
  import gradio as gr
2
  import tiktoken
3
  import json
4
+ import os
5
 
6
  # Function to count tokens in the dataset based on the "messages" field
7
  def count_tokens(json_file, encoding_name):
 
59
  json_input = gr.File(label="Upload JSON/JSONL File")
60
  encoding_dropdown = gr.Dropdown(choices=encoding_options, label="Select Encoding", value="o200k_base (gpt-4o, gpt-4o-mini)")
61
 
62
+ # Example file (this will automatically upload when clicked)
63
+ example_file_path = "keivalyaMedQuad-MedicalQnADataset_valid.jsonl"
64
+ if os.path.exists(example_file_path):
65
+ example = gr.Examples(
66
+ examples=[example_file_path],
67
+ inputs=json_input,
68
+ label="Click here to load the example file"
69
+ )
70
+
71
  # Output for individual conversation token counts
72
  conversation_output = gr.JSON(label="Token Counts per Conversation")
73