Update file_viewer_panel.py
Browse files4 unmodified lines5678910111213141516171819202122238 unmodified lines3233343536373830 unmodified lines6970717273744 unmodified linesdef file_viewer_dashboard(nickname_input):with gr.Column(scale=4, elem_id="main-column") as file_panel:file_upload = gr.File(label="π Upload a File", file_types=[".pdf", ".txt", ".md", ".pptx"])preview = gr.Textbox(label="π File Content Preview", lines=10, interactive=False)file_text_state = gr.State("")chat_input = gr.Textbox(label="π Ask about the file")chat_output = gr.Chatbot()btn_accessible = gr.Button("βΏοΈ Improve Accessibility")accessible_box = gr.Textbox(label="π Easier-to-Read Version", lines=15, interactive=False)quiz_box = gr.Column(visible=False)quiz_score = gr.Textbox(label="Your Score", interactive=False, visible=False)def load_and_preview(file):if not file:8 unmodified linesdef make_accessible_version(text):prompt = f"""You are an expert in reading accessibility.Reformat the following content to improve readability and make it easier to follow:- Use simple language- Break long paragraphs30 unmodified linesfile_upload.change(fn=load_and_preview, inputs=[file_upload], outputs=[preview, file_text_state])chat_input.submit(fn=handle_chat, inputs=[chat_input, file_text_state], outputs=[chat_output])btn_accessible.click(fn=make_accessible_version, inputs=[file_text_state], outputs=[accessible_box])gr.Button("π§ Generate Quiz").click(fn=generate_quiz, inputs=[file_text_state], outputs=[quiz_box, quiz_box, quiz_score])return file_panel4 unmodified lines5678910111213141516171819202122232425262728298 unmodified lines38394041424330 unmodified lines7475767778794 unmodified linesdef file_viewer_dashboard(nickname_input):with gr.Column(scale=4, elem_id="main-column") as file_panel:with gr.Row():file_upload = gr.File(label="π Upload a File", file_types=[".pdf", ".txt", ".md", ".pptx"])preview = gr.Textbox(label="π File Content Preview", lines=10, interactive=False)file_text_state = gr.State("")with gr.Row():chat_input = gr.Textbox(label="π Ask about the file")chat_output = gr.Chatbot()with gr.Row():btn_accessible = gr.Button("βΏοΈ Improve Accessibility")accessible_box = gr.Textbox(label="π Easier-to-Read Version", lines=15, interactive=False)with gr.Row():quiz_btn = gr.Button("π§ Generate Quiz")quiz_score = gr.Textbox(label="Your Score", interactive=False, visible=False)quiz_box = gr.Column(visible=False)def load_and_preview(file):if not file:8 unmodified linesdef make_accessible_version(text):prompt = f"""You are an expert in reading accessibility.Reformat the following content to improve readability and make it easier to follow:- Use simple language- Break long paragraphs30 unmodified linesfile_upload.change(fn=load_and_preview, inputs=[file_upload], outputs=[preview, file_text_state])chat_input.submit(fn=handle_chat, inputs=[chat_input, file_text_state], outputs=[chat_output])btn_accessible.click(fn=make_accessible_version, inputs=[file_text_state], outputs=[accessible_box])quiz_btn.click(fn=generate_quiz, inputs=[file_text_state], outputs=[quiz_box, quiz_box, quiz_score])return file_panel
file_viewer_panel.py+15-10