in src/databao_context_engine/llm/install.py [0:0]
def resolve_ollama_bin() -> str:
"""
Decide which `ollama` binary to use, in this order:
1. DCE_OLLAMA_BIN env var, if set and exists
2. `ollama` found on PATH
3. Managed installation under MANAGED_OLLAMA_BIN
Returns the full path to the binary
"""
override = os.environ.get("DCE_OLLAMA_BIN")
if override:
p = Path(override).expanduser()
if p.is_file() and os.access(p, os.X_OK):
return str(p)
system_ollama = shutil.which("ollama")
if system_ollama:
return system_ollama
if not MANAGED_OLLAMA_BIN.exists():
logger.info("No existing Ollama installation detected. We will download and install Ollama.")
install_ollama_to(MANAGED_OLLAMA_BIN)
return str(MANAGED_OLLAMA_BIN)