aboutsummaryrefslogtreecommitdiffstats
path: root/test_llamachat.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_llamachat.py')
-rwxr-xr-xtest_llamachat.py47
1 files changed, 44 insertions, 3 deletions
diff --git a/test_llamachat.py b/test_llamachat.py
index 44f569e..faa0a00 100755
--- a/test_llamachat.py
+++ b/test_llamachat.py
@@ -1256,6 +1256,7 @@ def test_provider_parsing():
"price_out": 0.9,
"thinking_budget": 8192,
"replay_reasoning": True,
+ "audio": True,
},
}
}
@@ -1273,6 +1274,9 @@ def test_provider_parsing():
# Off by default: replaying reasoning costs context and input tokens.
assert parsed["local"].replay_reasoning is False
+ assert parsed["together"].audio is True
+ assert parsed["local"].audio is None
+
# An old config: bare base_url, no providers table at all.
legacy = providers.parse({"base_url": "http://localhost:8181"})
assert set(legacy) == {"local"}
@@ -1827,6 +1831,13 @@ def test_models_store():
assert models.ModelStore(path).get("together:novision").vision is False
assert "vision = false" in path.read_text(encoding="utf-8")
+ # Audio is the same tri-state and must survive the same round trip.
+ again.save("together:hear", models.ModelInfo(audio=True))
+ assert models.ModelStore(path).get("together:hear").audio is True
+ assert "audio = true" in path.read_text(encoding="utf-8")
+ assert models.ModelInfo(audio=True).is_empty() is False
+ assert models.ModelInfo(audio=False).is_empty() is False
+
# Cancelling a dialog over a model we already know must not erase it,
# nor mark it skipped: the marker means "no real keys", so a section
# holding both would be a state no reader is written to expect.
@@ -1887,6 +1898,23 @@ def test_models_store():
print("ok models.ini storage")
+def test_audio_metadata_layers():
+ """Audio resolves store over provider; router overlay is Task 4's job."""
+ from llamachat import models, providers
+
+ with tempfile.TemporaryDirectory() as tmp:
+ table = providers.parse(
+ {"providers": {"local": {"base_url": "http://x", "audio": True}}}
+ )
+ store = models.ModelStore(Path(tmp) / "models.ini")
+
+ assert models.resolve("m", table, store).audio is True
+ store.save("m", models.ModelInfo(audio=False))
+ # The store is more specific than the provider.
+ assert models.resolve("m", table, store).audio is False
+ print("ok audio metadata layers")
+
+
def test_metadata_and_cost():
"""models.ini beats provider defaults beats unknown; cost sums per model."""
from llamachat import models, providers
@@ -2583,11 +2611,23 @@ def test_model_dialog_values():
ctx_text="", vision=False, in_text="", out_text="", vision_prefill=False
).vision is False
+ # Audio is tri-state in the same way.
+ assert modeldialog.to_info(
+ ctx_text="", vision=False, in_text="", out_text="", audio=True
+ ).audio is True
+ assert modeldialog.to_info(
+ ctx_text="", vision=False, in_text="", out_text="", audio=False
+ ).audio is None
+ assert modeldialog.to_info(
+ ctx_text="", vision=False, in_text="", out_text="",
+ audio=False, audio_prefill=True,
+ ).audio is False
+
# Prefill is the inverse: unknown becomes an empty field.
- assert modeldialog.to_fields(models.ModelInfo()) == ("", False, "", "")
+ assert modeldialog.to_fields(models.ModelInfo()) == ("", False, "", "", False)
assert modeldialog.to_fields(
- models.ModelInfo(ctx_size=4096, vision=True, price_in=0.5)
- ) == ("4096", True, "0.5", "")
+ models.ModelInfo(ctx_size=4096, vision=True, price_in=0.5, audio=True)
+ ) == ("4096", True, "0.5", "", True)
print("ok model dialog value conversion")
@@ -3944,6 +3984,7 @@ if __name__ == "__main__":
test_config_providers()
test_replays_reasoning()
test_models_store()
+ test_audio_metadata_layers()
test_metadata_and_cost()
test_token_column_migration()
test_usage_columns()