Files
crumbmissions/crumbmission/schnecki_zero_final.sh
Branko May Trinkwald 2915828adf Add complete Crumbforest mission system
- Interactive mission selector with metadata-driven design
- 5 educational missions (basics + advanced)
- AI assistant roles (Deepbit, Bugsy, Schnippsi, Tobi)
- SnakeCam gesture recognition system
- Token tracking utilities
- CLAUDE.md documentation
- .gitignore for logs and secrets
2025-12-21 01:16:48 +01:00

59 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
ROLE="SCHNECKI"
CONFIG_FILE="/home/zero/.crumbforest_config"
MODEL=$(grep "^${ROLE}=" "$CONFIG_FILE" | cut -d'=' -f2)
# Fallback auf DEFAULT falls leer
if [[ -z "$MODEL" ]]; then
MODEL=$(grep "^DEFAULT=" "$CONFIG_FILE" | cut -d'=' -f2)
fi
source /usr/local/bin/crumb_init.sh
source /usr/local/bin/crumb_logger.sh
crumb_init
QUESTION="$*"
API_KEY="${OPENROUTER_API_KEY}"
LOG_DIR="$HOME/.schnecki_logs"
mkdir -p "$LOGDIR"
HISTORY_FILE="$LOG_DIR/schnecki_history.json"
TOKEN_LOG="$LOG_DIR/token_log.json"
TMP_REQUEST="$LOG_DIR/schnecki_request.json"
TMP_RESPONSE="$LOG_DIR/schnecki_response.json"
echo "Rolle: $ROLE nutzt Modell: $MODEL"
echo "Schnecki antwortet ruhig auf: $QUESTION"
jq -n \
--arg model "$MODEL" \
--arg system_prompt "You are Schnecki, the Crumbforest's expert in mechanical engineering and tools. You explain things with patience and clarity, using child-friendly metaphors, poetic structure, and solid mechanical insight. You respond in the language of the question, primarily German." \
--arg user_input "$QUESTION" \
'{"model": $model, "temperature": 0.3, "messages": [{"role": "system", "content": $system_prompt}, {"role": "user", "content": $user_input}]}' > "$TMP_REQUEST"
# Anfrage an OpenRouter senden
curl -s https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d @"$TMP_REQUEST" \
-o "$TMP_RESPONSE"
# Antwort extrahieren
REPLY=$(jq -r '.choices[0].message.content' "$TMP_RESPONSE")
USAGE=$(jq -r '.usage' "$TMP_RESPONSE")
echo -e "Antwort von Schnecki:"
echo "$REPLY"
crumb_log "$ROLE" "$REPLY" "$TMP_RESPONSE"