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

Function _build_semantic_compressor

uncommon_route/proxy.py:2804–2825  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2802 return f"{str(base_url or '').rstrip('/')}/chat/completions"
2803
2804 def _build_semantic_compressor() -> SemanticCompressor | None:
2805 if not upstream:
2806 return semantic_compressor if semantic_compressor is not None and not isinstance(semantic_compressor, UpstreamSemanticCompressor) else None
2807 if semantic_compressor is not None and not isinstance(semantic_compressor, UpstreamSemanticCompressor):
2808 return semantic_compressor
2809 compressor = _semantic if isinstance(_semantic, UpstreamSemanticCompressor) else None
2810 if compressor is None:
2811 compressor = UpstreamSemanticCompressor(
2812 upstream_chat=_upstream_chat_url(upstream),
2813 primary_api_key=_primary_api_key,
2814 providers_config=_providers,
2815 model_mapper=_mapper,
2816 composition_policy=_composition_policy,
2817 )
2818 else:
2819 compressor.rebind_primary(
2820 upstream_chat=_upstream_chat_url(upstream),
2821 primary_api_key=_primary_api_key,
2822 model_mapper=_mapper,
2823 )
2824 compressor.rebind_providers(_providers)
2825 return compressor
2826
2827 _semantic = _build_semantic_compressor()
2828

Callers 2

create_appFunction · 0.85

Calls 4

rebind_primaryMethod · 0.95
rebind_providersMethod · 0.95
_upstream_chat_urlFunction · 0.85

Tested by

no test coverage detected