ankban commited on
Commit
b5831f8
ยท
verified ยท
1 Parent(s): dc42d6a

Update file_viewer_panel.py

Browse files
Files changed (1) hide show
  1. file_viewer_panel.py +13 -26
file_viewer_panel.py CHANGED
@@ -11,14 +11,14 @@ def file_viewer_dashboard(nickname_input):
11
  file_text_state = gr.State("")
12
  chat_history = gr.State([])
13
 
14
- chat_input = gr.Textbox(label="๐Ÿ” Ask about the file")
15
  chat_output = gr.Chatbot()
16
 
17
- btn_accessible = gr.Button("โ™ฟ๏ธ Improve Accessibility")
18
- accessible_box = gr.Textbox(label="๐ŸŒ Easier-to-Read Version", lines=15, interactive=False)
 
19
 
20
- btn_readability = gr.Button("๐Ÿงพ Improve Readability", size="sm")
21
- readable_box = gr.Textbox(label="๐Ÿ“˜ Reformatted Version", lines=15, interactive=False)
22
 
23
  quiz_btn = gr.Button("๐Ÿง  Generate Quiz")
24
  quiz_score = gr.Textbox(label="Your Score", interactive=False, visible=False)
@@ -36,27 +36,14 @@ def file_viewer_dashboard(nickname_input):
36
  history.append((query, answer))
37
  return history, ""
38
 
39
- def make_accessible_version(text):
40
  prompt = f"""
41
- You are an expert in reading accessibility.
42
- Reformat the following content to improve readability and make it easier to follow:
43
  - Use simple language
44
- - Break long paragraphs
45
- - Use bullet points or headings when appropriate
46
- - Preserve the meaning clearly
47
-
48
- Text:
49
- {text}
50
- """
51
- return call_llm(prompt)
52
-
53
- def improve_readability(text):
54
- prompt = f"""
55
- Please rewrite the following content to improve readability:
56
- - Increase spacing
57
- - Use larger font and clearer structure (for display purposes)
58
- - Break into shorter paragraphs or bullet points
59
- - Keep the meaning intact
60
 
61
  Text:
62
  {text}
@@ -86,9 +73,9 @@ Text:
86
  return gr.update(visible=False), [], gr.update(visible=True, value="Error generating quiz.")
87
 
88
  file_upload.change(fn=load_and_preview, inputs=[file_upload], outputs=[preview, file_text_state])
 
89
  chat_input.submit(fn=handle_chat, inputs=[chat_input, file_text_state, chat_history], outputs=[chat_output, chat_input])
90
- btn_accessible.click(fn=make_accessible_version, inputs=[file_text_state], outputs=[accessible_box])
91
- btn_readability.click(fn=improve_readability, inputs=[file_text_state], outputs=[readable_box])
92
  quiz_btn.click(fn=generate_quiz, inputs=[file_text_state], outputs=[quiz_box, quiz_box, quiz_score])
93
 
94
  return file_panel
 
11
  file_text_state = gr.State("")
12
  chat_history = gr.State([])
13
 
 
14
  chat_output = gr.Chatbot()
15
 
16
+ with gr.Row():
17
+ chat_input = gr.Textbox(placeholder="Ask about the file...", label=None, lines=1)
18
+ send_btn = gr.Button("๐Ÿ“ค", size="sm", elem_id="send-btn")
19
 
20
+ btn_simplify = gr.Button("๐Ÿงพ Simplify Content")
21
+ simplified_box = gr.Textbox(label="๐Ÿ“˜ Simplified File Version", lines=15, interactive=False)
22
 
23
  quiz_btn = gr.Button("๐Ÿง  Generate Quiz")
24
  quiz_score = gr.Textbox(label="Your Score", interactive=False, visible=False)
 
36
  history.append((query, answer))
37
  return history, ""
38
 
39
+ def simplify_content(text):
40
  prompt = f"""
41
+ Reformat the following content to improve readability and clarity:
 
42
  - Use simple language
43
+ - Shorter paragraphs
44
+ - Larger font layout (for display)
45
+ - Use clear sections or bullet points when needed
46
+ - Preserve all original meaning
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  Text:
49
  {text}
 
73
  return gr.update(visible=False), [], gr.update(visible=True, value="Error generating quiz.")
74
 
75
  file_upload.change(fn=load_and_preview, inputs=[file_upload], outputs=[preview, file_text_state])
76
+ send_btn.click(fn=handle_chat, inputs=[chat_input, file_text_state, chat_history], outputs=[chat_output, chat_input])
77
  chat_input.submit(fn=handle_chat, inputs=[chat_input, file_text_state, chat_history], outputs=[chat_output, chat_input])
78
+ btn_simplify.click(fn=simplify_content, inputs=[file_text_state], outputs=[simplified_box])
 
79
  quiz_btn.click(fn=generate_quiz, inputs=[file_text_state], outputs=[quiz_box, quiz_box, quiz_score])
80
 
81
  return file_panel