mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-24 21:41:04 +02:00
fix: drop construction-time LLM provider validation
It only checked model (never retrieve_model), relied on a hand-kept keyless-provider allowlist that goes stale, and rejected valid setups like litellm proxies. A missing key now surfaces at the first LLM call with litellm's own clear error — the original pre-SDK behavior.
This commit is contained in:
parent
a84d88b4ce
commit
80bdfc152d
1 changed files with 0 additions and 39 deletions
|
|
@ -99,8 +99,6 @@ class PageIndexClient:
|
|||
else:
|
||||
opt = IndexConfig(**overrides) if overrides else IndexConfig()
|
||||
|
||||
self._validate_llm_provider(opt.model)
|
||||
|
||||
self.model = opt.model
|
||||
self.retrieve_model = _normalize_retrieve_model(opt.retrieve_model or self.model)
|
||||
|
||||
|
|
@ -118,43 +116,6 @@ class PageIndexClient:
|
|||
index_config=opt,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _validate_llm_provider(model: str) -> None:
|
||||
"""Validate the model string and require an API key for providers that
|
||||
need one. Local / keyless providers (ollama, lm_studio, …) are skipped so
|
||||
a keyless LiteLLM model isn't rejected at construction time."""
|
||||
try:
|
||||
import litellm
|
||||
_, provider, _, _ = litellm.get_llm_provider(model=model)
|
||||
except Exception:
|
||||
return
|
||||
|
||||
# LiteLLM providers that run locally / self-hosted and need no API key
|
||||
# by default (litellm itself falls back to a placeholder key for these
|
||||
# rather than erroring — see e.g. hosted_vllm's transformation.py).
|
||||
# This list is necessarily a manual allowlist (litellm.validate_environment
|
||||
# isn't reliable enough to derive it from); extend it as litellm adds
|
||||
# more local-inference providers.
|
||||
keyless = {
|
||||
"ollama", "ollama_chat", "lm_studio", "hosted_vllm", "vllm",
|
||||
"xinference", "llamafile", "triton", "oobabooga",
|
||||
"openai_like", "custom_openai", "custom", "docker_model_runner",
|
||||
"petals",
|
||||
}
|
||||
if provider in keyless:
|
||||
return
|
||||
|
||||
key = litellm.get_api_key(llm_provider=provider, dynamic_api_key=None)
|
||||
if not key:
|
||||
import os
|
||||
common_var = f"{provider.upper()}_API_KEY"
|
||||
if not os.getenv(common_var):
|
||||
from .errors import PageIndexError
|
||||
raise PageIndexError(
|
||||
f"API key not configured for provider '{provider}' (model: {model}). "
|
||||
f"Set the {common_var} environment variable."
|
||||
)
|
||||
|
||||
def collection(self, name: str = "default") -> Collection:
|
||||
"""Get or create a collection. Defaults to 'default'."""
|
||||
self._backend.get_or_create_collection(name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue