Skip to content

ui : Add Hugging Face Hub data layer - #27947

Open
allozaur wants to merge 4 commits into
allozaur/ui/model-id-parsingfrom
allozaur/ui/hf-data-layer
Open

ui : Add Hugging Face Hub data layer#27947
allozaur wants to merge 4 commits into
allozaur/ui/model-id-parsingfrom
allozaur/ui/hf-data-layer

Conversation

@allozaur

@allozaur allozaur commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Overview

Adds the Hugging Face Hub data layer for llama-ui (only business logic layer, UI will be added in follow ups):

  • New HuggingFaceService for browsing/searching GGUF models on HF Hub:
    • search (by query, task, trending / popular / new / most liked)
    • model details (full=true), repo file tree (recursive, cursor pagination)
    • raw README fetch (YAML frontmatter stripped)
    • llama.app model catalog (/v1/catalog.json) as the default list for the Discover dialog
  • GGUF file analysis helpers:
    • extract quant token + sidecar type from filenames (prefix or suffix form)
    • collapse split shards (Model-00001-of-00015.gguf) into one entry with total size
    • bits-per-weight lookup for known quants (with digit-based fallback, UD- aware)
    • formatting for sizes, download/like counts, and relative time
  • New HF API + catalog types, HfModelSort / SidecarForm / HfEntryType enums
  • New huggingface.constants.ts (URLs, regexes, retry settings, limits)
  • Fetch retry with backoff (3 attempts)

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, pi:zai-org/GLM-5.3-Flash + llama-ui:unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_XL

@allozaur
allozaur force-pushed the allozaur/ui/hf-data-layer branch 2 times, most recently from 8dc9904 to 8371db2 Compare August 29, 2026 10:08
Comment thread tools/ui/src/lib/constants/models-discover.constants.ts
Comment thread tools/ui/src/lib/services/huggingface.service.ts Outdated
Comment thread tools/ui/src/lib/services/huggingface.service.ts Outdated
Comment thread tools/ui/src/lib/services/huggingface.service.ts Outdated
Comment thread tools/ui/src/lib/services/huggingface.service.ts Outdated
Comment thread tools/ui/src/lib/services/huggingface.service.ts Outdated
Comment thread tools/ui/src/lib/services/huggingface.service.ts
Comment thread tools/ui/src/lib/types/huggingface.d.ts Outdated
Comment thread tools/ui/src/lib/types/huggingface.d.ts Outdated
Comment thread tools/ui/src/lib/services/huggingface.service.ts
Comment thread tools/ui/src/lib/constants/huggingface.constants.ts Outdated
Comment thread tools/ui/src/lib/services/huggingface.service.ts Outdated
Comment thread tools/ui/src/lib/services/huggingface.service.ts
@allozaur allozaur changed the title ui : add huggingface hub data layer ui : Add Hugging Face Hub data layer Aug 29, 2026
@allozaur
allozaur marked this pull request as ready for review August 29, 2026 12:03
@allozaur
allozaur requested a review from a team as a code owner August 29, 2026 12:03
Copilot AI lite review requested due to automatic review settings August 29, 2026 12:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds a Hugging Face Hub “data layer” to llama-ui, including types/enums/constants and a new HuggingFaceService for searching/browsing GGUF repos, fetching detail/readme/tree data, and providing GGUF filename/shard parsing helpers.

Changes:

  • Introduces HuggingFaceService with HF API + llama.app catalog fetching, retry logic (for search), and GGUF parsing/formatting utilities.
  • Adds new Hugging Face API types (huggingface.d.ts) and enums (huggingface.enums.ts) and exports them via existing index.ts barrels.
  • Adds huggingface.constants.ts and models-discover.constants.ts for URLs, regexes, limits, and formatting units.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/ui/src/lib/types/index.ts Re-exports new Hugging Face types for app-wide consumption.
tools/ui/src/lib/types/huggingface.d.ts Adds TS declaration types for HF REST API and llama.app catalog responses.
tools/ui/src/lib/services/index.ts Re-exports HuggingFaceService from the services barrel.
tools/ui/src/lib/services/huggingface.service.ts Implements HF browsing/searching plus GGUF parsing/format helpers.
tools/ui/src/lib/enums/index.ts Re-exports new HF enums.
tools/ui/src/lib/enums/huggingface.enums.ts Defines enums mirroring HF API sort and tree-entry type strings.
tools/ui/src/lib/constants/models-discover.constants.ts Adds llama.app catalog URL constant.
tools/ui/src/lib/constants/index.ts Re-exports new constants modules.
tools/ui/src/lib/constants/huggingface.constants.ts Adds HF URL/regex/limits/retry/formatting constants used by the service.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +243 to +253
static formatDownloads(downloads: number): string {
if (downloads >= MEGABYTE) {
return `${(downloads / MEGABYTE).toFixed(1)}${MEGA_LABEL}`;
}

if (downloads >= KILOBYTE) {
return `${(downloads / KILOBYTE).toFixed(1)}${KILO_LABEL}`;
}

return downloads.toString();
}
Comment on lines +288 to +309
static formatRelativeTime(timestamp: string): string {
const date = new Date(timestamp);
const now = new Date();
const diffMs = now.getTime() - date.getTime();
const diffDays = Math.floor(diffMs / MS_PER_DAY);

if (diffDays === 0) return TODAY_LABEL;

if (diffDays === 1) return YESTERDAY_LABEL;

if (diffDays < DAYS_PER_WEEK) return `${diffDays} ${DAYS_AGO_LABEL}`;

if (diffDays < DAYS_PER_MONTH) {
return `${Math.floor(diffDays / DAYS_PER_WEEK)} ${WEEKS_AGO_LABEL}`;
}

if (diffDays < DAYS_PER_YEAR) {
return `${Math.floor(diffDays / DAYS_PER_MONTH)} ${MONTHS_AGO_LABEL}`;
}

return `${Math.floor(diffDays / DAYS_PER_YEAR)} ${YEARS_AGO_LABEL}`;
}
Comment on lines +446 to +452
static async getDetails(modelId: string): Promise<HfModelDetailInfo | null> {
// Do not encode the modelId, it contains slashes for author/name.
// `full=true` includes cardData (description, base_model) and safetensors.
const url = `${HF_API_MODELS_URL}${PATH_SEPARATOR}${modelId}?${HF_FULL_DETAIL_PARAM}`;

try {
const response = await fetch(url);
Comment on lines +148 to +149
*/
export const HF_CACHE_PATH_REGEX = /models--(.+?)\/snapshots\/[^/]+\/(.+)$/;
@allozaur
allozaur force-pushed the allozaur/ui/hf-data-layer branch from 15ef6e7 to eb1e29b Compare August 30, 2026 06:36
@allozaur
allozaur force-pushed the allozaur/ui/hf-data-layer branch from eb1e29b to 8972a1f Compare August 31, 2026 10:56
@allozaur
allozaur force-pushed the allozaur/ui/hf-data-layer branch 2 times, most recently from 9b5a2ba to e8cbf97 Compare August 31, 2026 15:41
@allozaur
allozaur force-pushed the allozaur/ui/hf-data-layer branch from e8cbf97 to c2dffb8 Compare August 31, 2026 21:46
Add HuggingFaceService for browsing and searching GGUF models on the
HF Hub: catalog/model search, model details, repo file tree, raw
README fetch, and the llama.app model catalog. Includes GGUF file
analysis helpers - extractQuantMeta (quant token plus sidecar type
and its form, prefix or suffix), shard collapsing, quant bit-depth
lookup, and download/size/likes formatting.

Add the HF API types and the curated model list shown in the
Discover Models sidebar.

Assisted-by: pi
Address review on the HF data layer:

- replace the HfModelSort / SidecarForm / sibling entry type string
  unions with enums (HfModelSort, SidecarForm, HfEntryType)
- move URLs, query params, regexes, limits, retry settings, shard
  file conventions, tag tokens and formatting units into a dedicated
  huggingface.constants.ts; reuse the existing PATH_SEPARATOR
- drop the task label / pipeline icon / library display maps: the
  discover UI only presents GGUF models, so keep the task tags for
  logic use only (parseTags)
- drop the hardcoded curated model list; the discover dialog gets its
  default list from the llama.app /v1/catalog.json endpoint, which is
  an acceptable online-only source since the feature requires internet
  access anyway

Assisted-by: pi
Address review follow-up: the llama.app catalog endpoint belongs to
the models-discover feature, not the HF constants. Use Number() for
shard index parsing and name the UD-quant prefix segment lookup.

Assisted-by: pi
@allozaur
allozaur force-pushed the allozaur/ui/hf-data-layer branch from c2dffb8 to 548acc2 Compare August 31, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants