12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #!/bin/bash
- # 内容识别脚本启动脚本
- echo "内容识别脚本启动中..."
- # 检查Python环境
- if ! command -v python3 &> /dev/null; then
- echo "错误: 未找到 python3 命令"
- exit 1
- fi
- # 检查依赖
- echo "检查依赖..."
- python3 -c "import pymysql, google.genai, requests, dotenv" 2>/dev/null
- if [ $? -ne 0 ]; then
- echo "错误: 缺少必要的依赖包,请先安装: pip install -r requirements.txt"
- exit 1
- fi
- # 检查环境变量文件
- if [ ! -f ".env" ]; then
- echo "警告: 未找到 .env 文件,将使用默认配置"
- echo "建议创建 .env 文件并配置必要的环境变量"
- fi
- # 显示帮助信息
- echo ""
- echo "使用方法:"
- echo " python3 indentify.py --single # 处理单条记录"
- echo " python3 indentify.py --batch 20 # 批量处理20条记录"
- echo " python3 indentify.py --continuous # 连续处理模式(无限制)"
- echo " python3 indentify.py --continuous --max-records 100 # 连续处理最多100条"
- echo " python3 indentify.py --continuous --delay 5 # 连续处理,间隔5秒"
- echo " python3 indentify.py --help # 显示帮助信息"
- echo ""
- # 运行测试(可选)
- read -p "是否先运行测试?(y/N): " -n 1 -r
- echo
- if [[ $REPLY =~ ^[Yy]$ ]]; then
- echo "运行测试..."
- python3 test_identify.py
- echo ""
- fi
- # 询问运行模式
- echo "请选择运行模式:"
- echo "1) 处理单条记录"
- echo "2) 批量处理记录"
- echo "3) 连续处理模式(推荐)"
- echo "4) 退出"
- read -p "请输入选择 (1-4): " choice
- case $choice in
- 1)
- echo "启动单条记录处理模式..."
- python3 indentify.py --single
- ;;
- 2)
- read -p "请输入批量处理数量 (默认10): " batch_size
- batch_size=${batch_size:-10}
- echo "启动批量处理模式,处理 $batch_size 条记录..."
- python3 indentify.py --batch $batch_size
- ;;
- 3)
- echo "启动连续处理模式..."
- echo "此模式将自动处理数据库中的所有记录,一条完成后自动处理下一条"
- echo ""
- read -p "是否设置最大处理数量限制?(y/N): " -n 1 -r
- echo
- if [[ $REPLY =~ ^[Yy]$ ]]; then
- read -p "请输入最大处理数量: " max_records
- read -p "请输入处理间隔时间(秒,默认2): " delay
- delay=${delay:-2}
- echo "启动连续处理模式,最多处理 $max_records 条记录,间隔 $delay 秒..."
- python3 indentify.py --continuous --max-records $max_records --delay $delay
- else
- read -p "请输入处理间隔时间(秒,默认2): " delay
- delay=${delay:-2}
- echo "启动连续处理模式,无数量限制,间隔 $delay 秒..."
- python3 indentify.py --continuous --delay $delay
- fi
- ;;
- 4)
- echo "退出"
- exit 0
- ;;
- *)
- echo "无效选择,退出"
- exit 1
- ;;
- esac
|