diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..a51e90c --- /dev/null +++ b/install.ps1 @@ -0,0 +1,94 @@ +# wechatauto-replica 一键安装脚本(Windows PowerShell,管理员运行) +# 用法:irm https://gite.aiyuntuan.com/xiaoxiao_unai/wechatauto-replica/raw/branch/main/install.ps1 | iex +# 或本地:.\install.ps1 +$ErrorActionPreference = "Stop" +$RepoUrl = "https://gite.aiyuntuan.com/xiaoxiao_unai/wechatauto-replica.git" +$InstallDir = "C:\wechatauto-replica" + +Write-Host "==== wechatauto-replica 一键安装 ====" -ForegroundColor Cyan + +# 1. 检查 git +if (-not (Get-Command git -ErrorAction SilentlyContinue)) { + Write-Host "[错误] 未检测到 git。请先安装 https://git-scm.com/download/win" -ForegroundColor Red + exit 1 +} +# 2. 检查 python +if (-not (Get-Command python -ErrorAction SilentlyContinue)) { + Write-Host "[错误] 未检测到 python。请先安装 Python 3.9+ 并勾选 Add to PATH" -ForegroundColor Red + exit 1 +} +$pyVer = python --version 2>&1 +Write-Host "[1/6] 环境: $pyVer, git 已就绪" + +# 3. clone(已存在则跳过) +if (Test-Path "$InstallDir\.git") { + Write-Host "[2/6] 项目已存在: $InstallDir(跳过 clone)" -ForegroundColor Yellow +} else { + Write-Host "[2/6] clone 公开仓库 -> $InstallDir" + git clone $RepoUrl $InstallDir + if ($LASTEXITCODE -ne 0) { Write-Host "[错误] clone 失败,检查网络(内网需连公司 VPN)" -ForegroundColor Red; exit 1 } +} +Set-Location $InstallDir + +# 4. venv +if (-not (Test-Path ".venv\Scripts\python.exe")) { + Write-Host "[3/6] 创建虚拟环境 .venv" + python -m venv .venv +} else { + Write-Host "[3/6] .venv 已存在(跳过)" -ForegroundColor Yellow +} +$Py = ".venv\Scripts\python.exe" + +# 5. 依赖 +Write-Host "[4/6] 安装依赖(pip install -e . + winsdk pypinyin)" +& $Py -m pip install --upgrade pip +& $Py -m pip install -e . +& $Py -m pip install winsdk pypinyin +if ($LASTEXITCODE -ne 0) { Write-Host "[错误] 依赖安装失败" -ForegroundColor Red; exit 1 } + +# 6. 生成 ai_config.json 模板(不存在才生成,保留客户已有配置) +if (-not (Test-Path "ai_config.json")) { + Write-Host "[5/6] 生成 ai_config.json 模板(请填入 DeepSeek API Key)" + $tmpl = @' +{ + "llm": { + "api_key": "PASTE_YOUR_DEEPSEEK_API_KEY_HERE", + "base_url": "https://api.deepseek.com/v1", + "model": "deepseek-chat", + "timeout_sec": 60, + "max_retry": 2 + }, + "persona": { + "name": "微信本人", + "system_prompt": "你是这个微信账号本人,正在用自己的微信跟好友/客户聊天。用自己平时的口吻说话,像真人发微信,不是客服、不是机器人。短句口语、禁客服套话、禁 emoji、不硬推销;没把握的信息(价格、合同、承诺、资质、发货时间等)一律回「这个我确认下,回头回你」,别瞎编。" + }, + "knowledge": { "vault_dir": "kb", "top_k": 3, "max_chars_per_note": 1500 }, + "reply": { + "enabled": true, + "only_prefix": ["wxid_"], + "blocklist": ["filehelper"], + "cooldown_sec": 5, + "history_turns": 10, + "history_window_sec": 86400, + "fallback_reply": "【自动回复】已收到您的消息,稍后回复您。", + "keyword_rules": {}, + "allowlist": [] + }, + "storage": { "conversation_dir": "data/conversations" } +} +'@ + Set-Content -Path "ai_config.json" -Value $tmpl -Encoding UTF8 +} else { + Write-Host "[5/6] ai_config.json 已存在(跳过模板)" -ForegroundColor Yellow +} + +# 7. 自检 +Write-Host "[6/6] 自检 import" +& $Py -c "from wechatauto import WeChatDB; print('OK: wechatauto 安装成功')" +if ($LASTEXITCODE -ne 0) { Write-Host "[错误] import 自检失败" -ForegroundColor Red; exit 1 } + +Write-Host "" +Write-Host "==== 安装完成 ====" -ForegroundColor Green +Write-Host "1) 编辑 $InstallDir\ai_config.json,把 llm.api_key 换成自己的 DeepSeek Key" +Write-Host "2) 启动 AI 客服: cd $InstallDir && .venv\Scripts\python.exe wechat_ai_reply.py" +Write-Host "3) 测试发消息: 看项目 README.md 的 Quick Start"