fix(cli): write embedding base url in --setup
This commit is contained in:
parent
2f7658577e
commit
c53728a855
|
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- `--setup` for openai-compatible writes `EMBEDDING_MODEL_CONFIG__OVERRIDES__BASE_URL` into the profile `.env` alongside `LLM_OPENAI_BASE_URL`
|
||||
|
||||
## [0.1.3] - 2026-08-25
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -14,11 +14,7 @@ from pathlib import Path
|
|||
import typer
|
||||
from rich.console import Console
|
||||
|
||||
from honcho_cli.local.env import (
|
||||
is_placeholder_key,
|
||||
read_env_file,
|
||||
settings_from_environ,
|
||||
)
|
||||
from honcho_cli.local.env import is_placeholder_key, read_env_file, settings_from_environ
|
||||
from honcho_cli.output import print_error
|
||||
|
||||
SETUP_MODES = ("basic", "advanced")
|
||||
|
|
@ -145,6 +141,10 @@ def answers_to_env(answers: SetupAnswers) -> dict[str, str]:
|
|||
env[_PROVIDER_KEY_ENV[answers.provider]] = answers.api_key
|
||||
if answers.base_url:
|
||||
env["LLM_OPENAI_BASE_URL"] = answers.base_url
|
||||
# Embeddings do not inherit this URL; write it so OpenRouter/vLLM
|
||||
# keys are not sent to api.openai.com.
|
||||
if (answers.embedding_transport or "openai") == "openai":
|
||||
env["EMBEDDING_MODEL_CONFIG__OVERRIDES__BASE_URL"] = answers.base_url
|
||||
|
||||
if answers.embedding_api_key and answers.embedding_key_transport:
|
||||
embed_key = (
|
||||
|
|
@ -188,9 +188,13 @@ def answers_to_env(answers: SetupAnswers) -> dict[str, str]:
|
|||
|
||||
def answers_drop_keys(answers: SetupAnswers) -> tuple[str, ...]:
|
||||
"""Keys to remove so a previous wizard run cannot leak into this one."""
|
||||
if answers.provider == "openai-compatible":
|
||||
return ()
|
||||
return ("LLM_OPENAI_BASE_URL",)
|
||||
drop: list[str] = []
|
||||
if answers.provider != "openai-compatible":
|
||||
drop.append("LLM_OPENAI_BASE_URL")
|
||||
embed_openai = (answers.embedding_transport or "openai") == "openai"
|
||||
if answers.provider != "openai-compatible" or not embed_openai:
|
||||
drop.append("EMBEDDING_MODEL_CONFIG__OVERRIDES__BASE_URL")
|
||||
return tuple(drop)
|
||||
|
||||
|
||||
def run_setup(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from __future__ import annotations
|
|||
from honcho_cli.local.setup import (
|
||||
DIALECTIC_LEVELS,
|
||||
SetupAnswers,
|
||||
answers_drop_keys,
|
||||
answers_to_env,
|
||||
chat_model_default,
|
||||
load_toml_setup_defaults,
|
||||
|
|
@ -46,6 +47,33 @@ def test_basic_anthropic_keeps_openai_embeddings_default():
|
|||
assert "EMBEDDING_MODEL_CONFIG__TRANSPORT" not in env
|
||||
|
||||
|
||||
def test_openai_compatible_copies_base_url_to_embeddings():
|
||||
env = answers_to_env(
|
||||
SetupAnswers(
|
||||
mode="basic",
|
||||
provider="openai-compatible",
|
||||
api_key="sk-or-test",
|
||||
chat_model="gpt-test",
|
||||
base_url="https://openrouter.ai/api/v1",
|
||||
)
|
||||
)
|
||||
assert env["LLM_OPENAI_BASE_URL"] == "https://openrouter.ai/api/v1"
|
||||
assert (
|
||||
env["EMBEDDING_MODEL_CONFIG__OVERRIDES__BASE_URL"]
|
||||
== "https://openrouter.ai/api/v1"
|
||||
)
|
||||
|
||||
|
||||
def test_leaving_openai_compatible_drops_proxy_urls():
|
||||
dropped = answers_drop_keys(
|
||||
SetupAnswers(
|
||||
mode="basic", provider="openai", api_key="sk", chat_model="gpt-test"
|
||||
)
|
||||
)
|
||||
assert "LLM_OPENAI_BASE_URL" in dropped
|
||||
assert "EMBEDDING_MODEL_CONFIG__OVERRIDES__BASE_URL" in dropped
|
||||
|
||||
|
||||
def test_chat_default_comes_from_image_toml(tmp_path):
|
||||
path = tmp_path / "config.toml"
|
||||
path.write_text(
|
||||
|
|
|
|||
Loading…
Reference in New Issue