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

Function _reuse_anthropic_source_body

uncommon_route/proxy.py:2318–2332  ·  view source on GitHub ↗
(
    *,
    source_body: dict[str, Any],
    upstream_body: dict[str, Any],
)

Source from the content-addressed store, hash-verified

2316
2317
2318def _reuse_anthropic_source_body(
2319 *,
2320 source_body: dict[str, Any],
2321 upstream_body: dict[str, Any],
2322) -> dict[str, Any]:
2323 transport_body = json.loads(json.dumps(source_body))
2324 for key in ("model", "max_tokens", "stream", "temperature", "top_p"):
2325 if key in upstream_body:
2326 transport_body[key] = json.loads(json.dumps(upstream_body[key]))
2327 stop_value = upstream_body.get("stop")
2328 if isinstance(stop_value, list):
2329 transport_body["stop_sequences"] = list(stop_value)
2330 elif isinstance(stop_value, str) and stop_value.strip():
2331 transport_body["stop_sequences"] = [stop_value]
2332 return transport_body
2333
2334
2335def _transport_name(native_anthropic_transport: bool) -> str:

Callers 1

_prepare_attemptFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected