fix(setup,chat): pass dummy api_key for local providers
litellm requires the api_key field even for local OpenAI-compatible servers (LM Studio, llama.cpp). Use "local" as a sentinel value for providers that don't require a real key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -102,17 +102,17 @@ def _call_ai(cfg: PyraConfig, history: ConversationHistory) -> str:
|
||||
from pyra.vault.reader import get_key
|
||||
|
||||
provider = get_provider(cfg.ai.provider_id)
|
||||
api_key = get_key(cfg.ai.provider_id) if provider.requires_key else None
|
||||
# Local providers don't need a real key but litellm requires the field
|
||||
api_key = get_key(cfg.ai.provider_id) if provider.requires_key else "local"
|
||||
|
||||
kwargs: dict = {
|
||||
"model": f"{provider.litellm_prefix}{cfg.ai.model}",
|
||||
"messages": history.build_for_api(),
|
||||
"stream": True,
|
||||
"api_key": api_key,
|
||||
}
|
||||
if cfg.ai.base_url:
|
||||
kwargs["api_base"] = cfg.ai.base_url
|
||||
if api_key:
|
||||
kwargs["api_key"] = api_key
|
||||
|
||||
litellm.suppress_debug_info = True
|
||||
stream = litellm.completion(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user