#!/bin/bash

echo "🔧 Fixing LLM Configuration..."
echo "================================"

# Check if .env file exists
if [ ! -f .env ]; then
    echo "❌ .env file not found!"
    exit 1
fi

echo "📝 Current configuration:"
echo "------------------------"
grep -E "LLM_PROVIDER|LLM_MODEL|OPENAI_API_KEY|ANTHROPIC_API_KEY" .env

echo ""
echo "🔧 Updating configuration to use Anthropic..."
echo "---------------------------------------------"

# Create a backup
cp .env .env.backup
echo "✅ Backup created: .env.backup"

# Update the configuration
sed -i 's/LLM_PROVIDER=openai/LLM_PROVIDER=anthropic/' .env
sed -i 's/LLM_MODEL=gpt-4/LLM_MODEL=claude-3-5-sonnet-20241022/' .env
sed -i 's/OPENAI_API_KEY=sk-ant.*/OPENAI_API_KEY=/' .env

echo "✅ Configuration updated!"

echo ""
echo "📝 New configuration:"
echo "-------------------"
grep -E "LLM_PROVIDER|LLM_MODEL|OPENAI_API_KEY|ANTHROPIC_API_KEY" .env

echo ""
echo "🎉 Configuration fixed!"
echo "📋 Next steps:"
echo "1. The backend should now use Anthropic Claude"
echo "2. Try uploading a new document"
echo "3. The enhanced BPCP CIM Review Template should be generated" 