diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-09 14:59:37 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-09 14:59:37 +0200 |
| commit | 05184385699325efa830a18c4b05380df79bc12c (patch) | |
| tree | 60e7691aeba085d58f303449bd5b8d9c7b008a65 /test_llamachat.py | |
| parent | 37e2b3d9da2297e18431b4dd9e21170aff673b3e (diff) | |
| download | llamachat-05184385699325efa830a18c4b05380df79bc12c.tar.gz llamachat-05184385699325efa830a18c4b05380df79bc12c.zip | |
feat: expose the provider table from config
base_url stays populated so existing callers are untouched; the provider
table is built alongside it. models.ini sits beside config.toml and
state.ini, following the same pattern as the window layout.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'test_llamachat.py')
| -rwxr-xr-x | test_llamachat.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test_llamachat.py b/test_llamachat.py index b943976..0eea9e1 100755 --- a/test_llamachat.py +++ b/test_llamachat.py @@ -1207,6 +1207,47 @@ def test_key_resolution(): print("ok api key resolution") +def test_config_providers(): + """config.load exposes the provider table and the models.ini path.""" + with tempfile.TemporaryDirectory() as tmp: + path = Path(tmp) / "config.toml" + + # A legacy config: bare base_url only. + path.write_text('base_url = "http://localhost:9999"\n') + cfg = config.load(path) + assert set(cfg.providers) == {"local"} + assert cfg.providers["local"].base_url == "http://localhost:9999" + # base_url stays populated: existing code still reads it. + assert cfg.base_url == "http://localhost:9999" + assert cfg.models_path == path.parent / "models.ini" + + # A config with an explicit cloud provider. + path.write_text( + 'base_url = "http://localhost:9999"\n' + "\n" + "[providers.together]\n" + 'base_url = "https://api.example.org"\n' + 'api_key = "pass:api/together"\n' + 'filter = ["qwen"]\n' + "ctx_size = 32768\n" + "price_in = 0.6\n" + "price_out = 0.9\n" + ) + cfg = config.load(path) + assert set(cfg.providers) == {"local", "together"} + assert cfg.providers["together"].api_key == "pass:api/together" + assert cfg.providers["together"].filter == ["qwen"] + assert cfg.providers["together"].price_out == 0.9 + + # A config with no base_url and no providers still loads, with the + # built-in default synthesizing local. + path.write_text("request_timeout = 60\n") + cfg = config.load(path) + assert set(cfg.providers) == {"local"} + assert cfg.providers["local"].base_url == config.DEFAULTS["base_url"] + print("ok config provider table") + + class _FakeResponse: """Enough of an http.client response for urlopen's context manager.""" @@ -1947,6 +1988,7 @@ if __name__ == "__main__": test_provider_parsing() test_model_ids_and_filtering() test_key_resolution() + test_config_providers() test_search_tool_schema() test_search_results_sanitising() test_tool_call_accumulation() |
