690618:2126 239 #01
This commit is contained in:
@@ -17,7 +17,11 @@ export interface VramStatus {
|
||||
totalVramMb: number;
|
||||
usedVramMb: number;
|
||||
freeVramMb: number;
|
||||
loadedModels: string[];
|
||||
loadedModels: Array<{
|
||||
modelId: string;
|
||||
modelName: string;
|
||||
vramUsageMB: number;
|
||||
}>;
|
||||
hasCapacity: boolean;
|
||||
}
|
||||
|
||||
@@ -102,7 +106,11 @@ export class VramMonitorService {
|
||||
}>;
|
||||
}>(`${this.ollamaUrl}/api/ps`, { timeout: 3000 });
|
||||
const models = response.data?.models ?? [];
|
||||
const loadedModels = models.map((m) => m.name);
|
||||
const loadedModels = models.map((m) => ({
|
||||
modelId: m.name,
|
||||
modelName: m.name,
|
||||
vramUsageMB: Math.round((m.size_vram || 0) / (1024 * 1024)),
|
||||
}));
|
||||
const headroom = await this.getVramHeadroom();
|
||||
return {
|
||||
totalVramMb: headroom.totalMb,
|
||||
|
||||
@@ -120,7 +120,13 @@ describe('VramMonitorService', () => {
|
||||
},
|
||||
});
|
||||
const status = await service.getVramStatus(4000);
|
||||
expect(status.loadedModels).toContain('np-dms-ai:latest');
|
||||
expect(status.loadedModels).toEqual([
|
||||
{
|
||||
modelId: 'np-dms-ai:latest',
|
||||
modelName: 'np-dms-ai:latest',
|
||||
vramUsageMB: 3072,
|
||||
},
|
||||
]);
|
||||
expect(status.totalVramMb).toBe(8192);
|
||||
expect(status.hasCapacity).toBe(true); // 8192MB - 3072MB = 5120MB free > 4000MB required
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user