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