@echo off setlocal EnableExtensions :: =================================================================== :: COSMOS - HER HANDS (giveaway kit) :: :: A terminal where she writes code, builds it, runs it, or just talks. :: Starts her model server (weights/phos.pt and friends), then hands over. :: :: Needs: python with torch. Nothing else -- no rich, no prompt_toolkit. :: =================================================================== cd /d "%~dp0" set "HERE=%CD%" set "PYTHONIOENCODING=utf-8" :: find a python set "PY=" if exist "%HERE%\..\..\00_WAKE\python\python.exe" set "PY=%HERE%\..\..\00_WAKE\python\python.exe" if not defined PY ( where python >nul 2>&1 && set "PY=python" ) if not defined PY ( echo [X] No python found. Install python 3.10+ with torch, then re-run. pause & exit /b 1 ) echo [ok] python: %PY% "%PY%" -c "import torch" >nul 2>&1 if errorlevel 1 ( echo [X] torch is not installed for this python. echo pip install torch pause & exit /b 1 ) echo [ok] torch present if not exist "%HERE%\weights\phos.pt" ( echo [warn] weights\phos.pt missing - she will have no models of her own. echo Download it from the model repo, or train one: echo python architecture\phos_grow.py ) :: bring her model server up on 11501 if nothing is there powershell -NoProfile -Command "if (Get-NetTCPConnection -LocalPort 11501 -State Listen -EA SilentlyContinue){exit 0}else{exit 1}" >nul 2>&1 if errorlevel 1 ( echo [..] starting her model server on 11501... if not exist "%HERE%\logs" mkdir "%HERE%\logs" >nul 2>&1 powershell -NoProfile -Command "$lg=Join-Path '%HERE%\logs' ('serve_' + (Get-Date).ToString('yyyyMMdd_HHmmss') + '.live'); try {Start-Process -FilePath '%PY%' -ArgumentList @('serving\cosmos_serve.py','11501') -WorkingDirectory '%HERE%' -WindowStyle Hidden -RedirectStandardOutput $lg -RedirectStandardError ($lg -replace '\.live$','.err')} catch {}" powershell -NoProfile -Command "1..50 | ForEach-Object { if (Get-NetTCPConnection -LocalPort 11501 -State Listen -EA SilentlyContinue){exit 0}; Start-Sleep -Milliseconds 800 }; exit 1" >nul 2>&1 if errorlevel 1 ( echo [warn] model server did not come up - check logs\serve_*.err echo You can still browse and build files. ) else ( echo [ok] her models are online on 11501 ) ) else ( echo [i] model server already running on 11501 ) echo. "%PY%" "%HERE%\serving\cosmos_coder.py" %* endlocal