{{ $id := delimit (slice "huggingface" (partial "functions/uid.html" .)) "-" }} {{- $model := .Get "model" -}} {{- $dataset := .Get "dataset" -}} {{- $hfAPI := "" -}} {{- $repoLink := "" -}} {{- $type := "" -}} {{- if $model -}} {{- $hfAPI = print "https://huggingface.co/api/models/" $model -}} {{- $repoLink = print "https://huggingface.co/" $model -}} {{- $type = "model" -}} {{- else if $dataset -}} {{- $hfAPI = print "https://huggingface.co/api/datasets/" $dataset -}} {{- $repoLink = print "https://huggingface.co/datasets/" $dataset -}} {{- $type = "dataset" -}} {{- end -}} {{- $huggingfaceData := dict -}} {{- with try (resources.GetRemote $hfAPI) -}} {{- with .Err -}} {{- warnf "huggingface shortcode: failed to fetch remote resource from %q: %s" $hfAPI $.Position -}} {{- else with .Value -}} {{- $huggingfaceData = . | transform.Unmarshal -}} {{- else -}} {{- warnf "huggingface shortcode: unable to get remote resource from %q: %s" $hfAPI $.Position -}} {{- end -}} {{- end -}} {{- with $huggingfaceData -}}
{{- else -}} {{ warnf "huggingface shortcode: unable to fetch %q: %s" $hfAPI .Position }} {{- end -}} {{ define "HuggingFaceSVG" }} {{/* prettier-ignore-start */}} {{/* prettier-ignore-end */}} {{ end }}