When the installer is run a second time to add an additional model, the .env
update path checks only whether LLM_PROVIDER=ollama is already set:
if ($existing -match 'LLM_PROVIDER=ollama') {
Write-Host " AnythingLLM already configured for Ollama." -ForegroundColor Green
}
If the condition is true, the file is left untouched. This means
OLLAMA_MODEL_PREF retains the value from the first install run and is never
updated to reflect the newly added model.
A user who installs model 5 (Llama 3.2 3B) first, then re-runs the installer
to add model 1 (NemoMix 12B), will find AnythingLLM still pointing to
llama3-local with no indication that the configuration was not updated.
Steps to reproduce
- Run
install.bat, select model 5 (Llama 3.2 3B)
- Confirm
anythingllm_data/storage/.env contains OLLAMA_MODEL_PREF=llama3-local
- Re-run
install.bat, select model 1 (NemoMix 12B)
- Check
.env — OLLAMA_MODEL_PREF still reads llama3-local
Expected behaviour
The installer should update OLLAMA_MODEL_PREF to the first model in the
current selection, or prompt the user to choose which installed model
AnythingLLM should default to.
Proposed fix
When .env already exists with LLM_PROVIDER=ollama, use a targeted
find-and-replace on the OLLAMA_MODEL_PREF line rather than skipping the
file entirely:
(Get-Content $envFilePath) -replace 'OLLAMA_MODEL_PREF=.*', "OLLAMA_MODEL_PREF=$firstModelLocal" |
Set-Content $envFilePath -Encoding UTF8
When the installer is run a second time to add an additional model, the
.envupdate path checks only whether
LLM_PROVIDER=ollamais already set:If the condition is true, the file is left untouched. This means
OLLAMA_MODEL_PREFretains the value from the first install run and is neverupdated to reflect the newly added model.
A user who installs model 5 (Llama 3.2 3B) first, then re-runs the installer
to add model 1 (NemoMix 12B), will find AnythingLLM still pointing to
llama3-localwith no indication that the configuration was not updated.Steps to reproduce
install.bat, select model 5 (Llama 3.2 3B)anythingllm_data/storage/.envcontainsOLLAMA_MODEL_PREF=llama3-localinstall.bat, select model 1 (NemoMix 12B).env—OLLAMA_MODEL_PREFstill readsllama3-localExpected behaviour
The installer should update
OLLAMA_MODEL_PREFto the first model in thecurrent selection, or prompt the user to choose which installed model
AnythingLLM should default to.
Proposed fix
When
.envalready exists withLLM_PROVIDER=ollama, use a targetedfind-and-replace on the
OLLAMA_MODEL_PREFline rather than skipping thefile entirely: