belalmunsh commited on
Commit
193d727
1 Parent(s): 245e680

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -41
app.py CHANGED
@@ -1,41 +1,15 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
- import pdf2image
4
- import pytesseract
5
-
6
- # Initialize model
7
- qa_model = pipeline("question-answering")
8
-
9
- def process_pdf(pdf_file):
10
- # Convert PDF to text
11
- text = extract_text_from_pdf(pdf_file)
12
- return text
13
-
14
- def answer_question(question, context):
15
- # Get answer from model
16
- answer = qa_model(question=question, context=context)
17
- return answer['answer']
18
-
19
- # Create interface
20
- with gr.Blocks() as demo:
21
- gr.Markdown("# My Study Assistant")
22
-
23
- # File upload
24
- file_input = gr.File(label="Upload PDF")
25
-
26
- # Text display
27
- text_output = gr.Textbox(label="Extracted Text")
28
-
29
- # Chat interface
30
- question = gr.Textbox(label="Ask a question")
31
- answer = gr.Textbox(label="Answer")
32
-
33
- # Buttons
34
- upload_btn = gr.Button("Process PDF")
35
- ask_btn = gr.Button("Ask")
36
-
37
- # Set up actions
38
- upload_btn.click(process_pdf, inputs=file_input, outputs=text_output)
39
- ask_btn.click(answer_question, inputs=[question, text_output], outputs=answer)
40
-
41
- demo.launch()
 
1
+ STUDY_PROMPTS = {
2
+ "analyze": """
3
+ Analyze this text following these rules:
4
+ 1. Identify key concepts
5
+ 2. Break down complex terms
6
+ 3. Provide examples
7
+ 4. Link to prerequisites
8
+ """,
9
+ "practice": """
10
+ Create practice materials:
11
+ 1. Generate questions
12
+ 2. Provide sample problems
13
+ 3. Include answer explanations
14
+ """
15
+ }