Spaces:
Runtime error

Vidya-V3-Tutor / README.md
TrueTensor's picture
Update README.md
00ba432 verified
|
Raw History Blame Contribute Delete
4.87 kB

A newer version of the Gradio SDK is available: 6.33.0

Upgrade
metadata
title: Vidya AI Tutor
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.32.0
app_file: app.py
pinned: false

Vidya V3 β€” Real-Time AI Tutor (Terminal POC)

A modular, terminal-based AI tutoring system powered by Google Gemini and Cognitive Apprenticeship (CA) pedagogy. Zero UI, zero server β€” just Python and a terminal.


Architecture

vidya-realtime-ai-tutor/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.py            ← entry point + REPL loop
β”‚   β”œβ”€β”€ config.py          ← env vars + constants
β”‚   β”œβ”€β”€ gemini_client.py   ← Gemini API (google-genai SDK)
β”‚   β”œβ”€β”€ tutor_session.py   ← per-turn orchestration
β”‚   β”œβ”€β”€ schemas.py         ← Pydantic input/output models
β”‚   β”œβ”€β”€ signal_extractor.py← local debug signal detector
β”‚   β”œβ”€β”€ phase_manager.py   ← fallback CA phase logic
β”‚   └── utils.py           ← terminal colors + helpers
β”œβ”€β”€ prompts/
β”‚   └── system_prompt.txt  ← Gemini's identity + rules
β”œβ”€β”€ logs/
β”‚   └── conversations.json ← auto-saved session logs
β”œβ”€β”€ requirements.txt
└── .env.example

Streamlit start

    streamlit run streamlit_app.py

## Quickstart

```bash
# 1. Create and activate virtual environment
python -m venv venv

# Windows
venv\Scripts\activate

# macOS / Linux
source venv/bin/activate

# 2. Install dependencies
pip install -r requirements.txt

# 3. Set up API key
copy .env.example .env        # Windows
cp .env.example .env          # macOS/Linux

# Edit .env and paste your Gemini API key:
# GEMINI_API_KEY=your_key_here

# 4. Run the tutor
python src/main.py

# Optional: enable debug signal view on startup
python src/main.py --debug

Getting a Gemini API Key

  1. Go to https://aistudio.google.com/app/apikey
  2. Sign in with your Google account
  3. Click Create API key
  4. Paste it into your .env file

Session Setup (one-time per run)

When you run the app you'll be asked:

Question Example inputs
Skill topic Python functions, SQL joins, OOP concepts
Mastery level 0.0 (beginner) β†’ 1.0 (expert), e.g. 0.2
Who are you? 1 for student, 2 for service engineer
Starting phase 1 MODEL, 2 COACH, 3 SCAFFOLD, 4 FADE
Language 1 English, 2 Hindi, 3 Mixed

Demo Conversation (Python Functions, student, en)

You: I don't understand what a function is.
πŸŽ“ Vidya [MODEL]
A function is a reusable block of code. Think of it like a recipe:
def greet(name):
    return f"Hello, {name}!"
greet("Riya") β†’ "Hello, Riya!"
The def keyword defines it; you call it by name.
πŸ’‘ Next: Try writing a function that adds two numbers.

You: Just tell me the answer.
πŸŽ“ Vidya [COACH]
I'd love to help β€” but you'll learn much more by trying first!
What would the function signature look like? What inputs would it take?
πŸ’‘ Next: Start with: def add(a, b): and see what you can fill in.

You: Can you teach me cricket?
πŸŽ“ Vidya [COACH]
That's a fun topic! But right now we're focused on Python functions β€”
and you're doing well! Let's stick with it. What part of functions
feels most unclear?
πŸ’‘ Next: Come back to Python functions β€” you're almost there!

You: exit
βœ… Conversation saved to logs/conversations.json (3 turns)

Cognitive Apprenticeship Phases

Phase Tutor Behaviour
MODEL Shows a worked example, thinks out loud
COACH Asks guiding questions, no direct answers
SCAFFOLD Partial hints, fills gaps not full solutions
FADE Learner leads, tutor lightly nudges

Gemini decides which phase to advance/hold/regress based on your responses.


Debug Mode

Type debug at any point during the chat to toggle signal visibility:

[DEBUG] signals=confusion, answer_seeking  |  phase_reason=turn 3

Or start with --debug for it enabled from the first turn.


Swapping LLM Provider

The Gemini call is isolated in src/gemini_client.py. To swap to OpenAI or Anthropic Claude:

  1. Open src/gemini_client.py
  2. Replace the call_gemini() function body with your provider's SDK call
  3. Keep the same function signature and return type (raw string)
  4. Update requirements.txt with the new SDK
  5. Add the new *_API_KEY to .env.example

tutor_session.py, main.py, and everything else stay unchanged.


Log Format (logs/conversations.json)

[
  {
    "config": { "skill_topic": "...", "mastery_level": 0.2, ... },
    "final_phase": "COACH",
    "turns": 5,
    "conversation": [
      { "role": "user", "content": "..." },
      { "role": "assistant", "content": "..." }
    ]
  }
]

Requirements

  • Python 3.10+
  • Google Gemini API key (free tier available)
  • Dependencies: google-genai, python-dotenv, pydantic