Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/AI_Brain / the_tired_agi/scripts/train_codefix_marketing.sh |
| Date | Not specified in source |
| Repository | Janady13/AI_Brain |
| Revision | d6c309d3fa439714ca46b9d3bb94caf478ea5376 |
| Branch | main |
| Path or archive member | the_tired_agi/scripts/train_codefix_marketing.sh |
| Original SHA-256 | 70786a02b142126bd0adc0870ab61739bd7019c0d2ae2c417e4fcb3b4a6faf95 |
| Git blob SHA | 28fe601d82a382c6b9966239b3ea4883f39a7aa1 |
| Reading-copy SHA-256 | aef53300f277e82873d16cd1ff42f8f32310d5c5a2346e7e62bd1c8d33c46e85 |
Every recorded occurrence
These 2 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/AI_Brain / the_tired_agi/scripts/train_codefix_marketing.sh | main | d6c309d3fa439714ca46b9d3bb94caf478ea5376 | Open original |
| Janady13/AI_Brain / the_tired_agi/scripts/train_codefix_marketing.sh | claude/binary-helix-fibonacci-hive-011CUj7dx1WWJLVYcWCjBbYv | 527d4882c71eb041393f9d8945996177c5ac9e86 | Open original |
Recovered source transcript
Download complete source text ↓234 lines · 7.4 KB
Credential-bearing and unrelated personal details were removed from this reading copy. The source identity and original checksum remain recorded.
#!/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 <<EOF
{
"model": "$API_MODEL",
"max_tokens": 4096,
"messages": [{
"role": "user",
"content": "$prompt"
}]
}
EOF
)
local http_code=$(curl -s -w "%{http_code}" -o "$response_file" \
-X POST "$API_ENDPOINT" \
-H "x-api-key: $API_KEY" \
-H "content-type: application/json" \
-d "$request_json")
echo "$http_code"
}
# Extract Q&A pairs from training data
extract_qa_pairs() {
grep -E "^Q:|^A:" "$TRAINING_DATA" | \
awk 'BEGIN {q=""; a=""}
/^Q:/ {if (q!="" && a!="") print q "|" a; q=$0; a=""}
/^A:/ {a=$0}
END {if (q!="" && a!="") print q "|" a}'
}
echo "📊 Extracting Q&A pairs from training data..."
QA_PAIRS=$(extract_qa_pairs)
QA_COUNT=$(echo "$QA_PAIRS" | wc -l)
echo " Found $QA_COUNT Q&A pairs"
echo ""
echo "🤖 Training AGI using Claude API..."
echo " This will generate high-quality responses and store them in the knowledge base"
echo ""
# Initialize knowledge base
cat > "$KNOWLEDGE_DB" <<EOF
# CodeFix Marketing & Revenue Generation Knowledge Base
# Generated by Claude API training
# $(date)
EOF
TRAINED_COUNT=0
BATCH_SIZE=10
while IFS='|' read -r question answer; do
TRAINED_COUNT=$((TRAINED_COUNT + 1))
# Progress indicator
if [ $((TRAINED_COUNT % BATCH_SIZE)) -eq 0 ]; then
PROGRESS=$((TRAINED_COUNT * 100 / QA_COUNT))
echo " Progress: $TRAINED_COUNT/$QA_COUNT ($PROGRESS%) - Credits used: ~$CREDITS_USED"
fi
# Clean up question and answer
Q_CLEAN=$(echo "$question" | sed 's/^Q: //')
A_CLEAN=$(echo "$answer" | sed 's/^A: //')
# For every 5th question, enhance with Claude API
if [ $((TRAINED_COUNT % 5)) -eq 0 ] && [ $CREDITS_USED -lt $MAX_CREDITS ]; then
# Create enhanced prompt
ENHANCE_PROMPT="You are a CodeFix marketing and sales expert. Given this Q&A about CodeFix, provide 3 additional insights or examples that would help someone better understand and sell this capability:\n\nQ: $Q_CLEAN\nA: $A_CLEAN\n\nProvide 3 concrete, actionable insights:"
# Call API
RESPONSE_FILE="/tmp/claude_response_$TRAINED_COUNT.json"
HTTP_CODE=$(call_api "$ENHANCE_PROMPT" "$RESPONSE_FILE")
if [ "$HTTP_CODE" = "200" ]; then
# Extract response content
ENHANCED=$(cat "$RESPONSE_FILE" | grep -o '"text":"[^"]*"' | head -1 | sed 's/"text":"//;s/"$//' | sed 's/\\n/\n/g')
# Add to knowledge base
cat >> "$KNOWLEDGE_DB" <<EOF
## $Q_CLEAN
**Answer**: $A_CLEAN
**Enhanced Insights**:
$ENHANCED
---
EOF
CREDITS_USED=$((CREDITS_USED + 10)) # Estimate 10 credits per API call
else
# API failed, just use basic answer
cat >> "$KNOWLEDGE_DB" <<EOF
## $Q_CLEAN
**Answer**: $A_CLEAN
---
EOF
fi
else
# No API call, just store the Q&A
cat >> "$KNOWLEDGE_DB" <<EOF
## $Q_CLEAN
**Answer**: $A_CLEAN
---
EOF
fi
# Stop if we've used too many credits
if [ $CREDITS_USED -ge $MAX_CREDITS ]; then
echo " ⚠️ Reached credit limit ($MAX_CREDITS). Stopping API calls."
echo " Remaining Q&A pairs will be added without enhancement."
break
fi
done <<< "$QA_PAIRS"
echo ""
echo "✅ Training complete!"
echo " Total Q&A pairs processed: $TRAINED_COUNT"
echo " API credits used: ~$CREDITS_USED"
echo " Knowledge base: $KNOWLEDGE_DB"
echo ""
# Now wake up the AGI agents and load the knowledge
echo "🚀 Waking up AGI agents..."
echo ""
# Start gossip service if not running
if ! curl -s -m 2 http://localhost:8008/stats > /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 ""