Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import pyperclip | |
| import pickle | |
| import random | |
| # Open the pickle file in read mode | |
| with open("data.pickle", "rb") as file: | |
| # Load the pickled dictionary from the file | |
| data = pickle.load(file) | |
| # Print the dictionary | |
| def classify_text(num, word): | |
| list_inputs = data[num][word] | |
| random.shuffle(list_inputs) | |
| prompt = '\n\n'.join(list_inputs) | |
| return prompt + f'\n\nstreść powyższe teksty i scal je w jeden rozdział zatytuowany "{word}"' | |
| def copy_to_clipboard(text, button): | |
| pyperclip.copy(text) | |
| button = 'Copied' | |
| with gr.Blocks() as interface: | |
| gr.Markdown( | |
| """ | |
| # <center>AA report generator hepler</center> | |
| Wybierz numer ćwiczenia, sekcję i przeklej tekst do ChatGPT. | |
| """) | |
| with gr.Row(): | |
| with gr.Column(): | |
| inputs = gr.Dropdown(choices=list(range(10)), label="Numer ćwiczenia", value=0) | |
| inputs2 = gr.Radio(choices=["wstęp", "opis stanowiska", "realizacja ćwiczenia", "wnioski"], label="Sekcja", value='wstęp') | |
| button = gr.Button(value="Copy to clipboard") | |
| with gr.Column(): | |
| output = gr.Textbox(label="Tekst do przeklejenia", value=classify_text(0, 'wstęp')) | |
| inputs.change(classify_text, [inputs, inputs2], output) | |
| inputs2.change(classify_text, [inputs, inputs2], output) | |
| button.click(copy_to_clipboard, [output, button], None) | |
| interface.launch(inline=False) | |