feat: add llama-swap as a backend
This commit is contained in:
parent
c8da58430a
commit
aa8baebac5
17 changed files with 544 additions and 52 deletions
|
|
@ -277,3 +277,49 @@ class TestGetTrackingModel:
|
|||
with patch.object(router, "config", cfg):
|
||||
result = router.get_tracking_model(ep, "unsloth/model:Q8_0")
|
||||
assert result == "model"
|
||||
|
||||
|
||||
class TestLlamaSwapClassification:
|
||||
def _cfg(self, *, server=None, swap=None):
|
||||
cfg = MagicMock()
|
||||
cfg.endpoints = []
|
||||
cfg.llama_server_endpoints = server or []
|
||||
cfg.llama_swap_endpoints = swap or []
|
||||
return cfg
|
||||
|
||||
def test_is_llama_swap_only_for_swap_list(self):
|
||||
from backends.normalize import is_llama_swap
|
||||
swap_ep = "http://host:8890/v1"
|
||||
server_ep = "http://host:8889/v1"
|
||||
cfg = self._cfg(server=[server_ep], swap=[swap_ep])
|
||||
with patch.object(router, "config", cfg):
|
||||
assert is_llama_swap(swap_ep) is True
|
||||
assert is_llama_swap(server_ep) is False
|
||||
|
||||
def test_is_llama_server_covers_both(self):
|
||||
from backends.normalize import is_llama_server
|
||||
swap_ep = "http://host:8890/v1"
|
||||
server_ep = "http://host:8889/v1"
|
||||
cfg = self._cfg(server=[server_ep], swap=[swap_ep])
|
||||
with patch.object(router, "config", cfg):
|
||||
assert is_llama_server(swap_ep) is True
|
||||
assert is_llama_server(server_ep) is True
|
||||
assert is_llama_server("http://host:11434") is False
|
||||
|
||||
def test_swap_is_openai_compatible_not_ext(self):
|
||||
swap_ep = "http://host:8890/v1"
|
||||
cfg = self._cfg(swap=[swap_ep])
|
||||
with patch.object(router, "config", cfg):
|
||||
assert router.is_openai_compatible(swap_ep) is True
|
||||
assert router.is_ext_openai_endpoint(swap_ep) is False
|
||||
|
||||
def test_swap_tracking_model_normalized(self):
|
||||
swap_ep = "http://host:8890/v1"
|
||||
cfg = self._cfg(swap=[swap_ep])
|
||||
with patch.object(router, "config", cfg):
|
||||
assert router.get_tracking_model(swap_ep, "unsloth/model:Q8_0") == "model"
|
||||
|
||||
def test_llama_endpoints_dedupes_and_orders(self):
|
||||
from backends.normalize import llama_endpoints
|
||||
cfg = self._cfg(server=["a", "b"], swap=["b", "c"])
|
||||
assert llama_endpoints(cfg) == ["a", "b", "c"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue