fix: restore OLLAMA_HOST env var support

This commit is contained in:
majiayu000
2026-01-13 23:16:29 +08:00
parent 02a9da5591
commit 234450bb0c
+8 -1
View File
@@ -39,7 +39,14 @@ class LMMAgent:
elif engine_type == "ollama":
# Reuse LMMEngineOpenAI for Ollama, defaulting to localhost if not specified
if "base_url" not in engine_params:
engine_params["base_url"] = "http://localhost:11434/v1"
import os
base_url = os.getenv("OLLAMA_HOST")
if base_url:
if not base_url.endswith("/v1"):
base_url = base_url.rstrip("/") + "/v1"
engine_params["base_url"] = base_url
else:
engine_params["base_url"] = "http://localhost:11434/v1"
if "api_key" not in engine_params:
engine_params["api_key"] = "ollama"
self.engine = LMMEngineOpenAI(**engine_params)