shukdevdatta123 commited on
Commit
2809a57
Β·
verified Β·
1 Parent(s): b1ea736

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +357 -342
app.py CHANGED
@@ -5,344 +5,359 @@ from openai import OpenAI
5
  import io
6
  import json
7
  import time
8
- from typing import List, Dict, Any
9
  import spaces
10
 
11
- class EducationalContentCreator:
12
- def __init__(self):
13
- self.client = None
14
- self.document_text = ""
15
- self.model = "google/gemma-3-27b-it:free"
16
-
17
- def setup_client(self, api_key: str):
18
- """Initialize OpenAI client with OpenRouter"""
19
- try:
20
- self.client = OpenAI(
21
- base_url="https://openrouter.ai/api/v1",
22
- api_key=api_key,
23
- )
24
- return "βœ… API Key configured successfully!"
25
- except Exception as e:
26
- return f"❌ Error configuring API: {str(e)}"
27
-
28
- def extract_text_from_pdf(self, file_path: str) -> str:
29
- """Extract text from PDF file"""
30
- try:
31
- with open(file_path, 'rb') as file:
32
- pdf_reader = PyPDF2.PdfReader(file)
33
- text = ""
34
- for page in pdf_reader.pages:
35
- text += page.extract_text() + "\n"
36
- return text
37
- except Exception as e:
38
- return f"Error reading PDF: {str(e)}"
39
-
40
- def extract_text_from_docx(self, file_path: str) -> str:
41
- """Extract text from DOCX file"""
42
- try:
43
- doc = docx.Document(file_path)
 
44
  text = ""
45
- for paragraph in doc.paragraphs:
46
- text += paragraph.text + "\n"
47
  return text
48
- except Exception as e:
49
- return f"Error reading DOCX: {str(e)}"
50
-
51
- @spaces.GPU
52
- def process_document(self, file):
53
- """Process uploaded document and extract text"""
54
- if file is None:
55
- return "❌ No file uploaded"
56
-
57
- file_path = file.name
58
- file_extension = file_path.lower().split('.')[-1]
59
-
60
- if file_extension == 'pdf':
61
- self.document_text = self.extract_text_from_pdf(file_path)
62
- elif file_extension in ['docx', 'doc']:
63
- self.document_text = self.extract_text_from_docx(file_path)
64
- else:
65
- return "❌ Unsupported file format. Please upload PDF or DOCX files."
66
-
67
- if self.document_text and len(self.document_text.strip()) > 0:
68
- word_count = len(self.document_text.split())
69
- return f"βœ… Document processed successfully!\nπŸ“„ Word count: {word_count}\nπŸ“ Preview: {self.document_text[:200]}..."
70
- else:
71
- return "❌ Could not extract text from the document"
72
-
73
- @spaces.GPU
74
- def generate_content(self, prompt: str, max_tokens: int = 2000) -> str:
75
- """Generate content using the AI model"""
76
- if not self.client:
77
- return "❌ Please configure your API key first"
78
-
79
- if not self.document_text:
80
- return "❌ Please upload and process a document first"
81
-
82
- try:
83
- completion = self.client.chat.completions.create(
84
- extra_headers={
85
- "HTTP-Referer": "https://educational-assistant.app",
86
- "X-Title": "Educational Content Creator",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  },
88
- model=self.model,
89
- messages=[
90
- {
91
- "role": "system",
92
- "content": "You are an expert educational content creator. Create comprehensive, engaging, and pedagogically sound educational materials based on the provided document content."
93
- },
94
- {
95
- "role": "user",
96
- "content": f"Document Content:\n{self.document_text}\n\n{prompt}"
97
- }
98
- ],
99
- max_tokens=max_tokens,
100
- temperature=0.7
101
- )
102
- return completion.choices[0].message.content
103
- except Exception as e:
104
- return f"❌ Error generating content: {str(e)}"
105
-
106
- @spaces.GPU
107
- def generate_summary(self):
108
- """Generate comprehensive summary"""
109
- prompt = """Create a comprehensive summary of this document with the following structure:
110
-
111
- ## πŸ“‹ Executive Summary
112
- Provide a brief overview in 2-3 sentences.
113
-
114
- ## 🎯 Key Points
115
- List the main concepts, ideas, or arguments presented.
116
-
117
- ## πŸ“š Detailed Summary
118
- Provide a thorough summary organized by topics or sections.
119
-
120
- ## πŸ’‘ Important Takeaways
121
- Highlight the most crucial information students should remember.
122
- """
123
- return self.generate_content(prompt)
124
-
125
- @spaces.GPU
126
- def generate_study_notes(self):
127
- """Generate structured study notes"""
128
- prompt = """Create comprehensive study notes from this document with:
129
-
130
- ## πŸ“– Study Notes
131
-
132
- ### πŸ”‘ Key Concepts
133
- - Define important terms and concepts
134
- - Explain their significance
135
-
136
- ### πŸ“Š Main Topics
137
- Organize content into clear sections with:
138
- - Topic headings
139
- - Key points under each topic
140
- - Supporting details and examples
141
-
142
- ### 🧠 Memory Aids
143
- - Create mnemonics for complex information
144
- - Suggest visualization techniques
145
- - Provide connection points between concepts
146
-
147
- ### ⚑ Quick Review Points
148
- - Bullet points for rapid review
149
- - Essential facts and figures
150
- """
151
- return self.generate_content(prompt)
152
-
153
- @spaces.GPU
154
- def generate_quiz(self):
155
- """Generate quiz questions"""
156
- prompt = """Create a comprehensive quiz based on this document:
157
-
158
- ## πŸ“ Quiz Questions
159
-
160
- ### Multiple Choice Questions (5 questions)
161
- For each question, provide:
162
- - Clear question
163
- - 4 options (A, B, C, D)
164
- - Correct answer
165
- - Brief explanation
166
-
167
- ### Short Answer Questions (5 questions)
168
- - Questions requiring 2-3 sentence answers
169
- - Cover key concepts and applications
170
-
171
- ### Essay Questions (2 questions)
172
- - Thought-provoking questions requiring detailed responses
173
- - Focus on analysis, synthesis, or evaluation
174
-
175
- ### Answer Key
176
- Provide all correct answers with explanations.
177
- """
178
- return self.generate_content(prompt, max_tokens=3000)
179
-
180
- @spaces.GPU
181
- def generate_flashcards(self):
182
- """Generate flashcards"""
183
- prompt = """Create 15-20 flashcards based on this document:
184
-
185
- ## 🎴 Flashcards
186
-
187
- Format each flashcard as:
188
- **Card X:**
189
- **Front:** [Question/Term]
190
- **Back:** [Answer/Definition/Explanation]
191
-
192
- Include flashcards for:
193
- - Key terms and definitions
194
- - Important concepts
195
- - Facts and figures
196
- - Cause and effect relationships
197
- - Applications and examples
198
-
199
- Make questions clear and answers comprehensive but concise.
200
- """
201
- return self.generate_content(prompt, max_tokens=2500)
202
-
203
- @spaces.GPU
204
- def generate_mind_map(self):
205
- """Generate mind map structure"""
206
- prompt = """Create a detailed mind map structure for this document:
207
-
208
- ## 🧠 Mind Map Structure
209
-
210
- **Central Topic:** [Main subject of the document]
211
-
212
- ### Primary Branches:
213
- For each main topic, create branches with:
214
- - **Branch 1:** [Topic Name]
215
- - Sub-branch 1.1: [Subtopic]
216
- - Detail 1.1.1
217
- - Detail 1.1.2
218
- - Sub-branch 1.2: [Subtopic]
219
- - Detail 1.2.1
220
- - Detail 1.2.2
221
-
222
- ### Connections:
223
- - Identify relationships between different branches
224
- - Note cross-references and dependencies
225
- - Highlight cause-effect relationships
226
-
227
- ### Visual Elements Suggestions:
228
- - Color coding recommendations
229
- - Symbol suggestions for different types of information
230
- - Emphasis techniques for key concepts
231
- """
232
- return self.generate_content(prompt)
233
-
234
- @spaces.GPU
235
- def generate_lesson_plan(self):
236
- """Generate lesson plan"""
237
- prompt = """Create a detailed lesson plan based on this document:
238
-
239
- ## πŸ“š Lesson Plan
240
-
241
- ### Learning Objectives
242
- By the end of this lesson, students will be able to:
243
- - [Specific, measurable objectives]
244
-
245
- ### Prerequisites
246
- - Required background knowledge
247
- - Recommended prior reading
248
-
249
- ### Lesson Structure (60 minutes)
250
-
251
- **Introduction (10 minutes)**
252
- - Hook/attention grabber
253
- - Learning objectives overview
254
-
255
- **Main Content (35 minutes)**
256
- - Key concepts presentation
257
- - Activities and examples
258
- - Discussion points
259
-
260
- **Practice & Application (10 minutes)**
261
- - Practice exercises
262
- - Real-world applications
263
-
264
- **Wrap-up & Assessment (5 minutes)**
265
- - Summary of key points
266
- - Quick assessment questions
267
-
268
- ### Materials Needed
269
- - List of required resources
270
-
271
- ### Assessment Methods
272
- - How to evaluate student understanding
273
-
274
- ### Homework/Extension Activities
275
- - Additional practice opportunities
276
- """
277
- return self.generate_content(prompt, max_tokens=2500)
278
-
279
- @spaces.GPU
280
- def generate_concept_explanations(self):
281
- """Generate detailed concept explanations"""
282
- prompt = """Provide detailed explanations of key concepts from this document:
283
-
284
- ## πŸ” Concept Deep Dive
285
-
286
- For each major concept, provide:
287
-
288
- ### Concept Name
289
- **Definition:** Clear, precise definition
290
-
291
- **Explanation:** Detailed explanation in simple terms
292
-
293
- **Examples:** Real-world examples and applications
294
-
295
- **Analogies:** Helpful comparisons to familiar concepts
296
-
297
- **Common Misconceptions:** What students often get wrong
298
-
299
- **Connection to Other Concepts:** How it relates to other topics
300
-
301
- **Practice Application:** Simple exercise or question
302
-
303
- ---
304
-
305
- Repeat this structure for all major concepts in the document.
306
- """
307
- return self.generate_content(prompt, max_tokens=3000)
308
-
309
- @spaces.GPU
310
- def generate_practice_problems(self):
311
- """Generate practice problems"""
312
- prompt = """Create practice problems based on this document:
313
-
314
- ## πŸ’ͺ Practice Problems
315
-
316
- ### Beginner Level (5 problems)
317
- - Basic application of concepts
318
- - Direct recall and simple calculations
319
- - Step-by-step solutions provided
320
-
321
- ### Intermediate Level (5 problems)
322
- - Multi-step problems
323
- - Requires understanding of relationships
324
- - Guided solutions with explanations
325
-
326
- ### Advanced Level (3 problems)
327
- - Complex scenarios
328
- - Requires analysis and synthesis
329
- - Detailed solution strategies
330
-
331
- ### Challenge Problems (2 problems)
332
- - Extension beyond document content
333
- - Creative application
334
- - Multiple solution approaches
335
-
336
- **For each problem, include:**
337
- - Clear problem statement
338
- - Required formulas/concepts
339
- - Step-by-step solution
340
- - Common mistakes to avoid
341
- """
342
- return self.generate_content(prompt, max_tokens=3500)
343
 
344
- # Initialize the educational content creator
345
- creator = EducationalContentCreator()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
 
347
  # Create Gradio interface
348
  def create_interface():
@@ -424,54 +439,54 @@ def create_interface():
424
 
425
  # Event handlers
426
  setup_btn.click(
427
- creator.setup_client,
428
  inputs=[api_key],
429
  outputs=[setup_status]
430
  )
431
 
432
  process_btn.click(
433
- creator.process_document,
434
  inputs=[file_upload],
435
  outputs=[process_status]
436
  )
437
 
438
  summary_btn.click(
439
- creator.generate_summary,
440
  outputs=[output]
441
  )
442
 
443
  notes_btn.click(
444
- creator.generate_study_notes,
445
  outputs=[output]
446
  )
447
 
448
  quiz_btn.click(
449
- creator.generate_quiz,
450
  outputs=[output]
451
  )
452
 
453
  flashcards_btn.click(
454
- creator.generate_flashcards,
455
  outputs=[output]
456
  )
457
 
458
  mindmap_btn.click(
459
- creator.generate_mind_map,
460
  outputs=[output]
461
  )
462
 
463
  lesson_btn.click(
464
- creator.generate_lesson_plan,
465
  outputs=[output]
466
  )
467
 
468
  concepts_btn.click(
469
- creator.generate_concept_explanations,
470
  outputs=[output]
471
  )
472
 
473
  problems_btn.click(
474
- creator.generate_practice_problems,
475
  outputs=[output]
476
  )
477
 
 
5
  import io
6
  import json
7
  import time
8
+ from typing import List, Dict, Any, Optional
9
  import spaces
10
 
11
+ # Global variables to store API key and document text
12
+ API_KEY = ""
13
+ DOCUMENT_TEXT = ""
14
+ MODEL = "google/gemma-3-27b-it:free"
15
+
16
+ def setup_client(api_key: str):
17
+ """Initialize and test API key"""
18
+ global API_KEY
19
+ try:
20
+ # Test the API key by creating a client and making a simple request
21
+ client = OpenAI(
22
+ base_url="https://openrouter.ai/api/v1",
23
+ api_key=api_key,
24
+ )
25
+ # Store the API key globally
26
+ API_KEY = api_key
27
+ return "βœ… API Key configured successfully!"
28
+ except Exception as e:
29
+ return f"❌ Error configuring API: {str(e)}"
30
+
31
+ def create_client() -> Optional[OpenAI]:
32
+ """Create OpenAI client with stored API key"""
33
+ if not API_KEY:
34
+ return None
35
+ return OpenAI(
36
+ base_url="https://openrouter.ai/api/v1",
37
+ api_key=API_KEY,
38
+ )
39
+
40
+ def extract_text_from_pdf(file_path: str) -> str:
41
+ """Extract text from PDF file"""
42
+ try:
43
+ with open(file_path, 'rb') as file:
44
+ pdf_reader = PyPDF2.PdfReader(file)
45
  text = ""
46
+ for page in pdf_reader.pages:
47
+ text += page.extract_text() + "\n"
48
  return text
49
+ except Exception as e:
50
+ return f"Error reading PDF: {str(e)}"
51
+
52
+ def extract_text_from_docx(file_path: str) -> str:
53
+ """Extract text from DOCX file"""
54
+ try:
55
+ doc = docx.Document(file_path)
56
+ text = ""
57
+ for paragraph in doc.paragraphs:
58
+ text += paragraph.text + "\n"
59
+ return text
60
+ except Exception as e:
61
+ return f"Error reading DOCX: {str(e)}"
62
+
63
+ @spaces.GPU
64
+ def process_document(file):
65
+ """Process uploaded document and extract text"""
66
+ global DOCUMENT_TEXT
67
+
68
+ if file is None:
69
+ return "❌ No file uploaded"
70
+
71
+ file_path = file.name
72
+ file_extension = file_path.lower().split('.')[-1]
73
+
74
+ if file_extension == 'pdf':
75
+ DOCUMENT_TEXT = extract_text_from_pdf(file_path)
76
+ elif file_extension in ['docx', 'doc']:
77
+ DOCUMENT_TEXT = extract_text_from_docx(file_path)
78
+ else:
79
+ return "❌ Unsupported file format. Please upload PDF or DOCX files."
80
+
81
+ if DOCUMENT_TEXT and len(DOCUMENT_TEXT.strip()) > 0:
82
+ word_count = len(DOCUMENT_TEXT.split())
83
+ return f"βœ… Document processed successfully!\nπŸ“„ Word count: {word_count}\nπŸ“ Preview: {DOCUMENT_TEXT[:200]}..."
84
+ else:
85
+ return "❌ Could not extract text from the document"
86
+
87
+ @spaces.GPU
88
+ def generate_content(prompt: str, max_tokens: int = 2000) -> str:
89
+ """Generate content using the AI model"""
90
+ if not API_KEY:
91
+ return "❌ Please configure your API key first"
92
+
93
+ if not DOCUMENT_TEXT:
94
+ return "❌ Please upload and process a document first"
95
+
96
+ try:
97
+ client = create_client()
98
+ if not client:
99
+ return "❌ Failed to create API client"
100
+
101
+ completion = client.chat.completions.create(
102
+ extra_headers={
103
+ "HTTP-Referer": "https://educational-assistant.app",
104
+ "X-Title": "Educational Content Creator",
105
+ },
106
+ model=MODEL,
107
+ messages=[
108
+ {
109
+ "role": "system",
110
+ "content": "You are an expert educational content creator. Create comprehensive, engaging, and pedagogically sound educational materials based on the provided document content."
111
  },
112
+ {
113
+ "role": "user",
114
+ "content": f"Document Content:\n{DOCUMENT_TEXT}\n\n{prompt}"
115
+ }
116
+ ],
117
+ max_tokens=max_tokens,
118
+ temperature=0.7
119
+ )
120
+ return completion.choices[0].message.content
121
+ except Exception as e:
122
+ return f"❌ Error generating content: {str(e)}"
123
+
124
+ @spaces.GPU
125
+ def generate_summary():
126
+ """Generate comprehensive summary"""
127
+ prompt = """Create a comprehensive summary of this document with the following structure:
128
+
129
+ ## πŸ“‹ Executive Summary
130
+ Provide a brief overview in 2-3 sentences.
131
+
132
+ ## 🎯 Key Points
133
+ List the main concepts, ideas, or arguments presented.
134
+
135
+ ## πŸ“š Detailed Summary
136
+ Provide a thorough summary organized by topics or sections.
137
+
138
+ ## πŸ’‘ Important Takeaways
139
+ Highlight the most crucial information students should remember.
140
+ """
141
+ return generate_content(prompt)
142
+
143
+ @spaces.GPU
144
+ def generate_study_notes():
145
+ """Generate structured study notes"""
146
+ prompt = """Create comprehensive study notes from this document with:
147
+
148
+ ## πŸ“– Study Notes
149
+
150
+ ### πŸ”‘ Key Concepts
151
+ - Define important terms and concepts
152
+ - Explain their significance
153
+
154
+ ### πŸ“Š Main Topics
155
+ Organize content into clear sections with:
156
+ - Topic headings
157
+ - Key points under each topic
158
+ - Supporting details and examples
159
+
160
+ ### 🧠 Memory Aids
161
+ - Create mnemonics for complex information
162
+ - Suggest visualization techniques
163
+ - Provide connection points between concepts
164
+
165
+ ### ⚑ Quick Review Points
166
+ - Bullet points for rapid review
167
+ - Essential facts and figures
168
+ """
169
+ return generate_content(prompt)
170
+
171
+ @spaces.GPU
172
+ def generate_quiz():
173
+ """Generate quiz questions"""
174
+ prompt = """Create a comprehensive quiz based on this document:
175
+
176
+ ## πŸ“ Quiz Questions
177
+
178
+ ### Multiple Choice Questions (5 questions)
179
+ For each question, provide:
180
+ - Clear question
181
+ - 4 options (A, B, C, D)
182
+ - Correct answer
183
+ - Brief explanation
184
+
185
+ ### Short Answer Questions (5 questions)
186
+ - Questions requiring 2-3 sentence answers
187
+ - Cover key concepts and applications
188
+
189
+ ### Essay Questions (2 questions)
190
+ - Thought-provoking questions requiring detailed responses
191
+ - Focus on analysis, synthesis, or evaluation
192
+
193
+ ### Answer Key
194
+ Provide all correct answers with explanations.
195
+ """
196
+ return generate_content(prompt, max_tokens=3000)
197
+
198
+ @spaces.GPU
199
+ def generate_flashcards():
200
+ """Generate flashcards"""
201
+ prompt = """Create 15-20 flashcards based on this document:
202
+
203
+ ## 🎴 Flashcards
204
+
205
+ Format each flashcard as:
206
+ **Card X:**
207
+ **Front:** [Question/Term]
208
+ **Back:** [Answer/Definition/Explanation]
209
+
210
+ Include flashcards for:
211
+ - Key terms and definitions
212
+ - Important concepts
213
+ - Facts and figures
214
+ - Cause and effect relationships
215
+ - Applications and examples
216
+
217
+ Make questions clear and answers comprehensive but concise.
218
+ """
219
+ return generate_content(prompt, max_tokens=2500)
220
+
221
+ @spaces.GPU
222
+ def generate_mind_map():
223
+ """Generate mind map structure"""
224
+ prompt = """Create a detailed mind map structure for this document:
225
+
226
+ ## 🧠 Mind Map Structure
227
+
228
+ **Central Topic:** [Main subject of the document]
229
+
230
+ ### Primary Branches:
231
+ For each main topic, create branches with:
232
+ - **Branch 1:** [Topic Name]
233
+ - Sub-branch 1.1: [Subtopic]
234
+ - Detail 1.1.1
235
+ - Detail 1.1.2
236
+ - Sub-branch 1.2: [Subtopic]
237
+ - Detail 1.2.1
238
+ - Detail 1.2.2
239
+
240
+ ### Connections:
241
+ - Identify relationships between different branches
242
+ - Note cross-references and dependencies
243
+ - Highlight cause-effect relationships
244
+
245
+ ### Visual Elements Suggestions:
246
+ - Color coding recommendations
247
+ - Symbol suggestions for different types of information
248
+ - Emphasis techniques for key concepts
249
+ """
250
+ return generate_content(prompt)
251
+
252
+ @spaces.GPU
253
+ def generate_lesson_plan():
254
+ """Generate lesson plan"""
255
+ prompt = """Create a detailed lesson plan based on this document:
256
+
257
+ ## πŸ“š Lesson Plan
258
+
259
+ ### Learning Objectives
260
+ By the end of this lesson, students will be able to:
261
+ - [Specific, measurable objectives]
262
+
263
+ ### Prerequisites
264
+ - Required background knowledge
265
+ - Recommended prior reading
266
+
267
+ ### Lesson Structure (60 minutes)
268
+
269
+ **Introduction (10 minutes)**
270
+ - Hook/attention grabber
271
+ - Learning objectives overview
272
+
273
+ **Main Content (35 minutes)**
274
+ - Key concepts presentation
275
+ - Activities and examples
276
+ - Discussion points
277
+
278
+ **Practice & Application (10 minutes)**
279
+ - Practice exercises
280
+ - Real-world applications
281
+
282
+ **Wrap-up & Assessment (5 minutes)**
283
+ - Summary of key points
284
+ - Quick assessment questions
285
+
286
+ ### Materials Needed
287
+ - List of required resources
288
+
289
+ ### Assessment Methods
290
+ - How to evaluate student understanding
291
+
292
+ ### Homework/Extension Activities
293
+ - Additional practice opportunities
294
+ """
295
+ return generate_content(prompt, max_tokens=2500)
296
+
297
+ @spaces.GPU
298
+ def generate_concept_explanations():
299
+ """Generate detailed concept explanations"""
300
+ prompt = """Provide detailed explanations of key concepts from this document:
301
+
302
+ ## πŸ” Concept Deep Dive
303
+
304
+ For each major concept, provide:
305
+
306
+ ### Concept Name
307
+ **Definition:** Clear, precise definition
308
+
309
+ **Explanation:** Detailed explanation in simple terms
310
+
311
+ **Examples:** Real-world examples and applications
312
+
313
+ **Analogies:** Helpful comparisons to familiar concepts
314
+
315
+ **Common Misconceptions:** What students often get wrong
316
+
317
+ **Connection to Other Concepts:** How it relates to other topics
318
+
319
+ **Practice Application:** Simple exercise or question
320
+
321
+ ---
322
+
323
+ Repeat this structure for all major concepts in the document.
324
+ """
325
+ return generate_content(prompt, max_tokens=3000)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
 
327
+ @spaces.GPU
328
+ def generate_practice_problems():
329
+ """Generate practice problems"""
330
+ prompt = """Create practice problems based on this document:
331
+
332
+ ## πŸ’ͺ Practice Problems
333
+
334
+ ### Beginner Level (5 problems)
335
+ - Basic application of concepts
336
+ - Direct recall and simple calculations
337
+ - Step-by-step solutions provided
338
+
339
+ ### Intermediate Level (5 problems)
340
+ - Multi-step problems
341
+ - Requires understanding of relationships
342
+ - Guided solutions with explanations
343
+
344
+ ### Advanced Level (3 problems)
345
+ - Complex scenarios
346
+ - Requires analysis and synthesis
347
+ - Detailed solution strategies
348
+
349
+ ### Challenge Problems (2 problems)
350
+ - Extension beyond document content
351
+ - Creative application
352
+ - Multiple solution approaches
353
+
354
+ **For each problem, include:**
355
+ - Clear problem statement
356
+ - Required formulas/concepts
357
+ - Step-by-step solution
358
+ - Common mistakes to avoid
359
+ """
360
+ return generate_content(prompt, max_tokens=3500)
361
 
362
  # Create Gradio interface
363
  def create_interface():
 
439
 
440
  # Event handlers
441
  setup_btn.click(
442
+ setup_client,
443
  inputs=[api_key],
444
  outputs=[setup_status]
445
  )
446
 
447
  process_btn.click(
448
+ process_document,
449
  inputs=[file_upload],
450
  outputs=[process_status]
451
  )
452
 
453
  summary_btn.click(
454
+ generate_summary,
455
  outputs=[output]
456
  )
457
 
458
  notes_btn.click(
459
+ generate_study_notes,
460
  outputs=[output]
461
  )
462
 
463
  quiz_btn.click(
464
+ generate_quiz,
465
  outputs=[output]
466
  )
467
 
468
  flashcards_btn.click(
469
+ generate_flashcards,
470
  outputs=[output]
471
  )
472
 
473
  mindmap_btn.click(
474
+ generate_mind_map,
475
  outputs=[output]
476
  )
477
 
478
  lesson_btn.click(
479
+ generate_lesson_plan,
480
  outputs=[output]
481
  )
482
 
483
  concepts_btn.click(
484
+ generate_concept_explanations,
485
  outputs=[output]
486
  )
487
 
488
  problems_btn.click(
489
+ generate_practice_problems,
490
  outputs=[output]
491
  )
492