Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: duplicate model while searching

Louis736790473eec
diff --git a/web-app/src/hooks/useModelSources.ts b/web-app/src/hooks/useModelSources.ts
index 916d8eae2..72d011582 100644
--- a/web-app/src/hooks/useModelSources.ts
+++ b/web-app/src/hooks/useModelSources.ts
@@ -8,7 +8,6 @@ type ModelSourcesState = {
sources: CatalogModel[]
error: Error | null
loading: boolean
- addSource: (source: CatalogModel) => void
fetchSources: () => Promise<void>
}
@@ -18,15 +17,6 @@ export const useModelSources = create<ModelSourcesState>()(
sources: [],
error: null,
loading: false,
-
- addSource: (source: CatalogModel) => {
- set((state) => ({
- sources: [
- ...state.sources.filter((e) => e.model_name !== source.model_name),
- source,
- ],
- }))
- },
fetchSources: async () => {
set({ loading: true, error: null })
try {
diff --git a/web-app/src/routes/hub/index.tsx b/web-app/src/routes/hub/index.tsx
index 2a6e6220d..5e43cc70e 100644
--- a/web-app/src/routes/hub/index.tsx
+++ b/web-app/src/routes/hub/index.tsx
@@ -73,7 +73,7 @@ function Hub() {
}
}, [])
- const { sources, addSource, fetchSources, loading } = useModelSources()
+ const { sources, fetchSources, loading } = useModelSources()
const [searchValue, setSearchValue] = useState('')
const [sortSelected, setSortSelected] = useState('newest')
@@ -187,14 +187,16 @@ function Hub() {
addModelSourceTimeoutRef.current = setTimeout(async () => {
try {
// Fetch HuggingFace repository information
- const repoInfo = await fetchHuggingFaceRepo(e.target.value, huggingfaceToken)
+ const repoInfo = await fetchHuggingFaceRepo(
+ e.target.value,
+ huggingfaceToken
+ )
if (repoInfo) {
const catalogModel = convertHfRepoToCatalogModel(repoInfo)
if (
!sources.some((s) => s.model_name === catalogModel.model_name)
) {
setHuggingFaceRepo(catalogModel)
- addSource(catalogModel)
}
}
} catch (error) {