feat: ✨ make llm picker responsive
This commit is contained in:
parent
420406f9a4
commit
849e41bc06
@ -1,20 +1,26 @@
|
|||||||
import {
|
import {
|
||||||
|
ActionIcon,
|
||||||
|
Drawer,
|
||||||
Group,
|
Group,
|
||||||
Indicator,
|
Indicator,
|
||||||
Progress,
|
Progress,
|
||||||
Select,
|
Select,
|
||||||
Stack,
|
Stack,
|
||||||
|
StackProps,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
|
|
||||||
import { IconRobotFace } from "@tabler/icons-react";
|
import { IconRobotFace } from "@tabler/icons-react";
|
||||||
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
import { useMLEngine } from "./MLEngineContext";
|
import { useMLEngine } from "./MLEngineContext";
|
||||||
|
|
||||||
function LLMPicker() {
|
function LLMPicker(props: StackProps) {
|
||||||
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
|
|
||||||
const { loadingModel, activeModel, selectModel, modelList } = useMLEngine();
|
const { loadingModel, activeModel, selectModel, modelList } = useMLEngine();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<Stack {...props}>
|
||||||
<Group>
|
<Group>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={
|
label={
|
||||||
@ -29,7 +35,9 @@ function LLMPicker() {
|
|||||||
color={activeModel ? (loadingModel ? "" : "green") : "orange"}
|
color={activeModel ? (loadingModel ? "" : "green") : "orange"}
|
||||||
processing={loadingModel !== null}
|
processing={loadingModel !== null}
|
||||||
>
|
>
|
||||||
|
<ActionIcon variant="subtle" onClick={open}>
|
||||||
<IconRobotFace />
|
<IconRobotFace />
|
||||||
|
</ActionIcon>
|
||||||
</Indicator>
|
</Indicator>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
{modelList && (
|
{modelList && (
|
||||||
@ -37,14 +45,34 @@ function LLMPicker() {
|
|||||||
data={modelList}
|
data={modelList}
|
||||||
value={activeModel}
|
value={activeModel}
|
||||||
onChange={(val) => val && selectModel(val)}
|
onChange={(val) => val && selectModel(val)}
|
||||||
|
placeholder="Select a model..."
|
||||||
searchable
|
searchable
|
||||||
clearable
|
clearable
|
||||||
|
visibleFrom="sm"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
{loadingModel && (
|
{loadingModel && (
|
||||||
<Progress value={loadingModel.progress} striped animated />
|
<Progress value={loadingModel.progress} striped animated />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<Drawer
|
||||||
|
offset={8}
|
||||||
|
radius="md"
|
||||||
|
opened={opened}
|
||||||
|
onClose={close}
|
||||||
|
title="Select model"
|
||||||
|
position="bottom"
|
||||||
|
size={200}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
data={modelList}
|
||||||
|
value={activeModel}
|
||||||
|
onChange={(val) => val && selectModel(val)}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</Drawer>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ const modelList = [
|
|||||||
|
|
||||||
type MLEngineContext = {
|
type MLEngineContext = {
|
||||||
activeModel: string | null;
|
activeModel: string | null;
|
||||||
|
selectedModel: string | null;
|
||||||
loadingModel: {
|
loadingModel: {
|
||||||
name: string;
|
name: string;
|
||||||
progress: number;
|
progress: number;
|
||||||
@ -67,6 +68,7 @@ type MLEngineContext = {
|
|||||||
|
|
||||||
const MLEngineContext = createContext<MLEngineContext>({
|
const MLEngineContext = createContext<MLEngineContext>({
|
||||||
activeModel: null,
|
activeModel: null,
|
||||||
|
selectedModel: null,
|
||||||
loadingModel: null,
|
loadingModel: null,
|
||||||
engine: { current: null },
|
engine: { current: null },
|
||||||
selectModel: () => {},
|
selectModel: () => {},
|
||||||
@ -128,6 +130,7 @@ export function MLEngineContextProvider({ children }: { children: ReactNode }) {
|
|||||||
? { name: loadingModel, progress: loadingProgress }
|
? { name: loadingModel, progress: loadingProgress }
|
||||||
: null,
|
: null,
|
||||||
activeModel: runningModel,
|
activeModel: runningModel,
|
||||||
|
selectedModel,
|
||||||
selectModel: setSelectedModel,
|
selectModel: setSelectedModel,
|
||||||
modelList,
|
modelList,
|
||||||
}}
|
}}
|
||||||
|
@ -395,7 +395,8 @@ function Organizrr() {
|
|||||||
</Group>
|
</Group>
|
||||||
<ScrollArea offsetScrollbars>
|
<ScrollArea offsetScrollbars>
|
||||||
<Group wrap="nowrap" align="start">
|
<Group wrap="nowrap" align="start">
|
||||||
{form.values.files[activeFile]?.documents.map((d, idx) => (
|
{form.values.files[activeFile]?.documents.map(
|
||||||
|
(d, idx) => (
|
||||||
<Stack
|
<Stack
|
||||||
key={`${d.id}-${idx}`}
|
key={`${d.id}-${idx}`}
|
||||||
h={500}
|
h={500}
|
||||||
@ -460,7 +461,8 @@ function Organizrr() {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
{form.values.documents
|
{form.values.documents
|
||||||
.find(
|
.find(
|
||||||
(doc) =>
|
(doc) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user