#!/bin/bash # Train AGI on CodeFix Marketing & Revenue Generation # Uses Claude API to generate high-quality training data # Budget: Up to 500 API credits set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" AGI_HOME="$(dirname "$SCRIPT_DIR")" TRAINING_DATA="$AGI_HOME/training/codefix_marketing_training.txt" API_KEY="${API_KEY:[credential removed]}" API_ENDPOINT="https://api.anthropic.com/v1/messages" API_MODEL="claude-3-5-sonnet-20241022" TRAINING_LOG="$AGI_HOME/logs/codefix_training.log" KNOWLEDGE_DB="$AGI_HOME/core/knowledge/codefix_knowledge.txt" CREDITS_USED=0 MAX_CREDITS=500 echo "╔════════════════════════════════════════════════════════╗" echo "║ 🧠 CodeFix Marketing & Revenue Generation Training ║" echo "╚════════════════════════════════════════════════════════╝" echo "" echo "Training Data: $TRAINING_DATA" echo "API Model: $API_MODEL" echo "Budget: $MAX_CREDITS credits" echo "" # Create directories mkdir -p "$AGI_HOME/logs" mkdir -p "$AGI_HOME/core/knowledge" # Function to call Claude API call_api() { local prompt="$1" local response_file="$2" local request_json=$(cat < "$KNOWLEDGE_DB" <> "$KNOWLEDGE_DB" <> "$KNOWLEDGE_DB" <> "$KNOWLEDGE_DB" < /dev/null 2>&1; then echo " Starting Gossip Service..." cd "$AGI_HOME/gossip" if [ -f "gossipd" ]; then nohup ./gossipd > "$AGI_HOME/logs/gossip.log" 2>&1 & sleep 2 echo " ✅ Gossip Service started" else echo " ⚠️ Gossip binary not found. Building..." go build -o gossipd main.go nohup ./gossipd > "$AGI_HOME/logs/gossip.log" 2>&1 & sleep 2 echo " ✅ Gossip Service built and started" fi else echo " ✅ Gossip Service already running" fi # Check agent count AGENT_STATS=$(curl -s http://localhost:8008/stats 2>/dev/null || echo "error") if [ "$AGENT_STATS" != "error" ]; then AGENT_COUNT=$(echo "$AGENT_STATS" | grep -o '"agent_count":[0-9]*' | cut -d: -f2) echo " 📊 Current agents: $AGENT_COUNT" # If agent count is low, spawn more if [ "$AGENT_COUNT" -lt 1000 ]; then echo " ⚡ Spawning more agents to reach 10,000..." curl -s -X POST http://localhost:8008/spawn -d '{"count":10000}' > /dev/null 2>&1 sleep 1 AGENT_STATS=$(curl -s http://localhost:8008/stats 2>/dev/null) NEW_COUNT=$(echo "$AGENT_STATS" | grep -o '"agent_count":[0-9]*' | cut -d: -f2) echo " ✅ Agent count increased to: $NEW_COUNT" fi else echo " ⚠️ Cannot connect to Gossip Service" fi echo "" echo "╔════════════════════════════════════════════════════════╗" echo "║ 🎉 CodeFix Marketing Training Complete! ║" echo "╚════════════════════════════════════════════════════════╝" echo "" echo "Knowledge Base Stats:" echo " → Q&A Pairs: $TRAINED_COUNT" echo " → API Credits: ~$CREDITS_USED / $MAX_CREDITS" echo " → Knowledge DB: $KNOWLEDGE_DB ($(wc -l < "$KNOWLEDGE_DB") lines)" echo "" echo "AGI Status:" echo " → Gossip Service: http://localhost:8008/stats" echo " → Agents Active: $(echo "$AGENT_STATS" | grep -o '"agent_count":[0-9]*' | cut -d: -f2 || echo "N/A")" echo " → Training Log: $TRAINING_LOG" echo "" echo "Next Steps:" echo " 1. Test AGI knowledge: curl http://localhost:8008/query -d '{\"q\":\"What is CodeFix?\"}'" echo " 2. View agent stats: curl http://localhost:8008/stats" echo " 3. Check training log: tail -f $TRAINING_LOG" echo "" echo "🚀 The AGI is now trained and ready to assist with CodeFix marketing!" echo ""