Feature: AI Configuration & Token Philosophy System
🌲 Core Philosophy: "Was kostet die Frage eines Kindes?"
In the forest: priceless. In the system: measured. Pedagogically: teaches mindful questioning.
Changes:
- Added .env.template for API configuration
• OpenRouter, Claude API, OpenAI support
• Ollama (local AI) as free alternative
• Qdrant vector database configuration
• Token budget system for mindful learning
• Parental controls (PIN, reports)
- New AI Doktor module in mission selector
• Shows configured APIs and models
• Displays token budget & tracking status
• Lists active AI characters (Waldwächter)
• Links to token logs viewer
• Guides setup if .env missing
- Extended CLAUDE.md with Token Philosophy
• Educational reasoning behind token tracking
• Why it teaches reflection and quality
• Budget system explanation
• Implementation details
Philosophy:
Token tracking isn't restriction - it's mindfulness training.
Just as we teach not to waste water/food/paper, we teach
not to waste computational resources. Children learn to:
- Think before asking
- Value AI's thinking time
- Ask better quality questions
- Research independently first
Result: More thoughtful questions, deeper learning, respect for resources.
This commit is contained in:
80
.env.template
Normal file
80
.env.template
Normal file
@@ -0,0 +1,80 @@
|
||||
# ============================================================
|
||||
# 🌲 Crumbforest Mission System - Environment Configuration
|
||||
# ============================================================
|
||||
#
|
||||
# Philosophie: "Was kostet die Frage eines Kindes?"
|
||||
# Im Wald unbezahlbar - aber Token helfen beim achtsamen Fragen.
|
||||
# Jede Frage ist wertvoll, Token-Messung lehrt bewusstes Denken.
|
||||
#
|
||||
# ============================================================
|
||||
|
||||
# === API KEYS ===
|
||||
|
||||
# OpenRouter (Multi-Model Gateway)
|
||||
OPENROUTER_API_KEY=""
|
||||
OPENROUTER_MODEL="openai/gpt-3.5-turbo" # oder anthropic/claude-3-haiku
|
||||
|
||||
# Claude API (Anthropic)
|
||||
CLAUDE_API_KEY=""
|
||||
CLAUDE_MODEL="claude-3-haiku-20240307"
|
||||
|
||||
# OpenAI
|
||||
OPENAI_API_KEY=""
|
||||
OPENAI_MODEL="gpt-3.5-turbo"
|
||||
|
||||
# === LOCAL AI (Optional) ===
|
||||
|
||||
# Ollama (Local AI - kostenlos!)
|
||||
OLLAMA_URL="http://localhost:11434"
|
||||
OLLAMA_MODEL="llama3.2:3b"
|
||||
USE_OLLAMA="false" # true = nutze Ollama statt API
|
||||
|
||||
# === VECTOR DATABASE ===
|
||||
|
||||
# Qdrant (für Maya-Eule Memory)
|
||||
QDRANT_URL="http://localhost:6333"
|
||||
QDRANT_COLLECTION="crumbforest_memory"
|
||||
QDRANT_API_KEY="" # Optional, meist leer bei local
|
||||
|
||||
# === TOKEN BUDGET (Pädagogisch) ===
|
||||
|
||||
# Tages-Budget für bewusstes Fragen (in Tokens)
|
||||
# 0 = unbegrenzt, >0 = Limit (z.B. 10000 = ~20 Fragen)
|
||||
DAILY_TOKEN_BUDGET="0"
|
||||
|
||||
# Warnung bei hohem Token-Verbrauch
|
||||
TOKEN_WARNING_THRESHOLD="1000"
|
||||
|
||||
# === LOGGING ===
|
||||
|
||||
# Token-Log speichern?
|
||||
ENABLE_TOKEN_TRACKING="true"
|
||||
|
||||
# Log-Verzeichnis
|
||||
LOG_DIR="${HOME}/.crumbforest_logs"
|
||||
|
||||
# === CHARAKTERE (AI Assistenten) ===
|
||||
|
||||
# Welche Charaktere sind aktiviert?
|
||||
ENABLE_MAYAEULE="true" # Maya-Eule (Weisheit)
|
||||
ENABLE_DEEPBIT="true" # Deepbit (Bash-Erklärer)
|
||||
ENABLE_BUGSY="true" # Bugsy (Debugging)
|
||||
ENABLE_SCHNIPPSI="true" # Schnippsi (Shell-Helfer)
|
||||
ENABLE_TOBI="true" # Tobi (JSON/Daten)
|
||||
|
||||
# === SICHERHEIT ===
|
||||
|
||||
# Eltern-PIN für Einstellungen (Optional)
|
||||
PARENT_PIN=""
|
||||
|
||||
# Automatische Token-Reports an Eltern?
|
||||
SEND_TOKEN_REPORTS="false"
|
||||
PARENT_EMAIL=""
|
||||
|
||||
# ============================================================
|
||||
# HINWEISE:
|
||||
# - Kopiere diese Datei zu .env und fülle deine Keys ein
|
||||
# - .env wird NICHT ins Git committed (siehe .gitignore)
|
||||
# - Mindestens einen API-Key ODER Ollama konfigurieren
|
||||
# - Qdrant ist optional (für Maya-Eule Memory)
|
||||
# ============================================================
|
||||
48
CLAUDE.md
48
CLAUDE.md
@@ -245,3 +245,51 @@ Located in `snake_camera_vision_v2/gestures/gestures_v4.py`:
|
||||
- Poetic and metaphorical explanations for complex concepts
|
||||
- Designed for children and beginners
|
||||
- Conversational history maintained across sessions
|
||||
|
||||
**Token Philosophy - "Was kostet die Frage eines Kindes?"**
|
||||
|
||||
In the forest, a child's question is priceless. However, in our digital age, questions to AI assistants consume computational resources (tokens). This creates a beautiful teaching moment:
|
||||
|
||||
*"What does a question cost?"*
|
||||
|
||||
- **In the forest:** Unbezahlbar (priceless) - every question holds infinite value
|
||||
- **In the system:** Measured in tokens - a concrete, understandable metric
|
||||
- **Pedagogically:** Token tracking teaches **mindful questioning**
|
||||
|
||||
### Why Token Tracking is Educational
|
||||
|
||||
1. **Teaches Reflection:** Children learn to think before asking
|
||||
2. **Creates Awareness:** Understanding that resources have value
|
||||
3. **Builds Quality:** Better questions lead to better answers
|
||||
4. **Encourages Research:** Try to find answers independently first
|
||||
5. **Develops Patience:** Not every thought needs an immediate AI response
|
||||
|
||||
### Token Budget System
|
||||
|
||||
The `.env` configuration allows setting a `DAILY_TOKEN_BUDGET`:
|
||||
- `0` = Unlimited (default) - trust and freedom
|
||||
- `>0` = Daily limit (e.g., 10000 tokens ≈ 20 thoughtful questions)
|
||||
|
||||
This isn't about restriction - it's about **mindfulness**. Just as we teach children to:
|
||||
- Not waste water
|
||||
- Not waste food
|
||||
- Not waste paper
|
||||
|
||||
We can teach them:
|
||||
- Not to waste computational resources
|
||||
- To value the AI's "thinking time"
|
||||
- To appreciate the cost of knowledge
|
||||
|
||||
### Implementation
|
||||
|
||||
All AI character scripts (`deepbit_zero.sh`, `bugsy_zero.sh`, etc.) log token usage to:
|
||||
- `~/.{character}_logs/token_log.json`
|
||||
|
||||
View with: `./log_tokens_viewer_v4.sh`
|
||||
|
||||
This creates a transparent feedback loop where children can see:
|
||||
- How many tokens each question consumed
|
||||
- Which questions were "expensive" vs "cheap"
|
||||
- Their daily/weekly usage patterns
|
||||
|
||||
**Result:** More thoughtful questions, deeper learning, and respect for resources.
|
||||
|
||||
@@ -16,6 +16,38 @@ NC='\033[0m' # No Color
|
||||
# === KONFIGURATION ===
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
MISSION_DIR="${SCRIPT_DIR}/missions"
|
||||
ENV_FILE="${SCRIPT_DIR}/.env"
|
||||
|
||||
# === ENVIRONMENT LOADER ===
|
||||
function load_env() {
|
||||
if [[ -f "${ENV_FILE}" ]]; then
|
||||
# Lade .env, aber nur nicht-kommentierte Zeilen
|
||||
while IFS='=' read -r key value; do
|
||||
# Skip Kommentare und leere Zeilen
|
||||
[[ "$key" =~ ^#.*$ ]] && continue
|
||||
[[ -z "$key" ]] && continue
|
||||
|
||||
# Entferne Quotes
|
||||
value="${value%\"}"
|
||||
value="${value#\"}"
|
||||
|
||||
# Exportiere Variable
|
||||
export "$key=$value"
|
||||
done < <(grep -v '^#' "${ENV_FILE}" | grep -v '^$')
|
||||
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Versuche .env zu laden
|
||||
if ! load_env; then
|
||||
# Keine .env gefunden - das ist OK, AI Features sind dann deaktiviert
|
||||
AI_AVAILABLE=false
|
||||
else
|
||||
AI_AVAILABLE=true
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# HILFSFUNKTIONEN
|
||||
@@ -339,6 +371,109 @@ EOF
|
||||
rm -f "${GIT_RC}"
|
||||
}
|
||||
|
||||
# ============================================================
|
||||
# AI DOKTOR (Token-Tracking & Status)
|
||||
# ============================================================
|
||||
|
||||
function ai_doktor() {
|
||||
clear
|
||||
echo -e "${BLUE}=== 🤖 AI Assistenten & Token-Tracking ===${NC}"
|
||||
echo ""
|
||||
|
||||
if [[ "$AI_AVAILABLE" == "false" ]]; then
|
||||
echo -e "${YELLOW}⚠️ Keine .env Datei gefunden${NC}"
|
||||
echo ""
|
||||
echo "Um AI-Assistenten zu nutzen:"
|
||||
echo "1. Kopiere .env.template zu .env"
|
||||
echo " ${CYAN}cp .env.template .env${NC}"
|
||||
echo ""
|
||||
echo "2. Füge deine API-Keys ein"
|
||||
echo " ${CYAN}nano .env${NC}"
|
||||
echo ""
|
||||
echo "3. Starte Mission Doktor neu"
|
||||
echo ""
|
||||
read -p "Drücke Enter..." -r
|
||||
return
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}🌲 Crumbforest AI Status${NC}"
|
||||
echo ""
|
||||
|
||||
# Check welche APIs konfiguriert sind
|
||||
echo -e "${YELLOW}Konfigurierte APIs:${NC}"
|
||||
[[ -n "$OPENROUTER_API_KEY" ]] && echo -e " ${GREEN}✅ OpenRouter${NC} (Model: ${OPENROUTER_MODEL:-nicht gesetzt})"
|
||||
[[ -n "$CLAUDE_API_KEY" ]] && echo -e " ${GREEN}✅ Claude API${NC} (Model: ${CLAUDE_MODEL:-nicht gesetzt})"
|
||||
[[ -n "$OPENAI_API_KEY" ]] && echo -e " ${GREEN}✅ OpenAI${NC} (Model: ${OPENAI_MODEL:-nicht gesetzt})"
|
||||
|
||||
if [[ "$USE_OLLAMA" == "true" ]]; then
|
||||
echo -e " ${GREEN}✅ Ollama (Local)${NC} (Model: ${OLLAMA_MODEL:-nicht gesetzt})"
|
||||
fi
|
||||
|
||||
if [[ -z "$OPENROUTER_API_KEY" ]] && [[ -z "$CLAUDE_API_KEY" ]] && [[ -z "$OPENAI_API_KEY" ]] && [[ "$USE_OLLAMA" != "true" ]]; then
|
||||
echo -e " ${RED}❌ Keine API-Keys konfiguriert${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Qdrant Status
|
||||
echo -e "${YELLOW}Vector Database (Qdrant):${NC}"
|
||||
if [[ -n "$QDRANT_URL" ]]; then
|
||||
echo -e " ${GREEN}✅ Konfiguriert${NC} (URL: ${QDRANT_URL})"
|
||||
else
|
||||
echo -e " ${YELLOW}⚠️ Nicht konfiguriert${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Token Budget
|
||||
echo -e "${YELLOW}Token Budget & Philosophie:${NC}"
|
||||
echo -e " ${CYAN}\"Was kostet die Frage eines Kindes?\"${NC}"
|
||||
echo -e " ${CYAN}Im Wald unbezahlbar - Token lehren achtsames Fragen.${NC}"
|
||||
echo ""
|
||||
|
||||
if [[ "${DAILY_TOKEN_BUDGET:-0}" -gt 0 ]]; then
|
||||
echo -e " Tages-Budget: ${GREEN}${DAILY_TOKEN_BUDGET} Tokens${NC}"
|
||||
else
|
||||
echo -e " Tages-Budget: ${GREEN}Unbegrenzt${NC}"
|
||||
fi
|
||||
|
||||
if [[ "${ENABLE_TOKEN_TRACKING}" == "true" ]]; then
|
||||
echo -e " Token-Tracking: ${GREEN}Aktiviert${NC}"
|
||||
else
|
||||
echo -e " Token-Tracking: ${YELLOW}Deaktiviert${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Aktivierte Charaktere
|
||||
echo -e "${YELLOW}Waldwächter (AI Charaktere):${NC}"
|
||||
[[ "${ENABLE_MAYAEULE}" == "true" ]] && echo -e " ${GREEN}✅ Maya-Eule${NC} (Weisheit)"
|
||||
[[ "${ENABLE_DEEPBIT}" == "true" ]] && echo -e " ${GREEN}✅ Deepbit${NC} (Bash-Erklärer)"
|
||||
[[ "${ENABLE_BUGSY}" == "true" ]] && echo -e " ${GREEN}✅ Bugsy${NC} (Debugging)"
|
||||
[[ "${ENABLE_SCHNIPPSI}" == "true" ]] && echo -e " ${GREEN}✅ Schnippsi${NC} (Shell-Helfer)"
|
||||
[[ "${ENABLE_TOBI}" == "true" ]] && echo -e " ${GREEN}✅ Tobi${NC} (JSON/Daten)"
|
||||
|
||||
echo ""
|
||||
|
||||
# Token Logs anzeigen (wenn vorhanden)
|
||||
if [[ "${ENABLE_TOKEN_TRACKING}" == "true" ]]; then
|
||||
echo -e "${YELLOW}Token-Logs:${NC}"
|
||||
LOG_DIR="${LOG_DIR:-$HOME/.crumbforest_logs}"
|
||||
|
||||
if [[ -d "$LOG_DIR" ]]; then
|
||||
TOKEN_COUNT=$(find "$LOG_DIR" -name "token_log.json" 2>/dev/null | wc -l | tr -d ' ')
|
||||
echo -e " Gefunden: ${GREEN}${TOKEN_COUNT} Log-Dateien${NC}"
|
||||
echo ""
|
||||
echo -e " Ansehen mit: ${CYAN}./log_tokens_viewer_v4.sh${NC}"
|
||||
else
|
||||
echo -e " ${YELLOW}Noch keine Logs vorhanden${NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
read -p "Drücke Enter..." -r
|
||||
}
|
||||
|
||||
# ============================================================
|
||||
# HAUPTMENÜ
|
||||
# ============================================================
|
||||
@@ -354,10 +489,11 @@ function main_menu() {
|
||||
echo "4) 🖥️ System Doktor"
|
||||
echo "5) 🛠️ Werkzeug-Check"
|
||||
echo "6) 🌲 Git Doktor"
|
||||
echo "7) 🤖 AI & Token-Tracking"
|
||||
echo ""
|
||||
echo "7) 👋 Beenden"
|
||||
echo "8) 👋 Beenden"
|
||||
echo ""
|
||||
read -p "Auswahl [1-7]: " CHOICE
|
||||
read -p "Auswahl [1-8]: " CHOICE
|
||||
|
||||
case $CHOICE in
|
||||
1) run_mission_menu "basics" "📚 Basics - Einsteiger" ;;
|
||||
@@ -366,7 +502,8 @@ function main_menu() {
|
||||
4) system_doktor ;;
|
||||
5) tools_doktor ;;
|
||||
6) git_doktor ;;
|
||||
7)
|
||||
7) ai_doktor ;;
|
||||
8)
|
||||
clear
|
||||
echo -e "${GREEN}"
|
||||
echo "👋 Auf bald im Crumbforest!"
|
||||
@@ -374,7 +511,7 @@ function main_menu() {
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Bitte 1-7 wählen.${NC}"
|
||||
echo -e "${RED}Bitte 1-8 wählen.${NC}"
|
||||
sleep 1
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user