MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / resolve_inference_bundle

Function resolve_inference_bundle

crates/openshell-server/src/inference.rs:891–931  ·  view source on GitHub ↗

Resolve the inference bundle (all managed routes + revision hash).

(store: &Store)

Source from the content-addressed store, hash-verified

889
890/// Resolve the inference bundle (all managed routes + revision hash).
891async fn resolve_inference_bundle(store: &Store) -> Result<GetInferenceBundleResponse, Status> {
892 let mut routes = Vec::new();
893 if let Some(r) = resolve_route_by_name(store, CLUSTER_INFERENCE_ROUTE_NAME).await? {
894 routes.push(r);
895 }
896 if let Some(r) = resolve_route_by_name(store, SANDBOX_SYSTEM_ROUTE_NAME).await? {
897 routes.push(r);
898 }
899
900 let now_ms = i64::try_from(
901 std::time::SystemTime::now()
902 .duration_since(std::time::UNIX_EPOCH)
903 .unwrap_or_default()
904 .as_millis(),
905 )
906 .unwrap_or(i64::MAX);
907
908 // Compute a simple revision from route contents for cache freshness checks.
909 let revision = {
910 use std::hash::{Hash, Hasher};
911 let mut hasher = std::collections::hash_map::DefaultHasher::new();
912 for r in &routes {
913 r.name.hash(&mut hasher);
914 r.base_url.hash(&mut hasher);
915 r.model_id.hash(&mut hasher);
916 r.api_key.hash(&mut hasher);
917 r.protocols.hash(&mut hasher);
918 r.provider_type.hash(&mut hasher);
919 r.timeout_secs.hash(&mut hasher);
920 r.model_in_path.hash(&mut hasher);
921 r.request_path_override.hash(&mut hasher);
922 }
923 format!("{:016x}", hasher.finish())
924 };
925
926 Ok(GetInferenceBundleResponse {
927 routes,
928 revision,
929 generated_at_ms: now_ms,
930 })
931}
932
933async fn resolve_route_by_name(
934 store: &Store,

Calls 2

resolve_route_by_nameFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected