ankban commited on
Commit
e0baf3c
Β·
verified Β·
1 Parent(s): 434302e

Create file_module.py

Browse files
Files changed (1) hide show
  1. file_module.py +49 -0
file_module.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from tempfile import NamedTemporaryFile
4
+
5
+
6
+ def file_dashboard():
7
+ with gr.Column() as file_panel:
8
+ gr.Markdown("""
9
+ <div style='text-align: center;'>
10
+ <img src='file/images/chatter_owl.png' width='120'>
11
+ <h2>πŸ“„ File-Based Learning with <strong>Chatter the Owl</strong></h2>
12
+ <p>Upload your notes, textbooks, or slides, and let me turn them into summaries, quizzes, and flashcards!</p>
13
+ </div>
14
+ """)
15
+
16
+ file_upload = gr.File(label="πŸ“ Upload Your Study Material", file_types=[".pdf", ".txt", ".md", ".pptx"])
17
+ question_box = gr.Textbox(label="πŸ’¬ Ask a question about the uploaded file")
18
+
19
+ with gr.Tabs():
20
+ with gr.Tab("πŸ“š Summary"):
21
+ summary_output = gr.Textbox(label="Generated Summary", lines=8, interactive=False)
22
+ with gr.Tab("🧠 Flashcards"):
23
+ flashcard_output = gr.Textbox(label="Generated Flashcards", lines=8, interactive=False)
24
+ with gr.Tab("❓ Quiz"):
25
+ quiz_output = gr.Textbox(label="Generated Quiz Questions", lines=8, interactive=False)
26
+ with gr.Tab("πŸ’¬ Answer to Your Question"):
27
+ answer_output = gr.Textbox(label="Answer", lines=4, interactive=False)
28
+
29
+ def placeholder_logic(file, question):
30
+ # Placeholder logic until GPT + parsing is added
31
+ summary = "This is a summary of your uploaded content."
32
+ flashcards = "Flashcard 1: Question? | Answer.\nFlashcard 2: Question? | Answer."
33
+ quiz = "1. What is...?\n2. Explain..."
34
+ answer = f"You asked: {question}\nHere's a helpful answer from your content."
35
+ return summary, flashcards, quiz, answer
36
+
37
+ file_upload.change(
38
+ fn=lambda file: placeholder_logic(file, ""),
39
+ inputs=[file_upload],
40
+ outputs=[summary_output, flashcard_output, quiz_output, answer_output]
41
+ )
42
+
43
+ question_box.change(
44
+ fn=lambda question: placeholder_logic(None, question),
45
+ inputs=[question_box],
46
+ outputs=[summary_output, flashcard_output, quiz_output, answer_output]
47
+ )
48
+
49
+ return file_panel