Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions elroy/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from toolz.curried import map, valfilter

from ..config.llm import DEFAULTS_CONFIG
from ..config.paths import get_default_sqlite_url
from ..config.paths import get_default_config_path, get_default_sqlite_url
from ..core.constants import CLAUDE_3_5_SONNET

logger = get_logger()
Expand Down Expand Up @@ -42,10 +42,7 @@ def resolve_model_alias(alias: str) -> str | None:
def load_config_file_params(config_path: str | None = None) -> dict:
# Looks for user specified config path, then merges with default values packaged with the lib

user_config_path = config_path or os.environ.get(get_env_var_name("config_path"))

if not user_config_path:
return {}
user_config_path = config_path or os.environ.get(get_env_var_name("config_path")) or str(get_default_config_path())
if user_config_path and not Path(user_config_path).is_absolute():
logger.info("Resolving relative user config path")
# convert to absolute path if not already, relative to working dir
Expand Down
18 changes: 18 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from rich.table import Table

from elroy.core.ctx import ElroyConfig
from elroy.tools.developer import print_config
from tests.utils import process_test_message

Expand All @@ -14,3 +15,20 @@ def test_print_config(ctx):
def test_custom_config(ctx):
ctx.config_path = Path(__file__).parent / "fixtures" / "test_config.yml"
process_test_message(ctx, "hello world")


def test_default_config_path_is_loaded(monkeypatch, tmp_path):
home_dir = tmp_path / "elroy-home"
config_path = home_dir / "elroy.conf.yaml"
config_path.parent.mkdir(parents=True, exist_ok=True)
config_path.write_text("chat_model: gpt-5.4\n", encoding="utf-8")

monkeypatch.setenv("ELROY_HOME", str(home_dir))
monkeypatch.delenv("ELROY_CONFIG_PATH", raising=False)
monkeypatch.delenv("OPENAI_API_KEY", raising=False)
monkeypatch.delenv("ANTHROPIC_API_KEY", raising=False)
monkeypatch.delenv("GEMINI_API_KEY", raising=False)

ctx = ElroyConfig.init()

assert ctx.model_config.chat_model == "gpt-5.4"