From e7be86c61425873b4fa5a58317aba89974abb24f Mon Sep 17 00:00:00 2001 From: ali asaria Date: Mon, 27 May 2024 14:15:03 -0400 Subject: [PATCH] list python libraries in computer info panel --- src/renderer/components/Computer.tsx | 257 +++++++++++++-------- src/renderer/lib/transformerlab-api-sdk.ts | 5 + 2 files changed, 172 insertions(+), 90 deletions(-) diff --git a/src/renderer/components/Computer.tsx b/src/renderer/components/Computer.tsx index 90274d0f..fdbd5c9f 100644 --- a/src/renderer/components/Computer.tsx +++ b/src/renderer/components/Computer.tsx @@ -2,7 +2,17 @@ import Sheet from '@mui/joy/Sheet'; -import { Card, CardContent, Chip, Grid, Typography } from '@mui/joy'; +import { + Card, + CardContent, + Chip, + FormControl, + FormLabel, + Grid, + Input, + Table, + Typography, +} from '@mui/joy'; import { CalculatorIcon, @@ -13,6 +23,7 @@ import { LayoutIcon, MemoryStickIcon, RouterIcon, + SearchIcon, } from 'lucide-react'; import { BsGpuCard } from 'react-icons/bs'; @@ -22,6 +33,10 @@ import { PiMathOperationsFill } from 'react-icons/pi'; import { formatBytes } from 'renderer/lib/utils'; import { useServerStats } from 'renderer/lib/transformerlab-api-sdk'; +import useSWR from 'swr'; +import { useState } from 'react'; + +import * as chatAPI from 'renderer/lib/transformerlab-api-sdk'; function getSystemProperties() { const information = document.getElementById('info'); @@ -60,96 +75,117 @@ function ComputerCard({ children, title, description = '', chip = '', icon }) { ); } +const fetcher = (url) => fetch(url).then((res) => res.json()); + export default function Computer() { + const [searchText, setSearchText] = useState(''); + const { server, isLoading, isError } = useServerStats(); - if (server) { - return ( - <> - {/* {JSON.stringify(server)} */} - - Server Information - - - - - } - title="Machine" - description={`${server.os} - ${server.name}`} - > - CPU: {server.cpu_percent}%
- {server.cpu_count} Cores -
-
{' '} - - } title="Device"> - GPU: {server.gpu?.length === 0 ? '❌' : '✅'} -
- CUDA: {server?.device === 'cuda' ? '✅ ' : '❌ '} -
- CUDA Version: {server?.cuda_version} -
- Python MPS: {server?.device === 'mps' ? '✅ ' : '❌ '} -
-
{' '} - - } - title="GPU Specs" - image={undefined} - > - {server.gpu?.map((g) => { - return ( - <> - 🔥 {g.name} -
- {formatBytes(Math.round(g?.used_memory))} Used -
- {formatBytes(g.total_memory)} Total - - ); - })} -
- Used Memory:{' '} - {Math.round( - server.gpu[0]?.used_memory / server.gpu[0]?.total_memory - )} - % -
-
{' '} - - } title="Operating System"> - {server?.platform} - - - - } title="Memory"> - <> - - Total Memory: {formatBytes(server.memory?.total)} - - - Available: {formatBytes(server.memory?.available)} - - Percent: {server.memory?.percent}% - - - - - }> - Total: {formatBytes(server.disk?.total)} - Used:{' '} - {formatBytes(server.disk?.free)} - Free: {server.disk?.percent}% - - - - } title="Python Version"> - {server.python_version} - + const { data: pythonLibraries } = useSWR( + chatAPI.Endpoints.ServerInfo.PythonLibraries(), + fetcher + ); + + return ( + + {server && ( + <> + {/* {JSON.stringify(server)} */} + + Server Information + + + + + } + title="Machine" + description={`${server.os} - ${server.name}`} + > + CPU: {server.cpu_percent}%
+ {server.cpu_count} Cores +
+
{' '} + + } title="Device"> + GPU: {server.gpu?.length === 0 ? '❌' : '✅'} +
+ CUDA: {server?.device === 'cuda' ? '✅ ' : '❌ '} +
+ CUDA Version: {server?.cuda_version} +
+ Python MPS: {server?.device === 'mps' ? '✅ ' : '❌ '} +
+
{' '} + + } + title="GPU Specs" + image={undefined} + > + {server.gpu?.map((g) => { + return ( + <> + 🔥 {g.name} +
+ {formatBytes(Math.round(g?.used_memory))} Used +
+ {formatBytes(g.total_memory)} Total + + ); + })} +
+ Used Memory:{' '} + {Math.round( + server.gpu[0]?.used_memory / server.gpu[0]?.total_memory + )} + % +
+
{' '} + + } title="Operating System"> + {server?.platform} + + + + } title="Memory"> + <> + + Total Memory: {formatBytes(server.memory?.total)} + + + Available: {formatBytes(server.memory?.available)} + + Percent: {server.memory?.percent}% + + + + + }> + Total: {formatBytes(server.disk?.total)} - Used:{' '} + {formatBytes(server.disk?.free)} - Free:{' '} + {server.disk?.percent}% + + + + } title="Python Version"> + {server.python_version} + +
-
- {/*

System Properties in Electron

+ {/*

System Properties in Electron