refactor(hermes_cli): collapse PATH B step d.5/e gating
This commit is contained in:
@@ -1218,20 +1218,16 @@ def _route_from_model_input(st: _Switch) -> Optional[ModelSwitchResult]:
|
||||
if matched is not None:
|
||||
st.new_model, resolved_in_current_catalog = matched, True
|
||||
|
||||
# Step d.5 — deliberately NOT gated on ``not is_custom``.
|
||||
config_routed = False
|
||||
if not st.resolved_alias and not resolved_in_current_catalog and st.target_provider == current_provider:
|
||||
config_routed = _route_configured_provider(st)
|
||||
if isinstance(config_routed, ModelSwitchResult):
|
||||
return config_routed
|
||||
|
||||
# Step e
|
||||
# Steps d.5 / e only apply while the request is still unrouted on the current provider.
|
||||
if st.resolved_alias or resolved_in_current_catalog or st.target_provider != current_provider:
|
||||
return None
|
||||
config_routed = _route_configured_provider(st) # d.5 — deliberately NOT gated on ``not is_custom``
|
||||
if isinstance(config_routed, ModelSwitchResult):
|
||||
return config_routed
|
||||
is_custom = (
|
||||
current_provider in {"custom", "local"} or current_provider.startswith("custom:")
|
||||
or base_url_hostname(st.current_base_url or "") in ("localhost", "127.0.0.1"))
|
||||
if (
|
||||
st.target_provider == current_provider and not is_custom and not st.resolved_alias
|
||||
and not resolved_in_current_catalog and not config_routed):
|
||||
if not config_routed and not is_custom: # e
|
||||
detected = detect_provider_for_model(st.new_model, current_provider)
|
||||
if detected:
|
||||
st.target_provider, st.new_model = detected
|
||||
|
||||
Reference in New Issue
Block a user