@@ -74,7 +74,7 @@ function _platformIcon(platform) {
7474 return '' ;
7575}
7676
77- export let _envState = { env : 'none' , envPath : '' , hfToken : '' , hfTokenConfigured : false , hfTokenMasked : '' , gpus : '' , remoteHost : '' , servers : [ ] , modelPaths : [ ] , platform : '' , defaultServer : '' } ;
77+ export let _envState = { env : 'none' , envPath : '' , hfToken : '' , hfTokenConfigured : false , hfTokenMasked : '' , gpus : '' , remoteHost : '' , servers : [ ] , modelPaths : [ ] , platform : '' , hostPlatform : '' , defaultServer : '' } ;
7878let _lastCacheHostVal = null ;
7979let _cookbookOpeningSpinners = [ ] ;
8080export function _lastCacheHost ( ) { return _lastCacheHostVal ; }
@@ -211,8 +211,13 @@ function _getPort(hostOrTask) {
211211
212212/** Get platform for a given host (or task object). Returns 'windows', 'termux', 'linux', or '' */
213213export function _getPlatform ( hostOrTask ) {
214- if ( ! hostOrTask ) return _envState . platform || '' ;
215- if ( typeof hostOrTask === 'object' ) return hostOrTask . platform || _getPlatform ( hostOrTask . remoteServerKey || hostOrTask . remoteHost ) ;
214+ if ( hostOrTask === 'local' ) return _envState . hostPlatform || '' ;
215+ if ( ! hostOrTask ) return _envState . remoteHost ? ( _envState . platform || '' ) : ( _envState . hostPlatform || '' ) ;
216+ if ( typeof hostOrTask === 'object' ) {
217+ const taskHost = hostOrTask . remoteServerKey || hostOrTask . remoteHost || '' ;
218+ if ( ! taskHost || taskHost === 'local' ) return _envState . hostPlatform || '' ;
219+ return hostOrTask . platform || _getPlatform ( taskHost ) ;
220+ }
216221 const selected = hostOrTask === _envState . remoteHost ? _selectedServer ( ) : null ;
217222 const srv = selected || _serverByVal ( hostOrTask ) ;
218223 return srv ?. platform || '' ;
@@ -636,7 +641,12 @@ export function _buildServeCmd(f, modelName, backend) {
636641 // GPU list — read from gpus (button strip); fall back to gpu_id for
637642 // backward-compat with older saved presets that pre-date the removal.
638643 const gpuId = ( f . gpus || f . gpu_id || '' ) . toString ( ) . trim ( ) ;
639- const py = _isWindows ( ) ? 'python' : 'python3' ;
644+ const _targetHost = Object . prototype . hasOwnProperty . call ( f , 'host' )
645+ ? String ( f . host || '' ) . trim ( )
646+ : String ( _envState . remoteHost || '' ) . trim ( ) ;
647+ const _isWin = _targetHost ? _isWindows ( _targetHost ) : _isWindows ( 'local' ) ;
648+ const _localWindows = _isWin && ! _targetHost ;
649+ const py = _isWin ? 'python' : 'python3' ;
640650 // CPU-only serve (-ngl 0): drop the GPU-only flags, otherwise the command
641651 // mixes "zero GPU layers" with CUDA unified-memory + flash-attn and fails to
642652 // start (issue #1291). Only affects the ngl=0 path; GPU serving is unchanged.
@@ -658,19 +668,19 @@ export function _buildServeCmd(f, modelName, backend) {
658668 // with misleading prefixes.
659669 const _sb = String ( _hwfitCache ?. system ?. backend || '' ) . toLowerCase ( ) ;
660670 const _hwfitHost = String ( _hwfitCache ?. _scannedHost || '' ) ;
661- const _curHost = String ( _envState . remoteHost || '' ) ;
671+ const _curHost = _targetHost ;
662672 const _isCudaTarget = ( _sb === 'cuda' ) && ( _hwfitHost === _curHost ) ;
663673 const lcPrefix = ( ( ) => {
664674 let p = '' ;
665- if ( f . unified_mem && ! _cpuOnly && ! _isWindows ( ) && _isCudaTarget ) p += `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 ` ;
666- // No GPU env var in CPU mode — `-ngl 0` already disables offload
675+ if ( f . unified_mem && ! _cpuOnly && ( ! _isWin || _localWindows ) && _isCudaTarget ) p += `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 ` ;
676+ // No GPU env var in CPU mode - `-ngl 0` already disables offload
667677 // so CUDA_VISIBLE_DEVICES / HIP_VISIBLE_DEVICES would be misleading
668678 // clutter ("why is CUDA pinned for a CPU run?").
669- if ( ! _isWindows ( ) && ! _cpuOnly ) p += _gpuEnvPrefix ( gpuId ) ;
679+ if ( ( ! _isWin || _localWindows ) && ! _cpuOnly ) p += _gpuEnvPrefix ( gpuId ) ;
670680 return p ;
671681 } ) ( ) ;
672- if ( f . unified_mem && ! _cpuOnly && _isWindows ( ) && _isCudaTarget ) cmd += `$env:GGML_CUDA_ENABLE_UNIFIED_MEMORY="1"; ` ;
673- if ( _isWindows ( ) && ! _cpuOnly ) cmd += _gpuEnvPrefix ( gpuId , true ) ;
682+ if ( f . unified_mem && ! _cpuOnly && _isWin && ! _localWindows && _isCudaTarget ) cmd += `$env:GGML_CUDA_ENABLE_UNIFIED_MEMORY="1"; ` ;
683+ if ( _isWin && ! _localWindows && ! _cpuOnly ) cmd += _gpuEnvPrefix ( gpuId , true ) ;
674684 const needsGgufPrelude = / ^ \$ \( \{ \s * f i n d \s / . test ( String ( ggufPath || '' ) ) ;
675685 const modelArg = needsGgufPrelude ? '"$MODEL_FILE"' : `"${ ggufPath } "` ;
676686 // Prefer native llama-server. The backend bootstrap resolves/builds the
@@ -742,11 +752,16 @@ export function _buildServeCmd(f, modelName, backend) {
742752 // llama-cpp-python takes the projector via --clip_model_path.
743753 _lcpExtra += ` --clip_model_path "${ f . _mmproj_path } "` ;
744754 }
745- if ( _isWindows ( ) ) {
746- const _lcpServer = `${ lcPrefix } ${ py } -m llama_cpp.server --model ${ modelArg } --host 0.0.0.0 --port ${ f . port || '8080' } --n_gpu_layers ${ f . ngl || '99' } --n_ctx ${ f . ctx || '8192' } ${ _lcpExtra } ` ;
755+ const _lcServer = `${ lcPrefix } llama-server --model ${ modelArg } --host 0.0.0.0 --port ${ f . port || '8080' } -ngl ${ f . ngl || '99' } -c ${ f . ctx || '8192' } ${ _lcExtra } ` ;
756+ const _lcpServer = `${ lcPrefix } ${ py } -m llama_cpp.server --model ${ modelArg } --host 0.0.0.0 --port ${ f . port || '8080' } --n_gpu_layers ${ f . ngl || '99' } --n_ctx ${ f . ctx || '8192' } ${ _lcpExtra } ` ;
757+ if ( _localWindows ) {
758+ // Local Windows serve is launched through Git Bash, so use the native
759+ // llama-server shape and let PATH resolve the CUDA Release wrapper.
760+ cmd += _lcServer ;
761+ } else if ( _isWin ) {
747762 cmd += _lcpServer ;
748763 } else {
749- cmd += ` ${ lcPrefix } llama-server --model ${ modelArg } --host 0.0.0.0 --port ${ f . port || '8080' } -ngl ${ f . ngl || '99' } -c ${ f . ctx || '8192' } ${ _lcExtra } ` ;
764+ cmd += _lcServer ;
750765 }
751766 if ( needsGgufPrelude ) {
752767 cmd = `MODEL_FILE=${ ggufPath } && { [ -n "$MODEL_FILE" ] && [ -f "$MODEL_FILE" ]; } || { echo "ERROR: No GGUF found on this host"; exit 1; } && ${ cmd } ` ;
@@ -2615,13 +2630,14 @@ function _renderRecipes() {
26152630 const isLocal = ! s . host || s . host . toLowerCase ( ) === 'local' ;
26162631 if ( isLocal ) {
26172632 s . host = '' ;
2633+ s . platform = _envState . hostPlatform || '' ;
26182634 if ( _localSeen ) return false ;
26192635 _localSeen = true ;
26202636 }
26212637 return true ;
26222638 } ) ;
26232639 if ( ! _localSeen ) {
2624- _es . servers . unshift ( { host : '' , env : _es . env || 'none' , envPath : _es . envPath || '' , modelDir : '~/.cache/huggingface/hub' } ) ;
2640+ _es . servers . unshift ( { host : '' , env : _es . env || 'none' , envPath : _es . envPath || '' , modelDir : '~/.cache/huggingface/hub' , platform : _envState . hostPlatform || '' } ) ;
26252641 }
26262642 if ( _es . remoteHost && ! _es . servers . some ( s => s . host === _es . remoteHost ) ) {
26272643 _es . servers . push ( { host : _es . remoteHost , env : _es . env || 'none' , envPath : _es . envPath || '' , modelDir : '~/.cache/huggingface/hub' } ) ;
0 commit comments