#!/bin/bash
# 炼妖壶 (Lianyaohu) - 虚拟环境设置脚本
# 用于快速初始化项目开发环境

set -e  # 遇到错误时退出

echo "🔧 开始设置炼妖壶项目虚拟环境..."

# 检查Python版本
echo "📋 检查Python版本..."
python3 --version

# 创建虚拟环境（如果不存在）
if [ ! -d "venv" ]; then
    echo "🏗️  创建虚拟环境..."
    python3 -m venv venv
else
    echo "✅ 虚拟环境已存在"
fi

# 激活虚拟环境
echo "🚀 激活虚拟环境..."
source venv/bin/activate

# 升级pip
echo "⬆️  升级pip..."
pip install --upgrade pip

# 安装项目依赖
echo "📦 安装项目依赖..."
pip install -r requirements.txt

# 检查关键依赖
echo "🔍 检查关键依赖安装状态..."
echo "  - streamlit: $(pip show streamlit | grep Version || echo '未安装')" 
echo "  - openai: $(pip show openai | grep Version || echo '未安装')"
echo "  - google-cloud-aiplatform: $(pip show google-cloud-aiplatform | grep Version || echo '未安装')"
echo "  - aiohttp: $(pip show aiohttp | grep Version || echo '未安装')"

echo "✨ 虚拟环境设置完成！"
echo ""
echo "📝 使用说明："
echo "  1. 激活虚拟环境: source venv/bin/activate"
echo "  2. 运行辩论系统: python examples/debates/baxian_adk_gemini_debate.py"
echo "  3. 启动Web界面: streamlit run app.py (如果有)"
echo "  4. 退出虚拟环境: deactivate"
echo ""
echo "🔧 环境变量配置："
echo "  请确保 .env 文件中配置了必要的API密钥："
echo "  - GOOGLE_API_KEY (Google Gemini API)"
echo "  - GOOGLE_CLOUD_PROJECT_ID (GCP项目ID)"
echo "  - GOOGLE_CLOUD_LOCATION (GCP区域)"
echo ""
echo "🎉 准备就绪！开始你的AI辩论之旅吧！"