IW2025 commited on
Commit
f9e1010
·
verified ·
1 Parent(s): d92cf2c

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -60
app.py CHANGED
@@ -103,38 +103,12 @@ class CurriculumChatbot:
103
  self.llm = HuggingFacePipeline(pipeline=pipe)
104
 
105
  # Warm and engaging prompt templates
106
- qa_template = """You are a friendly and encouraging programming tutor.
107
-
108
- STUDENT'S QUESTION: {question}
109
 
110
  Here's the relevant curriculum content to help answer their question:
111
  {filled_context}
112
 
113
- CRITICAL: The student is specifically asking about "{question}". Make sure your answer directly addresses this exact question.
114
-
115
- Please provide a warm, encouraging answer that:
116
- 1. DIRECTLY ANSWERS the student's specific question: "{question}"
117
- 2. ANALYZES and EXPLAINS the specific curriculum content shown
118
- 3. References the exact examples, code, or concepts from the curriculum
119
- 4. Explains what each part of the curriculum is teaching
120
- 5. Provides step-by-step breakdown of any code examples shown
121
- 6. Explains the "why" behind the concepts, not just the "what"
122
- 7. Makes connections to real-world programming scenarios
123
- 8. Acknowledges the student's curiosity and encourages them
124
- 9. Suggests how they can practice or explore further
125
-
126
- IMPORTANT:
127
- - Answer the EXACT question: "{question}"
128
- - Focus on explaining the specific content shown in the curriculum, not generic concepts
129
- - If there's code, explain what it does step by step
130
- - If there are examples, break them down clearly
131
- - If there are rules or concepts, explain them with concrete examples
132
- - Use a conversational, friendly tone like you're explaining to a friend
133
- - Structure your response with clear sections and bullet points where helpful
134
- - Include short code examples (3-7 lines) ONLY if they help illustrate the concept clearly
135
- - Don't force code examples if the concept doesn't need them
136
-
137
- Your response should be educational and helpful, specifically answering: "{question}"."""
138
 
139
  self.qa_prompt = PromptTemplate(
140
  input_variables=["question", "filled_context"],
@@ -157,41 +131,12 @@ Please select the most relevant slide (filename.pdf - Page X) that would best he
157
  self.slide_selection_chain = self.slide_selection_prompt | self.llm
158
 
159
  # Warm and detailed focused QA template
160
- focused_qa_template = """You are a friendly and encouraging programming tutor.
161
 
162
- STUDENT'S QUESTION: {question}
163
-
164
- Here's the specific curriculum slide content that directly addresses their question:
165
  {slide_content}
166
 
167
- CRITICAL: The student is specifically asking about "{question}". Make sure your answer directly addresses this exact question.
168
-
169
- Please provide a warm, encouraging answer that:
170
- 1. DIRECTLY ANSWERS the student's specific question: "{question}"
171
- 2. ANALYZES and EXPLAINS the specific content shown in the slide
172
- 3. References the exact examples, code, or concepts displayed
173
- 4. Explains what each part of the slide is teaching
174
- 5. Provides step-by-step breakdown of any code examples shown
175
- 6. Explains the "why" behind the concepts, not just the "what"
176
- 7. Makes connections to real-world programming scenarios
177
- 8. Acknowledges the student's curiosity and encourages them
178
- 9. Suggests how they can practice or explore further
179
-
180
- IMPORTANT:
181
- - Answer the EXACT question: "{question}"
182
- - If they ask about "for loops", explain for loops specifically, not loops in general
183
- - If they ask about "while loops", explain while loops specifically
184
- - If they ask about "variables", explain variables specifically
185
- - Focus on explaining the specific content shown in the slide, not generic concepts
186
- - If there's code, explain what it does step by step
187
- - If there are examples, break them down clearly
188
- - If there are rules or concepts, explain them with concrete examples
189
- - Use a conversational, friendly tone like you're explaining to a friend
190
- - Structure your response with clear sections and bullet points where helpful
191
- - Include short code examples (3-7 lines) ONLY if they help illustrate the concept clearly
192
- - Don't force code examples if the concept doesn't need them
193
-
194
- Your response should be educational and helpful, specifically answering: "{question}"."""
195
 
196
  self.focused_qa_prompt = PromptTemplate(
197
  input_variables=["question", "slide_content"],
 
103
  self.llm = HuggingFacePipeline(pipeline=pipe)
104
 
105
  # Warm and engaging prompt templates
106
+ qa_template = """You are a friendly and encouraging programming tutor. A student has asked: {question}
 
 
107
 
108
  Here's the relevant curriculum content to help answer their question:
109
  {filled_context}
110
 
111
+ Please provide a warm, encouraging answer that directly answers their question using the curriculum content. Use a conversational tone and explain the concepts clearly."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
  self.qa_prompt = PromptTemplate(
114
  input_variables=["question", "filled_context"],
 
131
  self.slide_selection_chain = self.slide_selection_prompt | self.llm
132
 
133
  # Warm and detailed focused QA template
134
+ focused_qa_template = """You are a friendly and encouraging programming tutor. A student has asked: {question}
135
 
136
+ Here's the curriculum slide content to help answer their question:
 
 
137
  {slide_content}
138
 
139
+ Please provide a warm, encouraging answer that directly answers their question about the slide content. Use a conversational tone and explain the concepts clearly."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  self.focused_qa_prompt = PromptTemplate(
142
  input_variables=["question", "slide_content"],