feat: sort unsloth models first in HF search dropdowns
This commit is contained in:
parent
88266fd973
commit
5bdec309e6
1 changed files with 14 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import type { PipelineType } from "@huggingface/hub";
|
||||
import { listModels } from "@huggingface/hub";
|
||||
import { useCallback } from "react";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { useHfPaginatedSearch } from "./use-hf-paginated-search";
|
||||
|
||||
export interface HfModelResult {
|
||||
|
|
@ -84,5 +84,17 @@ export function useHfModelSearch(
|
|||
[query, task, accessToken],
|
||||
);
|
||||
|
||||
return useHfPaginatedSearch(createIter, mapModel);
|
||||
const search = useHfPaginatedSearch(createIter, mapModel);
|
||||
|
||||
const results = useMemo(
|
||||
() =>
|
||||
[...search.results].sort((a, b) => {
|
||||
const aFirst = a.id.startsWith("unsloth/") ? 0 : 1;
|
||||
const bFirst = b.id.startsWith("unsloth/") ? 0 : 1;
|
||||
return aFirst - bFirst;
|
||||
}),
|
||||
[search.results],
|
||||
);
|
||||
|
||||
return { ...search, results };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue