Problem
Version
2.3.5
Problem
When CRG_OPENAI_API_KEY, CRG_OPENAI_BASE_URL, and CRG_OPENAI_MODEL are configured (e.g. for a local Ollama instance), calling semantic_search_nodes without an explicit provider argument always falls back to keyword-only search instead of using the configured OpenAI-compatible backend.
The root cause is in get_provider() (embeddings.py): when provider=None, the function immediately falls through to the # Default: local branch without checking whether OpenAI env vars are present:
# Default: local
if not _check_available():
return None
return LocalEmbeddingProvider(model_name=model)
This means embeddings built with --provider openai are effectively unreachable unless every caller explicitly passes provider="openai" ? including all MCP tool invocations from AI assistants, which typically omit optional parameters.
Expected behavior
If CRG_OPENAI_API_KEY and CRG_OPENAI_BASE_URL are set, get_provider(provider=None) should default to the OpenAI-compatible provider rather than local.
Proposed solution
Suggested fix
def get_provider(
provider: str | None = None,
model: str | None = None,
) -> EmbeddingProvider | None:
if provider is None and os.environ.get("CRG_OPENAI_API_KEY") and os.environ.get("CRG_OPENAI_BASE_URL"):
provider = "openai"
if provider == "openai":
...
This makes the provider selection consistent with how the OpenAI env vars are already used elsewhere in the codebase ? no new env vars needed.
Affected area
None
Alternatives considered
No response
Additional context
No response
Problem
Version
2.3.5
Problem
When
CRG_OPENAI_API_KEY,CRG_OPENAI_BASE_URL, andCRG_OPENAI_MODELare configured (e.g. for a local Ollama instance), callingsemantic_search_nodeswithout an explicitproviderargument always falls back to keyword-only search instead of using the configured OpenAI-compatible backend.The root cause is in
get_provider()(embeddings.py): whenprovider=None, the function immediately falls through to the# Default: localbranch without checking whether OpenAI env vars are present:This means embeddings built with
--provider openaiare effectively unreachable unless every caller explicitly passesprovider="openai"? including all MCP tool invocations from AI assistants, which typically omit optional parameters.Expected behavior
If
CRG_OPENAI_API_KEYandCRG_OPENAI_BASE_URLare set,get_provider(provider=None)should default to the OpenAI-compatible provider rather than local.Proposed solution
Suggested fix
This makes the provider selection consistent with how the OpenAI env vars are already used elsewhere in the codebase ? no new env vars needed.
Affected area
None
Alternatives considered
No response
Additional context
No response