The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): Find more models — Hugging Face search + Add model file
emozilla9a31ee39adc7
diff --git a/apps/desktop/src/api/local-models.ts b/apps/desktop/src/api/local-models.tsindex 4d449e1b9c2..f3b5f35566d 100644--- a/apps/desktop/src/api/local-models.ts+++ b/apps/desktop/src/api/local-models.ts@@ -97,3 +97,52 @@ export function setLocalServer(action: 'start' | 'stop'): Promise<{ ok: booleanpath: '/api/local-models/server'})}++// ── Hugging Face browser + sideload ─────────────────────────────++export interface HFSearchHit {+ repo: string+ downloads: number+ likes: number+ updated: string+ gated: boolean+}++export interface HFFileGroup {+ label: string+ paths: string[]+ total_bytes: number+ fit: 'fits-gpu' | 'needs-ram' | 'too-big' | 'unknown'+}++export function searchHFModels(q: string, limit = 20): Promise<{ hits: HFSearchHit[] }> {+ return hermesApi<{ hits: HFSearchHit[] }>({+ ...profileScoped(),+ path: `/api/local-models/search?q=${encodeURIComponent(q)}&limit=${limit}`+ })+}++export function listHFRepoFiles(repo: string): Promise<{ files: HFFileGroup[] }> {+ return hermesApi<{ files: HFFileGroup[] }>({+ ...profileScoped(),+ path: `/api/local-models/search/files?repo=${encodeURIComponent(repo)}`+ })+}++export function downloadBrowsedModel(repo: string, paths: string[]): Promise<{ already_downloaded?: boolean; job_id: null | string; model_id: string }> {+ return hermesApi<{ already_downloaded?: boolean; job_id: null | string; model_id: string }>({+ ...profileScoped(),+ body: { paths, repo },+ method: 'POST',+ path: '/api/local-models/download-browsed'+ })+}++export function sideloadLocalModel(path: string): Promise<{ already_present?: boolean; model_id: string; ok: boolean }> {+ return hermesApi<{ already_present?: boolean; model_id: string; ok: boolean }>({+ ...profileScoped(),+ body: { path },+ method: 'POST',+ path: '/api/local-models/sideload'+ })+}diff --git a/apps/desktop/src/app/settings/local-models-settings.test.tsx b/apps/desktop/src/app/settings/local-models-settings.test.tsxindex e125eb40c8a..792c24a1659 100644--- a/apps/desktop/src/app/settings/local-models-settings.test.tsx+++ b/apps/desktop/src/app/settings/local-models-settings.test.tsx@@ -1,4 +1,4 @@-import { cleanup, render, screen, waitFor } from '@testing-library/react'+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { I18nProvider } from '@/i18n'@@ -12,6 +12,7 @@ import { LocalModelsSettings } from './local-models-settings'vi.mock('@/hermes', () => ({activateLocalModel: vi.fn(),deleteLocalModel: vi.fn(),+ downloadBrowsedModel: vi.fn(),downloadLocalModel: vi.fn(),ejectLocalModel: vi.fn(),getLocalCatalog: vi.fn(),@@ -19,7 +20,10 @@ vi.mock('@/hermes', () => ({getLocalModelsJobs: vi.fn(),getLocalModelsStatus: vi.fn(),getLocalRuntimeJob: vi.fn(),- installLocalRuntime: vi.fn()+ installLocalRuntime: vi.fn(),+ listHFRepoFiles: vi.fn(),+ searchHFModels: vi.fn(),+ sideloadLocalModel: vi.fn()}))import * as hermes from '@/hermes'@@ -242,7 +246,7 @@ describe('LocalModelsSettings', () => {// The fitting row shows byte progress; the remaining download// buttons belong to the other rows (spilled + refused).- expect(screen.getByText(/0\.0 GB of 0\.0 GB|of/)).toBeTruthy()+ expect(screen.getAllByText(/0\.0 GB of 0\.0 GB|of/).length).toBeGreaterThan(0)const remaining = screen.queryAllByRole('button', { name: /download · 17\.6 GB/i })expect(remaining.length).toBe(2)expect(remaining.some(b => (b as HTMLButtonElement).disabled)).toBe(true)@@ -275,3 +279,51 @@ describe('LocalModelsSettings', () => {expect(await screen.findByText(/integrity check/)).toBeTruthy()})})++describe('BrowseSection', () => {+ it('searches HF after a pause and shows fit-priced files on demand', async () => {+ vi.useFakeTimers()+ try {+ vi.mocked(hermes.searchHFModels).mockResolvedValue({+ hits: [{ downloads: 872724, gated: false, likes: 47, repo: 'unsloth/Qwen3.8-27B-GGUF', updated: '2026-08-18' }]+ })+ vi.mocked(hermes.listHFRepoFiles).mockResolvedValue({+ files: [+ { fit: 'fits-gpu', label: 'Q4_K_M', paths: ['Qwen3.8-27B-Q4_K_M.gguf'], total_bytes: 17 * 2 ** 30 },+ { fit: 'too-big', label: 'F16', paths: ['Qwen3.8-27B-F16.gguf'], total_bytes: 56 * 2 ** 30 }+ ]+ })++ render(+ <I18nProvider>+ <LocalModelsSettings />+ </I18nProvider>+ )+ await act(async () => {+ await vi.runOnlyPendingTimersAsync()+ })++ const box = screen.getByPlaceholderText(/search models/i)+ fireEvent.change(box, { target: { value: 'qwen' } })+ // Debounce: no call until the pause elapses.+ expect(hermes.searchHFModels).not.toHaveBeenCalled()+ await act(async () => {+ await vi.advanceTimersByTimeAsync(400)+ })+ expect(hermes.searchHFModels).toHaveBeenCalledWith('qwen')+ expect(screen.getByText('unsloth/Qwen3.8-27B-GGUF')).toBeTruthy()++ fireEvent.click(screen.getByRole('button', { name: /show files/i }))+ await act(async () => {+ await vi.runOnlyPendingTimersAsync()+ })+ expect(screen.getByText('Q4_K_M')).toBeTruthy()+ // The too-big quant's download button is disabled; fits-gpu is live.+ const buttons = screen.getAllByRole('button', { name: /GB/ })+ expect(buttons.some(b => (b as HTMLButtonElement).disabled)).toBe(true)+ expect(buttons.some(b => !(b as HTMLButtonElement).disabled)).toBe(true)+ } finally {+ vi.useRealTimers()+ }+ })+})diff --git a/apps/desktop/src/app/settings/local-models-settings.tsx b/apps/desktop/src/app/settings/local-models-settings.tsxindex 66cedc513bb..b7651f057f1 100644--- a/apps/desktop/src/app/settings/local-models-settings.tsx+++ b/apps/desktop/src/app/settings/local-models-settings.tsx@@ -1,21 +1,27 @@import { useStore } from '@nanostores/react'-import { useCallback, useEffect, useState } from 'react'+import { useCallback, useEffect, useRef, useState } from 'react'import { Button } from '@/components/ui/button'import { Tip } from '@/components/ui/tooltip'import {activateLocalModel,deleteLocalModel,+ downloadBrowsedModel,downloadLocalModel,ejectLocalModel,getLocalCatalog,getLocalHardware,getLocalModelsStatus,+ type HFFileGroup,+ type HFSearchHit,installLocalRuntime,- setLocalServer+ listHFRepoFiles,+ searchHFModels,+ setLocalServer,+ sideloadLocalModel} from '@/hermes'import { useI18n } from '@/i18n'-import { Check, CheckCircle2, Cpu, Download, Eject, Loader2, Monitor, Package, StopFilled, Trash2, Zap } from '@/lib/icons'+import { Check, CheckCircle2, Cpu, Download, Eject, FolderOpen, Loader2, Monitor, Package, Search, StopFilled, Trash2, Zap } from '@/lib/icons'import { cn } from '@/lib/utils'import {$localRuntimeJobs,@@ -572,6 +578,228 @@ export function LocalModelsSettings() {<p className="text-[0.75rem] text-destructive">{lastError.error}</p>)}</SettingsSection>++ <BrowseSection onChanged={refresh} /></SettingsContent>)}++function fitTone(fit: HFFileGroup['fit']): 'destructive' | 'muted' | 'success' | 'warn' {+ if (fit === 'fits-gpu') {+ return 'success'+ }++ if (fit === 'needs-ram') {+ return 'warn'+ }++ if (fit === 'too-big') {+ return 'destructive'+ }++ return 'muted'+}++function BrowseSection({ onChanged }: { onChanged: () => void }) {+ const { t } = useI18n()+ const copy = t.settings.localModels+ const [query, setQuery] = useState('')+ const [hits, setHits] = useState<HFSearchHit[]>([])+ const [searching, setSearching] = useState(false)+ const [openRepo, setOpenRepo] = useState<null | string>(null)+ const [files, setFiles] = useState<HFFileGroup[]>([])+ const [listing, setListing] = useState(false)+ const [error, setError] = useState<null | string>(null)+ // Guard against the past: a stale search result must never overwrite a+ // newer query's hits (the desktop guide's out-of-order rule).+ const searchSeq = useRef(0)++ useEffect(() => {+ const q = query.trim()++ if (q.length < 2) {+ setHits([])+ setSearching(false)++ return+ }++ const seq = ++searchSeq.current+ setSearching(true)++ const handle = setTimeout(() => {+ searchHFModels(q)+ .then(r => {+ if (searchSeq.current === seq) {+ setHits(r.hits)+ setError(null)+ }+ })+ .catch((e: Error) => {+ if (searchSeq.current === seq) {+ setError(e.message)+ }+ })+ .finally(() => {+ if (searchSeq.current === seq) {+ setSearching(false)+ }+ })+ }, 350)++ return () => clearTimeout(handle)+ }, [query])++ const openFiles = useCallback((repo: string) => {+ setOpenRepo(repo)+ setFiles([])+ setListing(true)+ listHFRepoFiles(repo)+ .then(r => setFiles(r.files))+ .catch((e: Error) => setError(e.message))+ .finally(() => setListing(false))+ }, [])++ const startBrowsedDownload = useCallback(+ (repo: string, group: HFFileGroup) => {+ downloadBrowsedModel(repo, group.paths)+ .then(r => {+ if (r.already_downloaded) {+ notify({ durationMs: 3_000, kind: 'info', message: copy.browseAlreadyDownloaded, title: copy.browseTitle })+ }++ onChanged()+ })+ .catch((e: Error) => notifyError(e, copy.browseTitle))+ },+ [copy.browseAlreadyDownloaded, copy.browseTitle, onChanged]+ )++ const sideload = useCallback(() => {+ window.hermesDesktop+ .selectPaths({ filters: [{ extensions: ['gguf'], name: 'GGUF models' }], title: copy.sideloadTitle })+ .then(paths => {+ if (!paths.length) {+ return+ }++ return sideloadLocalModel(paths[0]).then(r => {+ notify({+ durationMs: 3_000,+ kind: 'success',+ message: r.already_present ? copy.sideloadAlreadyPresent : copy.sideloadDone.replace('{name}', r.model_id),+ title: copy.browseTitle+ })+ onChanged()+ })+ })+ .catch((e: Error) => notifyError(e, copy.browseTitle))+ }, [copy.browseTitle, copy.sideloadAlreadyPresent, copy.sideloadDone, copy.sideloadTitle, onChanged])++ return (+ <SettingsSection+ aside={+ <Button onClick={sideload} size="sm" variant="outline">+ <FolderOpen className="mr-1 size-3.5" />+ {copy.sideloadButton}+ </Button>+ }+ icon={Search}+ title={copy.browseTitle}+ >+ <p className="text-[0.75rem] text-muted-foreground">{copy.browseHint}</p>++ <div className="relative">+ <Search className="pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground" />+ <input+ className="w-full rounded-md border border-(--ui-border) bg-transparent py-1.5 pl-8 pr-3 text-[0.8rem] outline-none placeholder:text-muted-foreground focus:border-primary"+ onChange={e => setQuery(e.target.value)}+ placeholder={copy.browsePlaceholder}+ value={query}+ />+ </div>++ {searching && (+ <p className="flex items-center gap-2 text-[0.75rem] text-muted-foreground">+ <Loader2 className="size-3 animate-spin" />+ {copy.browseSearching}+ </p>+ )}++ {error && <p className="text-[0.75rem] text-destructive">{error}</p>}++ <div className="grid gap-1">+ {hits.map(hit => (+ <div key={hit.repo}>+ <ListRow+ action={+ <Button onClick={() => openFiles(hit.repo)} size="sm" variant="ghost">+ {openRepo === hit.repo ? copy.browseRefresh : copy.browseShowFiles}+ </Button>+ }+ description={+ <span>+ {Intl.NumberFormat().format(hit.downloads)} {copy.browseDownloads}+ {' · '}+ {Intl.NumberFormat().format(hit.likes)} {copy.browseLikes}+ {hit.gated ? ` · ${copy.browseGated}` : ''}+ </span>+ }+ title={<span className="font-mono text-[0.8rem]">{hit.repo}</span>}+ />++ {openRepo === hit.repo && (+ <div className="ml-4 grid gap-1 border-l border-(--ui-border) pl-3">+ {listing && (+ <p className="flex items-center gap-2 py-1 text-[0.75rem] text-muted-foreground">+ <Loader2 className="size-3 animate-spin" />+ {copy.browseListing}+ </p>+ )}++ {!listing && files.length === 0 && (+ <p className="py-1 text-[0.75rem] text-muted-foreground">{copy.browseNoGguf}</p>+ )}++ {files.map(group => (+ <ListRow+ action={+ <Button+ disabled={group.fit === 'too-big'}+ onClick={() => startBrowsedDownload(hit.repo, group)}+ size="sm"+ variant="outline"+ >+ <Download className="mr-1 size-3.5" />+ {gbLabel(group.total_bytes)}+ </Button>+ }+ description={+ <Pill tone={fitTone(group.fit)}>+ <Cpu className="mr-1 size-3" />+ {group.fit === 'fits-gpu'+ ? copy.pillFitsGpu+ : group.fit === 'needs-ram'+ ? copy.pillUsesRam+ : group.fit === 'too-big'+ ? copy.pillTooBig+ : copy.browseFitUnknown}+ </Pill>+ }+ key={group.label}+ title={+ <span className="font-mono text-[0.78rem]">+ {group.label}+ {group.paths.length > 1 ? ` (${group.paths.length} files)` : ''}+ </span>+ }+ />+ ))}+ </div>+ )}+ </div>+ ))}+ </div>+ </SettingsSection>+ )+}diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 929ac2185d8..169c28c220e 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -1103,6 +1103,23 @@ export const en: Translations = {pillFitsGpu: 'Fits your GPU',pillUsesRam: 'Uses system RAM',pillTooBig: 'Too big for this machine',+ browseTitle: 'Find more models',+ browseHint: 'Search all of Hugging Face. Anything you download here works like a catalog model — sized to your machine automatically — but has not been tested by us.',+ browsePlaceholder: 'Search models by name or author…',+ browseSearching: 'Searching Hugging Face',+ browseListing: 'Reading model files',+ browseShowFiles: 'Show files',+ browseRefresh: 'Refresh',+ browseDownloads: 'downloads',+ browseLikes: 'likes',+ browseGated: 'requires Hugging Face sign-in',+ browseNoGguf: 'No model files this app can run were found in this listing.',+ browseFitUnknown: 'Fit unknown',+ browseAlreadyDownloaded: 'That model is already downloaded.',+ sideloadButton: 'Add model file',+ sideloadTitle: 'Choose a GGUF model file',+ sideloadDone: '{name} added — it will appear in your models list.',+ sideloadAlreadyPresent: 'That model file is already in your library.',pillFullContext: max => `Full ${max} context`,pillFullContextTip: "Runs at the model's complete context window from the start",pillStarts: start => `Starts at ${start}`,diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 116a77592ec..9c17f7e1d65 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -1025,6 +1025,23 @@ export const ja = defineLocale({pillFitsGpu: 'GPU に完全に収まります',pillUsesRam: 'システム RAM を使用',pillTooBig: 'このマシンには大きすぎます',+ browseTitle: 'さらにモデルを探す',+ browseHint: 'Hugging Face 全体を検索できます。ここでダウンロードしたモデルもカタログのモデルと同様に自動でマシンに合わせて動作しますが、当方でのテストは行われていません。',+ browsePlaceholder: 'モデル名または作者で検索…',+ browseSearching: 'Hugging Face を検索中',+ browseListing: 'モデルファイルを読み込み中',+ browseShowFiles: 'ファイルを表示',+ browseRefresh: '更新',+ browseDownloads: 'ダウンロード',+ browseLikes: 'いいね',+ browseGated: 'Hugging Face へのサインインが必要',+ browseNoGguf: 'このリポジトリには本アプリで実行できるモデルファイルがありません。',+ browseFitUnknown: '適合状況は不明',+ browseAlreadyDownloaded: 'そのモデルはダウンロード済みです。',+ sideloadButton: 'モデルファイルを追加',+ sideloadTitle: 'GGUF モデルファイルを選択',+ sideloadDone: '{name} を追加しました — モデル一覧に表示されます。',+ sideloadAlreadyPresent: 'そのモデルファイルは既にライブラリにあります。',pillFullContext: max => `フル ${max} コンテキスト`,pillFullContextTip: '最初からモデルの完全なコンテキストウィンドウで動作します',pillStarts: start => `${start} から開始`,diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 1625f702f4c..026ea05f12d 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -958,6 +958,23 @@ export interface Translations {pillFitsGpu: stringpillUsesRam: stringpillTooBig: string+ browseTitle: string+ browseHint: string+ browsePlaceholder: string+ browseSearching: string+ browseListing: string+ browseShowFiles: string+ browseRefresh: string+ browseDownloads: string+ browseLikes: string+ browseGated: string+ browseNoGguf: string+ browseFitUnknown: string+ browseAlreadyDownloaded: string+ sideloadButton: string+ sideloadTitle: string+ sideloadDone: string+ sideloadAlreadyPresent: stringpillFullContext: (max: string) => stringpillFullContextTip: stringpillStarts: (start: string) => stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex a2042e56b9c..25dd771bfbd 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -993,6 +993,23 @@ export const zhHant = defineLocale({pillFitsGpu: '完全在 GPU 上執行',pillUsesRam: '使用系統記憶體',pillTooBig: '超出本機記憶體',+ browseTitle: '發現更多模型',+ browseHint: '搜尋整個 Hugging Face。在這裡下載的模型和目錄模型一樣自動適配你的機器,但未經我們測試。',+ browsePlaceholder: '按名稱或作者搜尋模型…',+ browseSearching: '正在搜尋 Hugging Face',+ browseListing: '正在讀取模型檔案',+ browseShowFiles: '查看檔案',+ browseRefresh: '重新整理',+ browseDownloads: '次下載',+ browseLikes: '個讚',+ browseGated: '需要登入 Hugging Face',+ browseNoGguf: '此儲存庫中沒有本應用可執行的模型檔案。',+ browseFitUnknown: '適配情況未知',+ browseAlreadyDownloaded: '該模型已下載。',+ sideloadButton: '新增模型檔案',+ sideloadTitle: '選擇 GGUF 模型檔案',+ sideloadDone: '{name} 已新增——它將出現在你的模型清單中。',+ sideloadAlreadyPresent: '該模型檔案已在你的庫中。',pillFullContext: max => `完整 ${max} 上下文`,pillFullContextTip: '從一開始就以模型的完整上下文視窗執行',pillStarts: start => `起始 ${start}`,diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 4a1795b3d32..597ba53f324 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -1298,6 +1298,23 @@ export const zh: Translations = {pillFitsGpu: '完全在 GPU 上运行',pillUsesRam: '使用系统内存',pillTooBig: '超出本机内存',+ browseTitle: '发现更多模型',+ browseHint: '搜索整个 Hugging Face。在这里下载的模型和目录模型一样自动适配你的机器,但未经我们测试。',+ browsePlaceholder: '按名称或作者搜索模型…',+ browseSearching: '正在搜索 Hugging Face',+ browseListing: '正在读取模型文件',+ browseShowFiles: '查看文件',+ browseRefresh: '刷新',+ browseDownloads: '次下载',+ browseLikes: '个赞',+ browseGated: '需要登录 Hugging Face',+ browseNoGguf: '此仓库中没有本应用可运行的模型文件。',+ browseFitUnknown: '适配情况未知',+ browseAlreadyDownloaded: '该模型已下载。',+ sideloadButton: '添加模型文件',+ sideloadTitle: '选择 GGUF 模型文件',+ sideloadDone: '{name} 已添加——它将出现在你的模型列表中。',+ sideloadAlreadyPresent: '该模型文件已在你的库中。',pillFullContext: max => `完整 ${max} 上下文`,pillFullContextTip: '从一开始就以模型的完整上下文窗口运行',pillStarts: start => `起始 ${start}`,diff --git a/website/docs/user-guide/local-models.md b/website/docs/user-guide/local-models.mdindex 9d4900e5894..6dbd7b83e42 100644--- a/website/docs/user-guide/local-models.md+++ b/website/docs/user-guide/local-models.md@@ -75,6 +75,22 @@ Right-click the status bar and enable **System resources** to see live GPUutilization, GPU memory, and RAM while local models run. The context meteralways reflects the window the model is actually running with.+## Finding more models++The catalog is a curated starting point, not a boundary. The **Find more+models** section on the same page searches all of Hugging Face:++- Results show download counts and a per-file fit check sized to your+ machine, so you know before downloading whether a build runs fully on+ your GPU.+- Anything you download behaves exactly like a catalog model — Hermes+ reads the model file itself to pick its context window and memory+ placement. The only difference: community models don't carry our+ "validated" testing badge.+- Already have a `.gguf` file on disk? **Add model file** links it into+ your library without copying it (the original stays where it is), and+ it's usable immediately.+## Using your own llama-serverIf a llama-server is already running on your machine, Hermes detects it