Skip to content

Commit

Permalink
fix: allow model hub to be able to search for hugging face url
Browse files Browse the repository at this point in the history
Signed-off-by: James <[email protected]>
  • Loading branch information
James committed Apr 16, 2024
1 parent 22a25cf commit 7fd2ef9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/src/browser/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const downloadFile: (downloadRequest: DownloadRequest, network?: NetworkConfig)
) => globalThis.core?.api?.downloadFile(downloadRequest, network)

/**
* Get file size from browser processes.
* Get unit in bytes for a remote file.
*
* @param url - The url of the file.
* @returns {Promise<number>} - A promise that resolves with the file size.
Expand Down
Binary file removed extensions/model-extension/bin/mac-arm64/quantize
Binary file not shown.
17 changes: 6 additions & 11 deletions web/screens/ExploreModels/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
configuredModelsAtom,
downloadedModelsAtom,
} from '@/helpers/atoms/Model.atom'
import ModelSearch from '../Settings/Models/ModelSearch'

Check failure on line 26 in web/screens/ExploreModels/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

`../Settings/Models/ModelSearch` import should occur before import of `./ExploreModelList`

Check failure on line 26 in web/screens/ExploreModels/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

`../Settings/Models/ModelSearch` import should occur before import of `./ExploreModelList`

Check failure on line 26 in web/screens/ExploreModels/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

`../Settings/Models/ModelSearch` import should occur before import of `./ExploreModelList`

const sortMenu = ['All Models', 'Recommended', 'Downloaded']

Expand Down Expand Up @@ -54,6 +55,10 @@ const ExploreModelsScreen = () => {
setImportModelStage('SELECTING_MODEL')
}, [setImportModelStage])

const onSearchUpdate = useCallback((input: string) => {
setsearchValue(input)
}, [])

return (
<div
className="flex h-full w-full overflow-y-auto bg-background"
Expand All @@ -70,17 +75,7 @@ const ExploreModelsScreen = () => {
/>
<div className="absolute left-1/2 top-1/2 w-1/3 -translate-x-1/2 -translate-y-1/2 space-y-2">
<div className="flex flex-row space-x-2">
<div className="relative">
<SearchIcon
size={20}
className="absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground"
/>
<Input
placeholder="Search models"
className="bg-white pl-9 dark:bg-background"
onChange={(e) => setsearchValue(e.target.value)}
/>
</div>
<ModelSearch onSearchLocal={onSearchUpdate} />
<Button
themes="outline"
className="gap-2 bg-white dark:bg-secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const ModelDownloadRow: React.FC<Props> = ({
])

return (
<div className="flex w-[662px] flex-row items-center justify-between rounded border border-border p-3">
<div className="flex w-[662px] flex-row items-center justify-between space-x-1 rounded border border-border p-3">
<div className="flex">
{quantization && <Badge className="mr-1">{quantization}</Badge>}

Expand Down
2 changes: 1 addition & 1 deletion web/screens/Settings/HuggingFaceRepoDetailModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const HuggingFaceRepoDetailModal: React.FC = () => {

return (
<Modal open={open} onOpenChange={onOpenChange}>
<ModalContent className="max-w-[1162px]">
<ModalContent className="w-[1162px] max-w-[calc(100%-38px)]">
<ModalHeader>
<ModalTitle>{importingHuggingFaceRepoData.id}</ModalTitle>
</ModalHeader>
Expand Down
7 changes: 5 additions & 2 deletions web/screens/Settings/Models/ModelSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ModelSearch: React.FC<Props> = ({ onSearchLocal }) => {

const debounced = useDebouncedCallback(async () => {
if (searchText.indexOf('/') === -1) {
// if we don't find / in text search, do search locally
// If we don't find / in the text, perform a local search
onSearchLocal?.(searchText)
return
}
Expand Down Expand Up @@ -74,7 +74,10 @@ const ModelSearch: React.FC<Props> = ({ onSearchLocal }) => {
<div className="flex flex-row items-center space-x-4">
<Input
placeholder="Search or paste Hugging Face URL"
className={twMerge('pl-8', loading ? 'pr-8' : '')}
className={twMerge(
'bg-white pl-8 dark:bg-background',
loading ? 'pr-8' : ''
)}
onChange={onSearchChanged}
onKeyDown={onKeyDown}
/>
Expand Down
6 changes: 4 additions & 2 deletions web/screens/Settings/Models/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ const Models: React.FC = () => {
const filteredDownloadedModels = useMemo(
() =>
downloadedModels
.sort((a, b) => a.name.localeCompare(b.name))
.filter((e) => e.name.toLowerCase().includes(searchText.toLowerCase())),
.filter((e) =>
e.name.toLowerCase().includes(searchText.toLowerCase().trim())
)
.sort((a, b) => a.name.localeCompare(b.name)),
[downloadedModels, searchText]
)

Expand Down

0 comments on commit 7fd2ef9

Please sign in to comment.