#!/bin/bash
# 🚀 向量记忆系统 - 一键部署脚本

echo "=========================================="
echo "🧠 OpenClaw 向量记忆系统 - 快速部署"
echo "=========================================="

# 1. 安装依赖
echo ""
echo "📦 步骤 1: 安装 Python 依赖..."
if ! command -v pip3 &> /dev/null; then
    echo "   需要先安装 pip，请运行:"
    echo "   sudo apt-get update && sudo apt-get install -y python3-pip"
    exit 1
fi

pip3 install chromadb openai sqlalchemy

# 2. 设置 API Key
echo ""
echo "🔑 步骤 2: 设置 API Key..."
if [ -z "$SILICONFLOW_API_KEY" ]; then
    echo "   请运行以下命令（推荐写入 ~/.bashrc）:"
    echo '   export SILICONFLOW_API_KEY="sk-fpjdtxbxrhtekshircjhegstloxaodriekotjdyzzktyegcl"'
    echo ""
    echo "   或者临时运行:"
    echo '   SILICONFLOW_API_KEY="sk-fpjdtxbxrhtekshircjhegstloxaodriekotjdyzzktyegcl" python3 test_memory.py'
fi

# 3. 创建目录
echo ""
echo "📁 步骤 3: 创建数据目录..."
mkdir -p ~/openclaw-memory-vector/data/memory

echo ""
echo "=========================================="
echo "✅ 部署完成！"
echo "=========================================="
echo ""
echo "📋 使用方法:"
echo ""
echo "1️⃣  测试运行:"
echo "   cd ~/openclaw-memory-vector"
echo '   export SILICONFLOW_API_KEY="sk-fpjdtxbxrhtekshircjhegstloxaodriekotjdyzzktyegcl"'
echo "   python3 test_memory.py"
echo ""
echo "2️⃣  添加记忆:"
echo '   python3 memory_cli.py add "今天学习了向量数据库" --importance 4 --tags 学习'
echo ""
echo "3️⃣  搜索记忆:"
echo '   python3 memory_cli.py search "股票"'
echo ""
echo "4️⃣  查看最近:"
echo "   python3 memory_cli.py recent"
echo ""
echo "5️⃣  统计数量:"
echo "   python3 memory_cli.py count"
echo ""
