Skip to content

Add OpenAI-compatible agent profile#7

Open
WarGloom wants to merge 3 commits into
dimknaf:mainfrom
WarGloom:feat/openai-compatible-profile
Open

Add OpenAI-compatible agent profile#7
WarGloom wants to merge 3 commits into
dimknaf:mainfrom
WarGloom:feat/openai-compatible-profile

Conversation

@WarGloom
Copy link
Copy Markdown
Contributor

This is the focused follow-up from the closed local-agent setup PR. It only adds the generic openai_compatible profile path, so BrainDB can point the internal agent at OpenAI-compatible /v1 endpoints without adding another provider abstraction.

What changed:

  • add openai_compatible to _LLM_PROFILES and let AGENT_BASE_URL override the profile base URL
  • pass AGENT_BASE_URL and AGENT_API_KEY into the API container
  • document the env vars with an Ollama-style example using the generic profile name
  • add unit coverage for the new profile and existing profile regressions

What this does not include:

  • no local_ollama alias
  • no Codex profile or OPENAI_API_KEY passthrough
  • no fast-path save routing
  • no bundled Postgres, manage script, or GPU compose changes

Validation:

  • python -m pytest tests/test_config_profiles.py -q -> 7 passed
  • docker compose config
  • python -m py_compile braindb/config.py tests/conftest.py tests/test_config_profiles.py
  • manual Settings smoke with LLM_PROFILE=openai_compatible, AGENT_MODEL=openai/llama3.2:3b, AGENT_BASE_URL=http://localhost:11434/v1

I could not run the full suite in this shell because the local Python environment is missing agents and psycopg2; the targeted config tests above do not depend on those packages.

@dimknaf
Copy link
Copy Markdown
Owner

dimknaf commented May 31, 2026

Thanks — direction is great, two scoping nits before merge:

1. Rename to follow the provider-prefix convention.

Existing env vars are DEEPINFRA_API_KEY, NVIDIA_NIM_API_KEY, VLLM_API_KEY — provider-name prefix. AGENT_* reads as "auth for calling BrainDB's agent endpoint", which these aren't. They're the LLM provider's credentials. Suggest:

  • AGENT_API_KEYOPENAI_API_KEY
  • AGENT_BASE_URLOPENAI_BASE_URL

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 base_url via env — they're all hardcoded in _LLM_PROFILES. The current diff makes AGENT_BASE_URL a global override that would silently re-point vllm_workstation, nim, etc. too. No existing profile needs that capability — only openai_compatible does.

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 docker-compose.yml addition (OPENAI_API_KEY + OPENAI_BASE_URL env passthroughs) is fine because it follows the existing explicit-allowlist pattern.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants