Moving Froward Approach
This is a complex transition from a "Passive Viewer" to an "Active State Machine." To create the most accurate prompt for Google Antigravity, I need to clarify two specific UI/UX preferences.
My Questions for You¶
- The "Map" Visualization:
When the user sees their progress, do you want:
- Option A: A simple List/Card View (e.g., "✅ Gravity", "✅ Orbit", "🔒 Relativity").
- Option B: An interactive Network Graph (using
streamlit-agraphorpyvis) where nodes light up gold as they are mastered? (Option B looks cooler but is harder to implement perfectly in Streamlit.)
- The "Stitching" Phase:
Since your current ingestion just has a list of concepts, we need to create the connections (Prerequisites). Do you want the app to:
- Auto-Stitch: Have the LLM read all your nodes right now and guess the order? (Easier, takes ~5 mins).
- Manual Mode: Give you a drag-and-drop UI to link them yourself? (Harder to build, more control).
The Updated "Mega-Prompt" (Adaptive Edition)¶
Copy and paste this into Google Antigravity:
codeText
Act as a Senior Python Full-Stack Developer. We are building "The Professor," a local-first adaptive AI tutor.
### CONTEXT
I have `db_manager.py` (FalkorDBLite), `app.py` (Streamlit), and `prompts.py` (LLM instructions).
### THE "KILLER FEATURE": ADAPTIVE CURRICULUM
The app must track student performance. If a student fails a concept twice, the system must **physically alter the Knowledge Graph** to make the learning curve shallower.
### STEP 1: DATABASE UPDATES (`db_manager.py`)
Update the schema and functions:
1. **Schema Change:** The `[:MASTERED]` and `[:ATTEMPTED]` relationships need a property `failure_count`.
2. `record_attempt(user_id, concept_name, passed: bool)`:
- If `passed`: Create `[:MASTERED]` edge. Reset `failure_count`.
- If `failed`: Increment `failure_count` on the `[:ATTEMPTED]` edge.
- **Return:** The new `failure_count`.
3. `refactor_graph(concept_name, new_sub_concepts_list)`:
- **Critical Logic:** Insert new nodes *between* the current prerequisites and the target concept.
- Logic:
1. Find target concept `(Target)`.
2. Find immediate prerequisites `(Pre)`.
3. Create new nodes `(Sub1)`, `(Sub2)` from the list.
4. Delete edge `(Pre)-[:PREREQUISITE]->(Target)`.
5. Create edges `(Pre)->(Sub1)->(Sub2)->(Target)`.
### STEP 2: PROMPTS (`prompts.py`)
Add `get_decomposition_prompt(concept, user_mistakes)`:
- Task: "The user is failing to understand '{concept}'. Based on their mistakes, break this concept down into 2-3 simpler, foundational sub-concepts that bridge the gap."
- Output: JSON list of new concepts with definitions.
### STEP 3: UI LOGIC (`app.py`)
Update the "Feedback" state logic:
- When User clicks "Submit Test":
1. Call Grader LLM.
2. If **PASS**: Show fireworks, unlock next node.
3. If **FAIL**:
- Call `db.record_attempt()`.
- Check: Is `failure_count >= 2`?
- **IF YES (Trigger Adaptation):**
- Show UI Message: "I see this is tricky. Let me break this down for you..."
- Call LLM (`get_decomposition_prompt`).
- Call `db.refactor_graph()` with the new nodes.
- Rerun `st.experimental_rerun()` to reload the syllabus. The "Next Lesson" will now be one of the new sub-concepts.
- **IF NO:**
- Show UI Message: "Let's try explaining it again."
### EXECUTION
Implement the database logic first, then the prompts, then the UI state machine. Ensure the Cypher queries for refactoring the graph handle edge deletions safely.
How this works in practice¶
-
Scenario: You are learning "Quantum Entanglement."
-
Action: You fail the test twice.
-
The Adaptation:
-
The App pauses and says: "I see this is tricky. Let me break this down..."
-
Behind the scenes: It asks Qwen-72B, "Break down Entanglement."
-
Qwen says: "They need to understand 'Spin' and 'Superposition' first."
-
FalkorDB Update: It inserts "Spin" and "Superposition" into your graph before "Entanglement."
-
-
The Result: The screen refreshes. Your "Next Lesson" is no longer "Entanglement." It is now "Electron Spin."
This is the feature that makes the app feel magical. Go for it.