forked from RTGS2017/NagaAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
57 lines (48 loc) · 1.94 KB
/
setup.ps1
File metadata and controls
57 lines (48 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 一键配置脚本 for NagaAgent 2.1 (极致码高尔夫)
# 版本号由config.py统一管理
$ErrorActionPreference = "Stop" # 设置错误时停止执行
$modelPath = "models/text2vec-base-chinese" # 模型路径
$modelRepo = "shibing624/text2vec-base-chinese" # 模型仓库名
$pythonMinVersion = "3.8" # Python最低版本要求
$venvPath = ".venv" # 虚拟环境路径
# 检查Python版本
$pythonVersion = (python --version 2>&1) -replace "Python "
if ([version]$pythonVersion -lt [version]$pythonMinVersion) {
Write-Error "需要Python $pythonMinVersion或更高版本,当前版本: $pythonVersion"
exit 1
}
# 设置工作目录
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $scriptPath
# 创建并激活虚拟环境
if (-not (Test-Path $venvPath)) {
Write-Host "创建虚拟环境..."
python -m venv $venvPath
}
# 激活虚拟环境
. "$venvPath/Scripts/Activate.ps1"
# 安装依赖(用清华源加速)
Write-Host "安装依赖(使用清华镜像源加速)..."
Get-ChildItem -Filter "requirements*.txt" | ForEach-Object {
pip install -r $_.FullName -i https://pypi.tuna.tsinghua.edu.cn/simple
}
# 安装playwright浏览器驱动
Write-Host "安装playwright浏览器驱动..."
python -m playwright install chromium
# 验证playwright安装
Write-Host "验证playwright安装..."
$playwrightVersion = python -m playwright --version
if ($LASTEXITCODE -ne 0) {
Write-Error "Playwright安装验证失败"
exit 1
}
Write-Host "Playwright版本: $playwrightVersion"
# 检查并下载模型
if (-not (Test-Path $modelPath)) {
Write-Host "下载模型中..."
python -c "from huggingface_hub import snapshot_download; snapshot_download('$modelRepo', local_dir='$modelPath')"
}
Write-Host "环境设置完成!"
Write-Host "如需安装其他浏览器驱动,请运行:"
Write-Host "python -m playwright install firefox # 安装Firefox"
Write-Host "python -m playwright install webkit # 安装WebKit"