Add OpenAI-compatible agent profile - #7
Conversation
|
Thanks — direction is great, two scoping nits before merge: 1. Rename to follow the provider-prefix convention. Existing env vars are
Bonus: every OpenAI-compatible tool (Ollama, LM Studio, copilot-api, vLLM) already calls them this, so it's instantly recognisable. 2. Scope the base_url env override to the new profile only. Today no profile lets you override Concretely: @property
def resolved_base_url(self) -> str | None:
if self.llm_profile == "openai_compatible":
return self.openai_base_url or None
return _LLM_PROFILES[self.llm_profile].get("base_url")That keeps every existing profile's resolution path untouched, gives the new profile the env-driven flexibility it needs, and the 2-line With those two changes I'd merge happily — the rest of the PR is good (regression coverage for existing profiles is a particularly nice touch). |
Point the internal agent at any OpenAI-compatible /v1 endpoint (Ollama, LM Studio, copilot-api, a remote vLLM) without a new provider abstraction: set LLM_PROFILE=openai_compatible, AGENT_MODEL=openai/<model-id>, and OPENAI_BASE_URL (OPENAI_API_KEY only if the endpoint needs auth). - new profile reuses the existing model-prefix + api_key_env mechanism - the env-driven base_url is scoped to this profile ONLY; resolved_base_url special-cases it so no other profile (deepinfra/nim/vllm_*) can be silently re-pointed - provider-prefix env names (OPENAI_*) to match DEEPINFRA_API_KEY etc. - unit coverage incl. a regression that OPENAI_BASE_URL does not leak into other profiles; docker-compose env passthrough, .env.example, README, CONTRIBUTING, CHANGELOG Reworked from @WarGloom's proposal in dimknaf#7 (thanks for the nudge), adjusted to the provider-prefix convention and a profile-scoped override per review.
This is the focused follow-up from the closed local-agent setup PR. It only adds the generic
openai_compatibleprofile path, so BrainDB can point the internal agent at OpenAI-compatible/v1endpoints without adding another provider abstraction.What changed:
openai_compatibleto_LLM_PROFILESand letAGENT_BASE_URLoverride the profile base URLAGENT_BASE_URLandAGENT_API_KEYinto the API containerWhat this does not include:
local_ollamaaliasOPENAI_API_KEYpassthroughValidation:
python -m pytest tests/test_config_profiles.py -q-> 7 passeddocker compose configpython -m py_compile braindb/config.py tests/conftest.py tests/test_config_profiles.pyLLM_PROFILE=openai_compatible,AGENT_MODEL=openai/llama3.2:3b,AGENT_BASE_URL=http://localhost:11434/v1I could not run the full suite in this shell because the local Python environment is missing
agentsandpsycopg2; the targeted config tests above do not depend on those packages.