Conversation
…viders
The router already routed provider "custom" / "ollama" / "vllm" to
ChatOpenAI with a configurable api_base (router.py:369), but the
surrounding plumbing had two gaps:
1. LLM.validate_provider had no branch for those providers, so a
node configured with `provider: "custom"` could fail later in
runtime with a less actionable error.
2. Settings.get_api_key / set_api_key did not handle custom /
ollama / vllm, leaving the admin UI without a way to set the key
and leaving the env normalization loop without a slot for a
dedicated CUSTOM_LLM_API_KEY.
This change:
* Adds LLM.validate_provider branches for custom / ollama / vllm.
Custom endpoints require both a base URL (any of OPENAI_BASE_URL,
CUSTOM_LLM_BASE_URL, or per-node api_base) and an API key. Local
Ollama / vLLM servers tolerate a missing API key.
* Adds CUSTOM_LLM_API_KEY / CUSTOM_LLM_BASE_URL / CUSTOM_LLM_MODEL
fields on Settings, with backwards-compatible fallback to
OPENAI_API_KEY / OPENAI_BASE_URL when unset.
* Wires get_api_key and set_api_key for the new providers and
registers CUSTOM_LLM_API_KEY in the placeholder-filter loop.
* Adds ENV_CUSTOM_LLM_* constants for env-driven provisioning.
* Documents the new env vars and provider configuration in
.env.example with MiniMax, Ollama, and vLLM recipes.
* Adds tests/unit/test_custom_llm_providers.py covering all eight
paths: missing base URL, missing API key (custom only), fallback
to OPENAI_API_KEY, dedicated CUSTOM_LLM_* env vars, ollama/vllm
tolerance for missing key, and Settings round-trips.
The .env file remains gitignored (root .gitignore:105).
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Artemis already routed
provider: "custom"/"ollama"/"vllm"toChatOpenAIwith a configurableapi_base, but the surrounding plumbing had two gaps:LLM.validate_providerhad no branch for those providers, so a node configured withprovider: "custom"could fail later at runtime with a less actionable error.Settings.get_api_key/set_api_keydid not handlecustom/ollama/vllm, leaving the admin UI without a way to set the key and the env normalization loop without a slot for a dedicatedCUSTOM_LLM_API_KEY.This PR closes both gaps and makes the configuration discoverable in
.env.example.Why
OPENAI_BASE_URL; this adds dedicated env vars while keeping the existing path working.Changes
artemis/config/llm.py—validate_providernow branches oncustom/ollama/vllm. Custom requires a base URL (any ofOPENAI_BASE_URL,CUSTOM_LLM_BASE_URL, or per-nodeapi_base) and an API key. Localollama/vllmtolerate a missing API key.artemis/config/settings.py— addsCUSTOM_LLM_API_KEY/CUSTOM_LLM_BASE_URL/CUSTOM_LLM_MODELwith backwards-compatible fallback toOPENAI_API_KEY/OPENAI_BASE_URL.get_api_keyandset_api_keynow route the new providers through the dedicated fields.CUSTOM_LLM_API_KEYjoins the placeholder-filter loop.artemis/config/constants.py— addsENV_CUSTOM_LLM_API_KEY/ENV_CUSTOM_LLM_BASE_URL/ENV_CUSTOM_LLM_MODEL..env.example— adds a Custom / Local OpenAI-Compatible Providers section with MiniMax, Ollama, and vLLM recipes.tests/unit/test_custom_llm_providers.py— 8 new tests covering: missing base URL, missing API key (custom only), fallback toOPENAI_API_KEY, dedicatedCUSTOM_LLM_*env vars, ollama/vllm tolerance for missing key, and Settings round-trips.Verification
Existing
test_config_package.pyfailures (7) are pre-existing inmain(verified withgit stash); they assumeGOOGLE_API_KEYis set in the test environment. This PR does not introduce or fix them.End-to-end smoke test against a hosted OpenAI-compatible endpoint (MiniMax,
https://api.minimax.io/v1) usingCUSTOM_LLM_*env vars returned a validchat.completionsresponse with modelMiniMax-M3.Backwards compatibility
provider: "openai"andOPENAI_BASE_URLcontinue to work unchanged.provider: "custom"/"ollama"/"vllm"previously failed silently at runtime; the new validator now fails fast at config load with an actionable message..envstays gitignored (root.gitignore:105).Out of scope
Authorization: Bearer(some providers needx-api-key, etc.) — happy to follow up if needed.