fix: check for env value before setting (#6266)
* fix: check for env value before setting * Use empty instead of none
This commit is contained in:
parent
ef90f07db8
commit
64a608039b
@ -16,7 +16,7 @@
|
|||||||
"description": "Environmental variables for llama.cpp(KEY=VALUE), separated by ';'",
|
"description": "Environmental variables for llama.cpp(KEY=VALUE), separated by ';'",
|
||||||
"controllerType": "input",
|
"controllerType": "input",
|
||||||
"controllerProps": {
|
"controllerProps": {
|
||||||
"value": "none",
|
"value": "",
|
||||||
"placeholder": "Eg. GGML_VK_VISIBLE_DEVICES=0,1",
|
"placeholder": "Eg. GGML_VK_VISIBLE_DEVICES=0,1",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"textAlign": "right"
|
"textAlign": "right"
|
||||||
|
|||||||
@ -1082,9 +1082,9 @@ export default class llamacpp_extension extends AIEngine {
|
|||||||
|
|
||||||
// If we reach here, download completed successfully (including validation)
|
// If we reach here, download completed successfully (including validation)
|
||||||
// The downloadFiles function only returns successfully if all files downloaded AND validated
|
// The downloadFiles function only returns successfully if all files downloaded AND validated
|
||||||
events.emit(DownloadEvent.onFileDownloadAndVerificationSuccess, {
|
events.emit(DownloadEvent.onFileDownloadAndVerificationSuccess, {
|
||||||
modelId,
|
modelId,
|
||||||
downloadType: 'Model'
|
downloadType: 'Model',
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error downloading model:', modelId, opts, error)
|
logger.error('Error downloading model:', modelId, opts, error)
|
||||||
@ -1092,7 +1092,8 @@ export default class llamacpp_extension extends AIEngine {
|
|||||||
error instanceof Error ? error.message : String(error)
|
error instanceof Error ? error.message : String(error)
|
||||||
|
|
||||||
// Check if this is a cancellation
|
// Check if this is a cancellation
|
||||||
const isCancellationError = errorMessage.includes('Download cancelled') ||
|
const isCancellationError =
|
||||||
|
errorMessage.includes('Download cancelled') ||
|
||||||
errorMessage.includes('Validation cancelled') ||
|
errorMessage.includes('Validation cancelled') ||
|
||||||
errorMessage.includes('Hash computation cancelled') ||
|
errorMessage.includes('Hash computation cancelled') ||
|
||||||
errorMessage.includes('cancelled') ||
|
errorMessage.includes('cancelled') ||
|
||||||
@ -1372,7 +1373,7 @@ export default class llamacpp_extension extends AIEngine {
|
|||||||
envs['LLAMA_API_KEY'] = api_key
|
envs['LLAMA_API_KEY'] = api_key
|
||||||
|
|
||||||
// set user envs
|
// set user envs
|
||||||
this.parseEnvFromString(envs, this.llamacpp_env)
|
if (this.llamacpp_env) this.parseEnvFromString(envs, this.llamacpp_env)
|
||||||
|
|
||||||
// model option is required
|
// model option is required
|
||||||
// NOTE: model_path and mmproj_path can be either relative to Jan's data folder or absolute path
|
// NOTE: model_path and mmproj_path can be either relative to Jan's data folder or absolute path
|
||||||
@ -1751,7 +1752,7 @@ export default class llamacpp_extension extends AIEngine {
|
|||||||
}
|
}
|
||||||
// set envs
|
// set envs
|
||||||
const envs: Record<string, string> = {}
|
const envs: Record<string, string> = {}
|
||||||
this.parseEnvFromString(envs, this.llamacpp_env)
|
if (this.llamacpp_env) this.parseEnvFromString(envs, this.llamacpp_env)
|
||||||
|
|
||||||
// Ensure backend is downloaded and ready before proceeding
|
// Ensure backend is downloaded and ready before proceeding
|
||||||
await this.ensureBackendReady(backend, version)
|
await this.ensureBackendReady(backend, version)
|
||||||
@ -1767,7 +1768,7 @@ export default class llamacpp_extension extends AIEngine {
|
|||||||
return dList
|
return dList
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Failed to query devices:\n', error)
|
logger.error('Failed to query devices:\n', error)
|
||||||
throw new Error("Failed to load llamacpp backend")
|
throw new Error('Failed to load llamacpp backend')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1876,7 +1877,7 @@ export default class llamacpp_extension extends AIEngine {
|
|||||||
logger.info(
|
logger.info(
|
||||||
`Using explicit key_length: ${keyLen}, value_length: ${valLen}`
|
`Using explicit key_length: ${keyLen}, value_length: ${valLen}`
|
||||||
)
|
)
|
||||||
headDim = (keyLen + valLen)
|
headDim = keyLen + valLen
|
||||||
} else {
|
} else {
|
||||||
// Fall back to embedding_length estimation
|
// Fall back to embedding_length estimation
|
||||||
const embeddingLen = Number(meta[`${arch}.embedding_length`])
|
const embeddingLen = Number(meta[`${arch}.embedding_length`])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user