MCPcopy Create free account
hub / github.com/Icecubesaad/OpenLLM-Studio / MyLibrary

Function MyLibrary

src/components/MyLibrary.tsx:8–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import { formatBytes, formatSpeed } from '../lib/utils';
7
8export function MyLibrary() {
9 const { installedModels, isLoading, error, refreshModels } = useModels();
10 const { deleteModel, error: deleteError } = useModelDelete(refreshModels);
11 const { downloads } = useModelDownload(refreshModels);
12
13 const handleUseInChat = (modelName: string) => {
14 // Store selected model in localStorage
15 localStorage.setItem('selected-model', modelName);
16 // Trigger navigation to chat page
17 window.dispatchEvent(new CustomEvent('navigate-to-chat', { detail: { model: modelName } }));
18 };
19
20 if (isLoading) {
21 return (
22 <div className="flex items-center justify-center h-full">
23 <LoadingSpinner size="lg" />
24 </div>
25 );
26 }
27
28 // Get currently downloading models
29 const downloadingModels = Array.from(downloads.entries()).filter(
30 ([_, progress]) => progress.isDownloading
31 );
32
33 return (
34 <div className="p-8 max-w-7xl mx-auto">
35 {(error || deleteError) && (
36 <div className="mb-6">
37 <ErrorBanner message={error || deleteError || ''} onRetry={refreshModels} />
38 </div>
39 )}
40
41 {/* Currently Downloading Section */}
42 {downloadingModels.length > 0 && (
43 <div className="mb-10">
44 <div className="flex items-center gap-3 mb-4">
45 <div className="w-2 h-2 bg-dark-accent rounded-full animate-pulse" />
46 <h2 className="text-xl font-semibold text-dark-text">Downloading</h2>
47 <span className="text-dark-text-muted text-sm">
48 {downloadingModels.length} {downloadingModels.length === 1 ? 'model' : 'models'}
49 </span>
50 </div>
51
52 <div className="space-y-3">
53 {downloadingModels.map(([modelName, progress]) => (
54 <div
55 key={modelName}
56 className="bg-dark-surface border border-dark-border rounded-xl p-5 hover:border-dark-accent transition-all"
57 >
58 <div className="flex items-center justify-between mb-3">
59 <div className="flex items-center gap-3">
60 <div className="w-10 h-10 bg-dark-accent bg-opacity-20 rounded-lg flex items-center justify-center">
61 <svg className="w-5 h-5 text-dark-accent" fill="none" stroke="currentColor" viewBox="0 0 24 24">
62 <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
63 </svg>
64 </div>
65 <div>

Callers

nothing calls this directly

Calls 8

useModelsFunction · 0.90
useModelDeleteFunction · 0.90
useModelDownloadFunction · 0.90
formatBytesFunction · 0.90
formatSpeedFunction · 0.90
deleteModelFunction · 0.85
fromMethod · 0.80
handleUseInChatFunction · 0.70

Tested by

no test coverage detected