Group-1-5010/NotebookLM
1
1"""All mock responses and content for the NotebookLM prototype."""2 3import random4import time5import uuid6from datetime import datetime7from state import Artifact8 9 10# ── Chat Mock Responses ──────────────────────────────────────────────────────11 12MOCK_RESPONSES = [13 {14 "content": (15 "Based on the uploaded sources, the key concept revolves around "16 "the relationship between the variables discussed in Chapter 3. "17 "The author emphasizes that understanding this foundation is critical "18 "before moving to advanced topics."19 ),20 "citations": [21 {"source": "lecture_notes.pdf", "page": 3, "text": "the relationship between variables..."},22 {"source": "textbook_ch3.pdf", "page": 42, "text": "understanding this foundation..."},23 ],24 },25 {26 "content": (27 "The sources indicate three main approaches to this problem:\n\n"28 "1. **Direct method** — Apply the formula from Section 2.1\n"29 "2. **Iterative approach** — Build up from base cases\n"30 "3. **Approximation** — Use the simplified model when precision isn't critical\n\n"31 "The textbook recommends starting with the direct method for beginners."32 ),33 "citations": [34 {"source": "textbook_ch2.pdf", "page": 15, "text": "direct method... apply the formula"},35 ],36 },37 {38 "content": (39 "I couldn't find specific information about that topic in your "40 "uploaded sources. Try uploading additional materials that cover this "41 "subject, or rephrase your question to relate more closely to the "42 "content in your current sources."43 ),44 "citations": [],45 },46 {47 "content": (48 "Great question! According to the lecture slides, this concept "49 "was introduced in Week 5. The key takeaway is that the process involves "50 "three stages: **initialization**, **processing**, and **validation**. "51 "Each stage has specific requirements that must be met before proceeding."52 ),53 "citations": [54 {"source": "week5_slides.pptx", "page": 8, "text": "three stages: initialization..."},55 {"source": "week5_slides.pptx", "page": 12, "text": "specific requirements..."},56 ],57 },58]59 60 61def get_mock_response(query: str) -> dict:62 time.sleep(1.2)63 return random.choice(MOCK_RESPONSES)64 65 66# ── Artifact Mock Content ────────────────────────────────────────────────────67 68MOCK_CONVERSATION_SUMMARY = {69 "brief": """## Conversation Summary (Brief)70 71**Topics Discussed:**72- Relationship between core variables from Chapter 373- Three problem-solving methodologies and when to use each74- The three-stage process (initialization → processing → validation)75 76**Key Questions Asked:**77- What are the main approaches to the problem? → Three methods identified78- How do the lecture notes differ from the textbook? → Application vs. theory79 80**Unresolved:** No questions remain open from the conversation.81""",82 "detailed": """## Conversation Summary (Detailed)83 84### Discussion Flow85The conversation covered 4 main exchanges exploring the source material.86 87### Topics Explored881. **Core Concepts (Q1-Q2):** User asked about the foundational relationship between variables. The AI identified Chapter 3 as the primary source and highlighted it as a prerequisite for advanced topics.89 902. **Methodology Comparison (Q3):** User inquired about different problem-solving approaches. Three methods were identified — direct, iterative, and approximation — with trade-offs explained for each.91 923. **Process Stages (Q4):** Discussion about the three-stage process introduced in Week 5 lectures: initialization, processing, and validation.93 94### Key Insights from Chat95- The direct method is recommended as the starting point for beginners96- Lecture notes and textbook provide complementary perspectives97- Each stage has specific requirements that must be met before proceeding98 99### Citations Used100| Source | Times Referenced |101|--------|----------------|102| textbook_ch3.pdf | 3 |103| lecture_notes.pdf | 2 |104| week5_slides.pptx | 2 |105| textbook_ch2.pdf | 1 |106""",107}108 109MOCK_DOCUMENT_SUMMARY = {110 "brief": """## Document Summary (Brief)111 112**Core Theme:** The sources examine the relationship between key variables and present multiple problem-solving methodologies.113 114**Key Takeaways:**115- Three approaches exist: direct method, iterative approach, and approximation116- The direct method provides exact results but requires complete data117- A three-stage process (initialization → processing → validation) underpins the framework118- Lecture materials focus on application; textbook provides theoretical depth119 120**Bottom Line:** Master the direct method first, then explore alternatives as complexity increases.121""",122 "detailed": """## Document Summary (Detailed)123 124### 1. Foundational Framework125The sources establish a foundational framework centered on the relationship between core variables discussed primarily in Chapter 3. The author emphasizes that a thorough understanding of this relationship is a prerequisite before advancing to more complex topics. The framework operates through a three-stage process:126 127- **Initialization** — Setting up parameters and base conditions128- **Processing** — Executing the core computational logic129- **Validation** — Verifying outputs meet confidence thresholds130 131### 2. Methodological Approaches132Three distinct methodological approaches are presented across the sources:133 134| Method | Best For | Trade-off |135|--------|----------|-----------|136| **Direct** | Complete datasets, exact results needed | Requires full data availability |137| **Iterative** | Incomplete data, convergent solutions | Multiple passes, slower |138| **Approximation** | Quick estimates, non-critical precision | Sacrifices accuracy for speed |139 140The textbook (Section 2.1) recommends beginners start with the direct method, as it builds intuition for how the formula maps inputs to outputs.141 142### 3. Cross-Source Analysis143The lecture notes (Week 5) and textbook chapters approach the same material from complementary angles:144- **Lectures** — Emphasize practical application with worked examples145- **Textbook** — Provides theoretical depth, proofs, and edge cases146- **Slides** — Offer visual summaries and quick-reference diagrams147 148### 4. Key Definitions149- **Confidence threshold** — The minimum acceptable level of certainty for a result150- **Convergence** — The point at which iterative refinements produce negligible improvement151- **Base case** — The simplest instance of a problem used as a starting point152 153### 5. Conclusion154Mastering these fundamentals is essential before proceeding to advanced modules. The recommended learning path is: direct method → iterative approach → approximation, building complexity gradually.155""",156}157 158MOCK_PODCAST_SCRIPT = """## Podcast: Deep Dive Study Session159 160**Alex:** Hey everyone, welcome back to another deep dive study session! I'm Alex, and I'm here with Sam. Today we've got some really meaty material to break down. Sam, I read through the summary and honestly, there's a lot going on. Where do we even start?161 162**Sam:** Right, so let's zoom out first. The big picture here is about problem-solving methodology — specifically, the idea that there isn't just one way to solve a problem. The sources lay out three distinct approaches, and understanding when to use which one is really the meta-skill they're teaching.163 164**Alex:** Okay, three approaches. Let's go through them one by one?165 166**Sam:** Absolutely. So the first one is called the **direct method**. Think of it like having a recipe where you know all the ingredients and all the steps. You plug your values into the formula, follow the steps, and you get your exact answer. Clean, precise, done.167 168**Alex:** That sounds like the dream scenario. Why doesn't everyone just use that all the time?169 170**Sam:** Great question — and this is where it gets interesting. The direct method has a strict requirement: you need *complete* data. Every single input has to be known. In academic exercises, sure, they give you everything. But in the real world? You're often working with gaps, estimates, or noisy data.171 172**Alex:** Ah, so that's where the second approach comes in?173 174**Sam:** Exactly — the **iterative approach**. Instead of solving it in one shot, you start with your best guess and then keep refining. Each pass gets you closer to the real answer. It's like sculptors — you start with a rough block and keep chipping away until it looks right.175 176**Alex:** I love that analogy. So how do you know when to stop iterating?177 178**Sam:** That's actually one of the key concepts — **convergence**. You stop when the difference between iterations becomes so small that it's negligible. The sources define a confidence threshold, and once you're within that threshold, you're done.179 180**Alex:** Makes sense. And the third method?181 182**Sam:** **Approximation**. This one is all about pragmatism. Sometimes you don't need five decimal places of precision. You just need a ballpark. Is this going to cost us $100 or $10,000? The approximation method gives you that answer fast, at the cost of some accuracy.183 184**Alex:** So it's really about matching your tool to the job.185 186**Sam:** Exactly right. And that's actually what the sources are trying to teach. It's not just "here are three formulas." It's "here's how to think about which tool fits which situation." That metacognitive skill is what separates a good problem-solver from someone who just memorizes formulas.187 188**Alex:** One thing I noticed in the summary was this three-stage process — initialization, processing, validation. How does that fit in?189 190**Sam:** Good catch. That process applies to *all three* methods. Regardless of which approach you choose, you always: set up your initial conditions, run the computation, and then validate your results. It's like a universal wrapper around any problem-solving method.191 192**Alex:** That's a really clean mental model. I wish my professors had explained it that way.193 194**Sam:** Ha! Well, that's what the lecture notes try to do — they focus on practical application. The textbook goes deeper into the theory and proofs, but the lectures are where you get the worked examples and intuition.195 196**Alex:** Alright, I think that's a solid overview. Any final advice for students studying this material?197 198**Sam:** Start with the direct method. Get really comfortable with it. Once you feel solid, move to iterative, then approximation. Don't try to learn all three at once — build up gradually. And always check your work with that validation step.199 200**Alex:** Brilliant advice. Thanks Sam, and thanks everyone for listening. Until next time — keep studying smart, not just hard!201"""202 203MOCK_QUIZ = {204 5: """## Practice Quiz (5 Questions)205 206### Question 1207What is the primary advantage of the direct method?208 209- A) It works with incomplete data210- B) It provides exact results in a single pass211- C) It is the fastest method212- D) It requires no validation213 214**Answer: B**215**Explanation:** The direct method applies the formula once to produce exact results, unlike iterative methods that require multiple passes.216 217---218 219### Question 2220Which stage comes immediately after initialization in the three-stage process?221 222- A) Validation223- B) Optimization224- C) Processing225- D) Calibration226 227**Answer: C**228**Explanation:** The three stages are: initialization → processing → validation.229 230---231 232### Question 3233When should the approximation method be preferred?234 235- A) When working with critical systems236- B) When precision is not the primary concern237- C) When the dataset is very small238- D) When the direct method fails239 240**Answer: B**241**Explanation:** Approximation trades precision for speed, ideal when exact results aren't required.242 243---244 245### Question 4246What does "convergence" refer to in the iterative approach?247 248- A) The point where the algorithm starts249- B) When iterations produce negligible differences250- C) The final validation step251- D) Combining multiple methods together252 253**Answer: B**254**Explanation:** Convergence is reached when successive iterations produce results so close together that further refinement is unnecessary.255 256---257 258### Question 5259What is the recommended learning order for the three methods?260 261- A) Approximation → Iterative → Direct262- B) Iterative → Direct → Approximation263- C) Direct → Iterative → Approximation264- D) Any order is equally effective265 266**Answer: C**267**Explanation:** The textbook recommends starting with the direct method to build intuition, then progressing to iterative and approximation.268""",269 10: """## Practice Quiz (10 Questions)270 271### Question 1272What is the primary advantage of the direct method?273- A) It works with incomplete data274- B) It provides exact results in a single pass275- C) It is the fastest method276- D) It requires no validation277 278**Answer: B**279 280---281 282### Question 2283Which stage comes immediately after initialization?284- A) Validation285- B) Optimization286- C) Processing287- D) Calibration288 289**Answer: C**290 291---292 293### Question 3294When should the approximation method be preferred?295- A) When working with critical systems296- B) When precision is not the primary concern297- C) When the dataset is very small298- D) When the direct method fails299 300**Answer: B**301 302---303 304### Question 4305What does "convergence" mean in the iterative approach?306- A) The point where the algorithm starts307- B) When iterations produce negligible differences308- C) The final validation step309- D) Combining multiple methods310 311**Answer: B**312 313---314 315### Question 5316What is the recommended learning order?317- A) Approximation → Iterative → Direct318- B) Iterative → Direct → Approximation319- C) Direct → Iterative → Approximation320- D) Any order is fine321 322**Answer: C**323 324---325 326### Question 6327What does the direct method require?328- A) Multiple iterations329- B) Complete data330- C) A confidence threshold331- D) An initial estimate332 333**Answer: B**334 335---336 337### Question 7338What is a "confidence threshold"?339- A) How sure you are about your method choice340- B) The minimum acceptable certainty for a result341- C) The maximum number of iterations342- D) The accuracy of the approximation method343 344**Answer: B**345 346---347 348### Question 8349How do lecture notes differ from the textbook?350- A) Lectures focus on theory, textbook on application351- B) Lectures focus on application, textbook on theory352- C) They cover different topics entirely353- D) There is no significant difference354 355**Answer: B**356 357---358 359### Question 9360What is a "base case" in this context?361- A) The most complex problem instance362- B) The simplest problem instance used as a starting point363- C) The final validated result364- D) A failed iteration365 366**Answer: B**367 368---369 370### Question 10371The three-stage process applies to which methods?372- A) Only the direct method373- B) Only the iterative method374- C) Direct and iterative only375- D) All three methods376 377**Answer: D**378""",379}380 381 382def generate_mock_artifact(artifact_type: str, **kwargs) -> Artifact:383 time.sleep(1.5)384 385 if artifact_type == "conversation_summary":386 style = kwargs.get("style", "detailed")387 content = MOCK_CONVERSATION_SUMMARY.get(style, MOCK_CONVERSATION_SUMMARY["detailed"])388 title = f"Conversation Summary ({'Brief' if style == 'brief' else 'Detailed'})"389 elif artifact_type == "document_summary":390 style = kwargs.get("style", "detailed")391 content = MOCK_DOCUMENT_SUMMARY.get(style, MOCK_DOCUMENT_SUMMARY["detailed"])392 title = f"Document Summary ({'Brief' if style == 'brief' else 'Detailed'})"393 elif artifact_type == "podcast":394 content = MOCK_PODCAST_SCRIPT395 title = "Podcast Episode"396 elif artifact_type == "quiz":397 num_q = kwargs.get("num_questions", 5)398 content = MOCK_QUIZ.get(num_q, MOCK_QUIZ[5])399 title = f"Practice Quiz ({num_q}Q)"400 else:401 content = ""402 title = artifact_type403 404 return Artifact(405 id=str(uuid.uuid4()),406 type=artifact_type,407 title=title,408 content=content,409 audio_path=None,410 created_at=datetime.now().isoformat(),411 )412 