MCPcopy Create free account
hub / github.com/LeenHawk/sgproxy / normalize_claudecode_sampling

Function normalize_claudecode_sampling

src/proxy.rs:506–526  ·  view source on GitHub ↗
(body: &mut Value)

Source from the content-addressed store, hash-verified

504];
505
506fn normalize_claudecode_sampling(body: &mut Value) {
507 let Some(map) = body.as_object_mut() else {
508 return;
509 };
510
511 let tolerant = map.get("model").and_then(Value::as_str).is_some_and(|m| {
512 SAMPLING_TOLERANT_MODELS
513 .iter()
514 .any(|&prefix| m.starts_with(prefix))
515 });
516
517 if tolerant {
518 if map.contains_key("temperature") {
519 map.remove("top_p");
520 }
521 } else {
522 map.remove("temperature");
523 map.remove("top_p");
524 map.remove("top_k");
525 }
526}
527
528fn apply_claudecode_metadata_user_id(body: &mut Value, credential: &CredentialConfig) {
529 canonicalize_claude_body(body);

Calls

no outgoing calls