fix(llm): fall back to OLLAMA_HOST when OLLAMA_BASE_URL is unset#2019
Open
kimdzhekhon wants to merge 1 commit into
Open
fix(llm): fall back to OLLAMA_HOST when OLLAMA_BASE_URL is unset#2019kimdzhekhon wants to merge 1 commit into
kimdzhekhon wants to merge 1 commit into
Conversation
Ollama's own server has no OLLAMA_BASE_URL concept — it reads OLLAMA_HOST (https://docs.ollama.com/faq#how-do-i-configure-ollama-server). graphify only ever read OLLAMA_BASE_URL, so anyone who configured Ollama the way its own docs describe (OLLAMA_HOST) had graphify silently ignore it and fall back to the localhost:11434 default. Add _resolve_ollama_base_url(default): OLLAMA_BASE_URL still wins when set (unchanged behavior, graphify's existing convention for OpenAI- compatible base_url overrides across backends). Otherwise falls back to OLLAMA_HOST, normalized into an OpenAI-compatible URL (adds a scheme if missing, ensures a trailing /v1). Wired into the BACKENDS dict's ollama entry and the two ollama_url call sites that read the env var directly. Fixes Graphify-Labs#1940.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OLLAMA_BASE_URLconcept — its documented config var isOLLAMA_HOST(Ollama FAQ). graphify only ever readOLLAMA_BASE_URL, so a user who configured Ollama the way its own docs describe got silently routed to thelocalhost:11434default instead._resolve_ollama_base_url(default):OLLAMA_BASE_URLstill wins when set (unchanged behavior — this mirrors graphify's existing per-backend*_BASE_URLoverride convention, e.g.KIMI_BASE_URL,GEMINI_BASE_URL, left untouched). Otherwise falls back toOLLAMA_HOST, normalized into an OpenAI-compatible URL: addshttp://if no scheme is present, ensures a trailing/v1(no duplication if already present).BACKENDS["ollama"]["base_url"]dict-literal default and the twoollama_url = os.environ.get("OLLAMA_BASE_URL", ...)call sites.Fixes #1940.
Test plan
tests/test_llm_backends.py:OLLAMA_BASE_URLtakes priority overOLLAMA_HOST; scheme-lessOLLAMA_HOSTgetshttp://+/v1; an already-normalizedOLLAMA_HOST(scheme +/v1) passes through unchanged; neither set → falls back to caller's defaultuv run pytest tests/test_llm_backends.py -q -k ollama— 13 passeduv run pytest tests/ -q— full suite: 3415 passed (5 pre-existing failures unrelated to this change, missing optionalopenaidependency in this environment)