aboutsummaryrefslogtreecommitdiffstats
path: root/test_llamachat.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_llamachat.py')
-rwxr-xr-xtest_llamachat.py42
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()