Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
def topn_tokens(sequence, n):
|
| 4 |
-
chars =
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
return
|
| 8 |
-
|
| 9 |
-
|
| 10 |
demo = gr.Interface(
|
| 11 |
topn_tokens,
|
| 12 |
[
|
| 13 |
"text",
|
| 14 |
-
gr.Dropdown([
|
| 15 |
],
|
| 16 |
"dataframe",
|
| 17 |
description="Choose a number between 1-20 to display n tokens",
|
| 18 |
)
|
| 19 |
|
| 20 |
if __name__ == "__main__":
|
| 21 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
|
| 4 |
def topn_tokens(sequence, n):
|
| 5 |
+
chars = list(sequence)
|
| 6 |
+
n_column = [n] * len(chars) # Create a column with the chosen integer repeated
|
| 7 |
+
df = pd.DataFrame({'Character': chars, 'N': n_column}) # Create the DataFrame
|
| 8 |
+
return df
|
| 9 |
+
|
|
|
|
| 10 |
demo = gr.Interface(
|
| 11 |
topn_tokens,
|
| 12 |
[
|
| 13 |
"text",
|
| 14 |
+
gr.Dropdown([int(i) for i in range(1, 21)]), # Dropdown with numbers from 1 to 20
|
| 15 |
],
|
| 16 |
"dataframe",
|
| 17 |
description="Choose a number between 1-20 to display n tokens",
|
| 18 |
)
|
| 19 |
|
| 20 |
if __name__ == "__main__":
|
| 21 |
+
demo.launch()
|