Use direct OpenAI defaults for matchmaking
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""LLM clients — ONE place to build them.
|
||||
|
||||
Two backends, by capability:
|
||||
- **Gateway** (OpenAI-compatible, e.g. opencode/OpenRouter) → chat for the curator.
|
||||
- **Gateway** → chat for the curator, using DSPY_* when configured or direct OpenAI otherwise.
|
||||
- **Embeddings** → direct OpenAI or an OpenAI-compatible embeddings API via OPENAI_API_BASE.
|
||||
|
||||
Both keys come from config/.env (git-ignored). Each builder returns `None` when unconfigured so the
|
||||
@@ -16,12 +16,16 @@ from app.config import get_settings
|
||||
|
||||
@lru_cache
|
||||
def gateway_client():
|
||||
"""OpenAI-compatible client for the opencode.ai/zen gateway — chat (Opus). None if unconfigured."""
|
||||
"""Chat client for curation/suggestions. Prefer DSPY_* override, otherwise use OPENAI_API_KEY."""
|
||||
s = get_settings()
|
||||
if not (s.DSPY_API_BASE and s.DSPY_API_KEY):
|
||||
api_key = s.DSPY_API_KEY or s.OPENAI_API_KEY
|
||||
if not api_key:
|
||||
return None
|
||||
from openai import OpenAI
|
||||
return OpenAI(base_url=s.DSPY_API_BASE, api_key=s.DSPY_API_KEY, timeout=60, max_retries=2)
|
||||
kwargs = {"api_key": api_key, "timeout": 60, "max_retries": 2}
|
||||
if s.DSPY_API_BASE:
|
||||
kwargs["base_url"] = s.DSPY_API_BASE
|
||||
return OpenAI(**kwargs)
|
||||
|
||||
|
||||
@lru_cache
|
||||
@@ -38,6 +42,6 @@ def embed_client():
|
||||
|
||||
|
||||
def curate_enabled() -> bool:
|
||||
"""Is the Opus curator usable? (flag on + gateway key present)."""
|
||||
"""Is the curator usable? (flag on + any chat key present)."""
|
||||
s = get_settings()
|
||||
return bool(s.ENGINE_LLM_ENABLED and s.DSPY_API_BASE and s.DSPY_API_KEY)
|
||||
return bool(s.ENGINE_LLM_ENABLED and (s.DSPY_API_KEY or s.OPENAI_API_KEY))
|
||||
|
||||
Reference in New Issue
Block a user