feat: ✨ store and display gpu vendor in llm info drawer
This commit is contained in:
parent
172bdadd1a
commit
47adacb590
@ -7,17 +7,20 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
Stack,
|
Stack,
|
||||||
StackProps,
|
StackProps,
|
||||||
|
Text,
|
||||||
|
Title,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
|
import { IconCpu, IconRobotFace } from "@tabler/icons-react";
|
||||||
|
|
||||||
import { IconRobotFace } from "@tabler/icons-react";
|
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
import { useMLEngine } from "./MLEngineContext";
|
import { useMLEngine } from "./MLEngineContext";
|
||||||
|
|
||||||
function LLMPicker(props: StackProps) {
|
function LLMPicker(props: StackProps) {
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
|
|
||||||
const { loadingModel, activeModel, selectModel, modelList } = useMLEngine();
|
const { loadingModel, activeModel, selectModel, modelList, gpuVendor } =
|
||||||
|
useMLEngine();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack {...props}>
|
<Stack {...props}>
|
||||||
@ -61,17 +64,31 @@ function LLMPicker(props: StackProps) {
|
|||||||
radius="md"
|
radius="md"
|
||||||
opened={opened}
|
opened={opened}
|
||||||
onClose={close}
|
onClose={close}
|
||||||
title="Select model"
|
title={
|
||||||
|
<Group>
|
||||||
|
<IconRobotFace />
|
||||||
|
<Title size="h3">LLM</Title>
|
||||||
|
</Group>
|
||||||
|
}
|
||||||
position="bottom"
|
position="bottom"
|
||||||
size={200}
|
size={200}
|
||||||
>
|
>
|
||||||
<Select
|
<Stack>
|
||||||
data={modelList}
|
<Select
|
||||||
value={activeModel}
|
data={modelList}
|
||||||
onChange={(val) => val && selectModel(val)}
|
value={activeModel}
|
||||||
searchable
|
onChange={(val) => val && selectModel(val)}
|
||||||
clearable
|
searchable
|
||||||
/>
|
clearable
|
||||||
|
hiddenFrom="sm"
|
||||||
|
/>
|
||||||
|
{gpuVendor && (
|
||||||
|
<Group>
|
||||||
|
<IconCpu />
|
||||||
|
<Text>{gpuVendor}</Text>
|
||||||
|
</Group>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
@ -54,6 +54,7 @@ const modelList = [
|
|||||||
type MLEngineContext = {
|
type MLEngineContext = {
|
||||||
activeModel: string | null;
|
activeModel: string | null;
|
||||||
selectedModel: string | null;
|
selectedModel: string | null;
|
||||||
|
gpuVendor: string | null;
|
||||||
loadingModel: {
|
loadingModel: {
|
||||||
name: string;
|
name: string;
|
||||||
progress: number;
|
progress: number;
|
||||||
@ -69,6 +70,7 @@ type MLEngineContext = {
|
|||||||
const MLEngineContext = createContext<MLEngineContext>({
|
const MLEngineContext = createContext<MLEngineContext>({
|
||||||
activeModel: null,
|
activeModel: null,
|
||||||
selectedModel: null,
|
selectedModel: null,
|
||||||
|
gpuVendor: null,
|
||||||
loadingModel: null,
|
loadingModel: null,
|
||||||
engine: { current: null },
|
engine: { current: null },
|
||||||
selectModel: () => {},
|
selectModel: () => {},
|
||||||
@ -81,6 +83,7 @@ export function MLEngineContextProvider({ children }: { children: ReactNode }) {
|
|||||||
const [loadingModel, setLoadingModel] = useState<string | null>(null);
|
const [loadingModel, setLoadingModel] = useState<string | null>(null);
|
||||||
const [loadingProgress, setLoadingProgress] = useState<number | null>(null);
|
const [loadingProgress, setLoadingProgress] = useState<number | null>(null);
|
||||||
const [runningModel, setRunningModel] = useState<string | null>(null);
|
const [runningModel, setRunningModel] = useState<string | null>(null);
|
||||||
|
const [gpuVendor, setGpuVendor] = useState<string | null>(null);
|
||||||
|
|
||||||
const [selectedModel, setSelectedModel] = useLocalStorage<string | null>({
|
const [selectedModel, setSelectedModel] = useLocalStorage<string | null>({
|
||||||
key: "modelId",
|
key: "modelId",
|
||||||
@ -95,21 +98,20 @@ export function MLEngineContextProvider({ children }: { children: ReactNode }) {
|
|||||||
initProgress
|
initProgress
|
||||||
) => {
|
) => {
|
||||||
setLoadingProgress(initProgress.progress);
|
setLoadingProgress(initProgress.progress);
|
||||||
|
|
||||||
if (
|
|
||||||
initProgress.progress === 1 &&
|
|
||||||
initProgress.text.startsWith("Finish loading")
|
|
||||||
) {
|
|
||||||
setRunningModel(selectedModel);
|
|
||||||
setLoadingModel(null);
|
|
||||||
setLoadingProgress(null);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
engine.current = await CreateMLCEngine(
|
engine.current = await CreateMLCEngine(selectedModel, {
|
||||||
selectedModel,
|
initProgressCallback: initProgressCallback,
|
||||||
{ initProgressCallback: initProgressCallback } // engineConfig
|
});
|
||||||
);
|
|
||||||
|
setRunningModel(selectedModel);
|
||||||
|
setLoadingModel(null);
|
||||||
|
setLoadingProgress(null);
|
||||||
|
|
||||||
|
const gpuVendor = await engine.current?.getGPUVendor();
|
||||||
|
if (gpuVendor) {
|
||||||
|
setGpuVendor(gpuVendor);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
@ -119,6 +121,7 @@ export function MLEngineContextProvider({ children }: { children: ReactNode }) {
|
|||||||
setRunningModel,
|
setRunningModel,
|
||||||
setLoadingModel,
|
setLoadingModel,
|
||||||
setLoadingProgress,
|
setLoadingProgress,
|
||||||
|
setGpuVendor,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -131,6 +134,7 @@ export function MLEngineContextProvider({ children }: { children: ReactNode }) {
|
|||||||
: null,
|
: null,
|
||||||
activeModel: runningModel,
|
activeModel: runningModel,
|
||||||
selectedModel,
|
selectedModel,
|
||||||
|
gpuVendor,
|
||||||
selectModel: setSelectedModel,
|
selectModel: setSelectedModel,
|
||||||
modelList,
|
modelList,
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user