跳转至

Detailed Antigravity Development Guide

This is a comprehensive guide tailored for an occasional hobbyist using Google Antigravity (the hypothetical 2026 AI-native IDE) to build "The Professor."

Since you are a hobbyist, we will rely on Antigravity's AI Agents to write the complex code, handle the database connections, and debug errors. Your role is that of the Architect and Project Manager.


Phase 1: Preparation (The "No-Code" Setup)

Before opening the IDE, we need to ensure your M1 Max is ready.

1. Install the "Runners" You need the engines that the code will call. * Install Ollama: Download from ollama.com. * Pull Models (Terminal): Open your Mac Terminal and paste this:

ollama pull qwen2.5:72b
ollama pull qwen2.5:14b
ollama pull nomic-embed-text
Note: This will take a while. These are the brains your app will use.

2. Open Google Antigravity * Create a New Project: Name it Project_Professor. * Select "Local Environment" (so it runs on your Mac, not the cloud).


Phase 2: The Foundation (Letting the Agent Build the Skeleton)

In Antigravity, you don't write requirements.txt manually. You talk to the "Scaffold Agent" in the chat panel.

Prompt to Antigravity:

"I am building a local AI tutoring app called 'The Professor'. Stack: Python 3.11, Streamlit for UI, FalkorDBLite for the database, and Ollama for the LLM. Task: Please create the folder structure and a virtual environment. Install the following libraries: streamlit, falkordblite, langchain, langchain-community, ollama, pymupdf."

What Antigravity does: 1. Creates folders: /app, /data, /input_pdfs. 2. Creates a virtual environment (.venv). 3. Runs the installation commands. 4. Your Job: Click "Approve & Run" when it asks for permission.


Phase 3: Building the Database Logic (The "Syllabus" Engine)

We need to teach the app how to "speak" to FalkorDBLite without you needing to learn the Cypher query language.

Prompt to Antigravity:

"Create a Python script named database_manager.py. Goal: Manage a FalkorDBLite instance saved in the /data folder. Requirements: 1. A function init_db() that connects to the graph 'professor_graph'. 2. A function add_concept(name, definition, prerequisites_list) that creates a Concept node. If prerequisites exist, link them with [:PREREQUISITE]. 3. A function get_next_lesson() that finds a Concept where the User has NOT mastered it, but HAS mastered all prerequisites. 4. Use nomic-embed-text via Ollama to generate embeddings for the definition and store them on the node."

What happens: Antigravity writes the code. It handles the complex logic of checking if a node exists before creating it (MERGE vs CREATE) and sets up the embedding vector format.

Your Job: * Review the code briefly. * Test it: Ask Antigravity, "Write a small test script test_db.py to add 'Math 101' and 'Math 102' and verify they are linked. Run it." * If it fails (e.g., "Vector dimension mismatch"), tell Antigravity: "Fix the vector dimension error." It will auto-correct.


Phase 4: The Ingestion Pipeline (Reading Books)

Now we need the script that reads your PDFs and fills the database.

Prompt to Antigravity:

"Create a script named ingest_book.py. Input: It should scan all PDFs in the /input_pdfs folder. Logic: 1. Extract text using PyMuPDF. 2. Send the text to Ollama (model: qwen2.5:14b) with a prompt to extract key Concepts and their Dependencies as JSON. 3. Loop through that JSON and call the add_concept function from database_manager.py to save them."

Hobbyist Tip: This is the hardest part to get right. The LLM might output bad JSON. * Debugging with Antigravity: If the script crashes, copy the error message into the chat. Antigravity will likely say, "Ah, the LLM didn't close a bracket. I will update the script to use a 'JSON Repair' function."


Phase 5: The User Interface (The "Classroom")

This is where you make it look good. We will use Streamlit because it is "Pure Python" (no HTML/CSS needed).

Prompt to Antigravity:

"Create app.py using Streamlit. Layout: Wide mode. Two columns. Left Column (Chat): - A text input for the user. - A chat history display. Right Column (Board): - A placeholder for Mermaid.js diagrams. Logic: - When the app starts, call get_next_lesson() from database_manager.py. - Use Ollama (qwen2.5:72b) to explain the lesson. - Display the explanation in the chat. - If the LLM outputs Mermaid code, render it in the Right Column."

Your Job: * Run the app: Click the "Run Streamlit" button in Antigravity (or type streamlit run app.py in the terminal). * Visual Check: Does it look right? If the text is too small, tell Antigravity: "Make the chat font larger and give the right column a dark background."


Phase 6: The "Feynman" Feedback Loop

Now we add the grading logic.

Prompt to Antigravity:

"Update app.py. After the lesson is explained, ask the user to explain it back. Action: Capture the user's response. Grading: Send the User's response + the Concept Definition to Ollama (qwen2.5:72b). Prompt: 'Grade this explanation on a scale of 0-100. Return JSON: {score: int, feedback: str}'. Result: If score > 85, mark the node as MASTERED in the database and load the next lesson. If not, ask the user to try again."


Summary of Files You Will Have

  1. database_manager.py: The brain. Handles FalkorDBLite and Vector storage.
  2. ingest_book.py: The scanner. Reads PDFs and builds the graph.
  3. app.py: The face. The Streamlit website you interact with.
  4. requirements.txt: The library list.

How to "Play" with Your App

  1. Drop a PDF: Put a PDF (e.g., "Intro to Logic") into the input_pdfs folder.
  2. Run Ingestion: Type python ingest_book.py in the terminal. Watch the logs as it builds the graph.
  3. Start Class: Type streamlit run app.py.
  4. Learn: The AI will greet you, teach the first concept, and wait for your explanation.

Why this works for a Hobbyist

  • No Docker: You don't have to manage containers.
  • No Complex SQL: The Agent writes the Cypher queries.
  • No CSS: Streamlit handles the design.
  • Focus on Logic: You are telling the Agent what to build, not worrying about semicolons.