MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _apply_provider_cache_plan

Function _apply_provider_cache_plan

uncommon_route/proxy.py:2024–2052  ·  view source on GitHub ↗
(
    body: dict[str, Any],
    *,
    selected_model: str,
    provider_entry: Any,
    session_id: str | None,
    step_type: str,
    upstream_provider: str,
)

Source from the content-addressed store, hash-verified

2022
2023
2024def _apply_provider_cache_plan(
2025 body: dict[str, Any],
2026 *,
2027 selected_model: str,
2028 provider_entry: Any,
2029 session_id: str | None,
2030 step_type: str,
2031 upstream_provider: str,
2032) -> CacheRequestPlan:
2033 family = provider_family_for_model(
2034 selected_model,
2035 provider_name=getattr(provider_entry, "name", None),
2036 upstream_provider=upstream_provider,
2037 )
2038 if family == "openai":
2039 return apply_openai_cache_hints(
2040 body,
2041 model=selected_model,
2042 session_id=session_id,
2043 step_type=step_type,
2044 )
2045 if family == "anthropic":
2046 return CacheRequestPlan(family="anthropic", mode="stable-prefix")
2047 if family == "deepseek":
2048 return CacheRequestPlan(family="deepseek", mode="stable-prefix")
2049 if family == "google":
2050 _strip_openai_cache_hints_for_google(body)
2051 return CacheRequestPlan(family="google", mode="cache-bypass")
2052 return CacheRequestPlan(family=family)
2053
2054
2055def _strip_openai_cache_hints_for_google(body: dict[str, Any]) -> None:

Callers 1

_prepare_attemptFunction · 0.85

Calls 4

apply_openai_cache_hintsFunction · 0.90
CacheRequestPlanClass · 0.90

Tested by

no test coverage detected