@@ -73,7 +73,7 @@ function _platformIcon(platform) {
7373 return '' ;
7474}
7575
76- export let _envState = { env : 'none' , envPath : '' , hfToken : '' , hfTokenConfigured : false , hfTokenMasked : '' , gpus : '' , remoteHost : '' , servers : [ ] , modelPaths : [ ] , platform : '' , defaultServer : '' } ;
76+ export let _envState = { env : 'none' , envPath : '' , hfToken : '' , hfTokenConfigured : false , hfTokenMasked : '' , gpus : '' , remoteHost : '' , servers : [ ] , modelPaths : [ ] , platform : '' , hostPlatform : '' , defaultServer : '' } ;
7777let _lastCacheHostVal = null ;
7878let _cookbookOpeningSpinners = [ ] ;
7979export function _lastCacheHost ( ) { return _lastCacheHostVal ; }
@@ -210,8 +210,13 @@ function _getPort(hostOrTask) {
210210
211211/** Get platform for a given host (or task object). Returns 'windows', 'termux', 'linux', or '' */
212212export function _getPlatform ( hostOrTask ) {
213- if ( ! hostOrTask ) return _envState . platform || '' ;
214- if ( typeof hostOrTask === 'object' ) return hostOrTask . platform || _getPlatform ( hostOrTask . remoteServerKey || hostOrTask . remoteHost ) ;
213+ if ( hostOrTask === 'local' ) return _envState . hostPlatform || '' ;
214+ if ( ! hostOrTask ) return _envState . remoteHost ? ( _envState . platform || '' ) : ( _envState . hostPlatform || '' ) ;
215+ if ( typeof hostOrTask === 'object' ) {
216+ const taskHost = hostOrTask . remoteServerKey || hostOrTask . remoteHost || '' ;
217+ if ( ! taskHost || taskHost === 'local' ) return _envState . hostPlatform || '' ;
218+ return hostOrTask . platform || _getPlatform ( taskHost ) ;
219+ }
215220 const selected = hostOrTask === _envState . remoteHost ? _selectedServer ( ) : null ;
216221 const srv = selected || _serverByVal ( hostOrTask ) ;
217222 return srv ?. platform || '' ;
@@ -532,25 +537,27 @@ export function _buildServeCmd(f, modelName, backend) {
532537 // GPU list — read from gpus (button strip); fall back to gpu_id for
533538 // backward-compat with older saved presets that pre-date the removal.
534539 const gpuId = ( f . gpus || f . gpu_id || '' ) . toString ( ) . trim ( ) ;
535- const py = _isWindows ( ) ? 'python' : 'python3' ;
540+ const _isWin = _isWindows ( ) ;
541+ const _localWindows = _isWin && ! _envState . remoteHost ;
542+ const py = _isWin ? 'python' : 'python3' ;
536543 // CPU-only serve (-ngl 0): drop the GPU-only flags, otherwise the command
537544 // mixes "zero GPU layers" with CUDA unified-memory + flash-attn and fails to
538545 // start (issue #1291). Only affects the ngl=0 path; GPU serving is unchanged.
539546 const _cpuOnly = String ( f . ngl ) . trim ( ) === '0' ;
540547 const lcPrefix = ( ( ) => {
541548 let p = '' ;
542- if ( f . unified_mem && ! _cpuOnly && ! _isWindows ( ) ) p += `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 ` ;
543- if ( gpuId && ! _isWindows ( ) ) p += `CUDA_VISIBLE_DEVICES=${ gpuId } ` ;
549+ if ( f . unified_mem && ! _cpuOnly && ( ! _isWin || _localWindows ) ) p += `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 ` ;
550+ if ( gpuId && ( ! _isWin || _localWindows ) ) p += `CUDA_VISIBLE_DEVICES=${ gpuId } ` ;
544551 return p ;
545552 } ) ( ) ;
546- if ( f . unified_mem && ! _cpuOnly && _isWindows ( ) ) cmd += `$env:GGML_CUDA_ENABLE_UNIFIED_MEMORY="1"; ` ;
547- if ( gpuId && _isWindows ( ) ) cmd += `$env:CUDA_VISIBLE_DEVICES="${ gpuId } "; ` ;
548- if ( ! _isWindows ( ) ) {
553+ if ( f . unified_mem && ! _cpuOnly && _isWin && ! _localWindows ) cmd += `$env:GGML_CUDA_ENABLE_UNIFIED_MEMORY="1"; ` ;
554+ if ( gpuId && _isWin && ! _localWindows ) cmd += `$env:CUDA_VISIBLE_DEVICES="${ gpuId } "; ` ;
555+ if ( ! _isWin ) {
549556 // Resolve GGUF path once, fail loudly if nothing matched (prevents
550557 // `--model ""` which causes confusing downstream errors).
551558 cmd += `MODEL_FILE=${ ggufPath } && { [ -n "$MODEL_FILE" ] && [ -f "$MODEL_FILE" ]; } || { echo "ERROR: No GGUF found on this host. Either download the model here, or switch to the server where it's cached."; exit 1; } && ` ;
552559 }
553- const modelArg = _isWindows ( ) ? `"${ ggufPath } "` : `"$MODEL_FILE"` ;
560+ const modelArg = _isWin ? `"${ ggufPath } "` : `"$MODEL_FILE"` ;
554561 // Prefer the native llama-server binary on Linux — its minja templating
555562 // renders modern GGUF chat templates that the Python bindings' Jinja2
556563 // rejects (do_tojson ensure_ascii). Fall back to llama_cpp.server.
@@ -613,11 +620,16 @@ export function _buildServeCmd(f, modelName, backend) {
613620 // llama-cpp-python takes the projector via --clip_model_path.
614621 _lcpExtra += ` --clip_model_path "${ f . _mmproj_path } "` ;
615622 }
623+ 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 } ` ;
616624 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 } ` ;
617- if ( _isWindows ( ) ) {
625+ if ( _localWindows ) {
626+ // Local Windows serve is launched through Git Bash, so use the native
627+ // llama-server shape and let PATH resolve the CUDA Release wrapper.
628+ cmd += _lcServer ;
629+ } else if ( _isWin ) {
618630 cmd += _lcpServer ;
619631 } else {
620- cmd += ` ${ lcPrefix } llama-server --model ${ modelArg } --host 0.0.0.0 --port ${ f . port || '8080' } -ngl ${ f . ngl || '99' } -c ${ f . ctx || '8192' } ${ _lcExtra } ` ;
632+ cmd += _lcServer ;
621633 cmd += ` || ${ _lcpServer } ` ;
622634 }
623635 } else if ( backend === 'ollama' ) {
@@ -2099,13 +2111,14 @@ function _renderRecipes() {
20992111 const isLocal = ! s . host || s . host . toLowerCase ( ) === 'local' ;
21002112 if ( isLocal ) {
21012113 s . host = '' ;
2114+ s . platform = _envState . hostPlatform || _envState . platform || '' ;
21022115 if ( _localSeen ) return false ;
21032116 _localSeen = true ;
21042117 }
21052118 return true ;
21062119 } ) ;
21072120 if ( ! _localSeen ) {
2108- _es . servers . unshift ( { host : '' , env : _es . env || 'none' , envPath : _es . envPath || '' , modelDir : '~/.cache/huggingface/hub' } ) ;
2121+ _es . servers . unshift ( { host : '' , env : _es . env || 'none' , envPath : _es . envPath || '' , modelDir : '~/.cache/huggingface/hub' , platform : _envState . hostPlatform || _envState . platform || '' } ) ;
21092122 }
21102123 if ( _es . remoteHost && ! _es . servers . some ( s => s . host === _es . remoteHost ) ) {
21112124 _es . servers . push ( { host : _es . remoteHost , env : _es . env || 'none' , envPath : _es . envPath || '' , modelDir : '~/.cache/huggingface/hub' } ) ;
0 commit comments