fixing storage nan for rag

This commit is contained in:
2025-08-25 17:18:34 +02:00
parent ac5a8476bc
commit eb1daa60f4

View File

@@ -31,10 +31,22 @@ interface Collection {
} }
interface CollectionStats { interface CollectionStats {
total_collections: number collections: {
total_documents: number total: number
total_size: number active: number
active_collections: number }
documents: {
total: number
processing: number
processed: number
}
storage: {
total_size_bytes: number
total_size_mb: number
}
vectors: {
total: number
}
} }
export default function RAGPage() { export default function RAGPage() {
@@ -117,8 +129,8 @@ function RAGPageContent() {
) )
} }
const formatBytes = (bytes: number) => { const formatBytes = (bytes: number | null | undefined) => {
if (bytes === 0) return '0 Bytes' if (!bytes || bytes === 0) return '0 Bytes'
const k = 1024 const k = 1024
const sizes = ['Bytes', 'KB', 'MB', 'GB'] const sizes = ['Bytes', 'KB', 'MB', 'GB']
const i = Math.floor(Math.log(bytes) / Math.log(k)) const i = Math.floor(Math.log(bytes) / Math.log(k))
@@ -145,9 +157,9 @@ function RAGPageContent() {
<Database className="h-4 w-4 text-muted-foreground" /> <Database className="h-4 w-4 text-muted-foreground" />
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="text-2xl font-bold">{stats.total_collections}</div> <div className="text-2xl font-bold">{stats.collections.total}</div>
<p className="text-xs text-muted-foreground"> <p className="text-xs text-muted-foreground">
{stats.active_collections} active {stats.collections.active} active
</p> </p>
</CardContent> </CardContent>
</Card> </Card>
@@ -157,7 +169,7 @@ function RAGPageContent() {
<FileText className="h-4 w-4 text-muted-foreground" /> <FileText className="h-4 w-4 text-muted-foreground" />
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="text-2xl font-bold">{stats.total_documents}</div> <div className="text-2xl font-bold">{stats.documents.total}</div>
<p className="text-xs text-muted-foreground"> <p className="text-xs text-muted-foreground">
Across all collections Across all collections
</p> </p>
@@ -169,7 +181,7 @@ function RAGPageContent() {
<Upload className="h-4 w-4 text-muted-foreground" /> <Upload className="h-4 w-4 text-muted-foreground" />
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="text-2xl font-bold">{formatBytes(stats.total_size)}</div> <div className="text-2xl font-bold">{formatBytes(stats.storage.total_size_bytes)}</div>
<p className="text-xs text-muted-foreground"> <p className="text-xs text-muted-foreground">
Total indexed content Total indexed content
</p> </p>