Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions web-app/src/hooks/useModelSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@ export const useModelSources = create<ModelSourcesState>()(
set({ loading: true, error: null })
try {
const newSources = await fetchModelCatalog()
const currentSources = get().sources

set({
sources: [
...newSources,
...currentSources.filter(
(e) => !newSources.some((s) => s.model_name === e.model_name)
),
],
sources: newSources.length ? newSources : get().sources,
loading: false,
})
} catch (error) {
Expand Down
18 changes: 13 additions & 5 deletions web-app/src/routes/hub/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ function Hub() {
const repoInfo = await fetchHuggingFaceRepo(search.repo)
if (repoInfo) {
const catalogModel = convertHfRepoToCatalogModel(repoInfo)
setHuggingFaceRepo(catalogModel)
addSource(catalogModel)
if (
!sources.some((s) => s.model_name === catalogModel.model_name)
) {
setHuggingFaceRepo(catalogModel)
addSource(catalogModel)
}
}

await fetchSources()
Expand All @@ -157,7 +161,7 @@ function Hub() {
}
}, 500)
}
}, [convertHfRepoToCatalogModel, fetchSources, addSource, search])
}, [convertHfRepoToCatalogModel, fetchSources, addSource, search, sources])

// Sorting functionality
const sortedModels = useMemo(() => {
Expand Down Expand Up @@ -247,8 +251,12 @@ function Hub() {
const repoInfo = await fetchHuggingFaceRepo(e.target.value)
if (repoInfo) {
const catalogModel = convertHfRepoToCatalogModel(repoInfo)
setHuggingFaceRepo(catalogModel)
addSource(catalogModel)
if (
!sources.some((s) => s.model_name === catalogModel.model_name)
) {
setHuggingFaceRepo(catalogModel)
addSource(catalogModel)
}
}

// Original addSource logic (if needed)
Expand Down
Loading