mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-30 00:22:10 -04:00
fix(llm-core): prevent cache-affinity fields from reaching Cerebras
Recognize api.cerebras.ai as a Cerebras cloud provider so llama.cpp/LM Studio cache-affinity fields are not attached even when endpoint_kind is misconfigured as local. Add regression coverage for provider detection, self-hosted classification, and payload field exclusion.
This commit is contained in:
@@ -677,6 +677,8 @@ def _detect_provider(url: str) -> str:
|
|||||||
from src.copilot import is_copilot_base
|
from src.copilot import is_copilot_base
|
||||||
if is_copilot_base(url):
|
if is_copilot_base(url):
|
||||||
return "copilot"
|
return "copilot"
|
||||||
|
if _host_match(url, "cerebras.ai"):
|
||||||
|
return "cerebras"
|
||||||
if _host_match(url, "mistral.ai"):
|
if _host_match(url, "mistral.ai"):
|
||||||
return "mistral"
|
return "mistral"
|
||||||
return "openai"
|
return "openai"
|
||||||
@@ -763,6 +765,8 @@ def _provider_label(url: str) -> str:
|
|||||||
if is_chatgpt_subscription_base(url): return "ChatGPT Subscription"
|
if is_chatgpt_subscription_base(url): return "ChatGPT Subscription"
|
||||||
from src.copilot import is_copilot_base
|
from src.copilot import is_copilot_base
|
||||||
if is_copilot_base(url): return "GitHub Copilot"
|
if is_copilot_base(url): return "GitHub Copilot"
|
||||||
|
if _host_match(url, "cerebras.ai"):
|
||||||
|
return "cerebras"
|
||||||
if _host_match(url, "mistral.ai"): return "Mistral"
|
if _host_match(url, "mistral.ai"): return "Mistral"
|
||||||
if _host_match(url, "deepseek.com"): return "DeepSeek"
|
if _host_match(url, "deepseek.com"): return "DeepSeek"
|
||||||
if _host_match(url, "nvidia.com"): return "NVIDIA"
|
if _host_match(url, "nvidia.com"): return "NVIDIA"
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
"""Regression test for issue #4640.
|
||||||
|
|
||||||
|
Cerebras endpoints must not receive llama.cpp-specific fields
|
||||||
|
(session_id, cache_prompt) even when endpoint_kind is misconfigured as 'local'.
|
||||||
|
"""
|
||||||
|
import importlib
|
||||||
|
|
||||||
|
|
||||||
|
def test_detect_provider_recognizes_cerebras():
|
||||||
|
"""_detect_provider should return 'cerebras' for api.cerebras.ai URLs."""
|
||||||
|
llm_core = importlib.import_module("src.llm_core")
|
||||||
|
assert llm_core._detect_provider("https://api.cerebras.ai/v1") == "cerebras"
|
||||||
|
|
||||||
|
|
||||||
|
def test_cerebras_not_self_hosted():
|
||||||
|
"""_is_self_hosted_openai_compatible should be False for Cerebras."""
|
||||||
|
llm_core = importlib.import_module("src.llm_core")
|
||||||
|
assert llm_core._is_self_hosted_openai_compatible("https://api.cerebras.ai/v1") is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_apply_local_cache_affinity_skips_cerebras():
|
||||||
|
"""_apply_local_cache_affinity must not add session_id/cache_prompt for Cerebras."""
|
||||||
|
llm_core = importlib.import_module("src.llm_core")
|
||||||
|
payload = {"messages": []}
|
||||||
|
llm_core._apply_local_cache_affinity(payload, "https://api.cerebras.ai/v1", "test-session-123")
|
||||||
|
assert "session_id" not in payload, "session_id leaked into Cerebras payload"
|
||||||
|
assert "cache_prompt" not in payload, "cache_prompt leaked into Cerebras payload"
|
||||||
Reference in New Issue
Block a user