2023-05-05 15:23:34 +00:00
|
|
|
import {Button, CompoundButton, Dropdown, Link, Option, Text} from '@fluentui/react-components';
|
2023-05-04 15:55:24 +00:00
|
|
|
import React, {FC, ReactElement} from 'react';
|
2023-05-13 12:15:18 +00:00
|
|
|
import banner from '../assets/images/banner.jpg';
|
2023-05-04 15:55:24 +00:00
|
|
|
import {
|
|
|
|
Chat20Regular,
|
|
|
|
DataUsageSettings20Regular,
|
|
|
|
DocumentSettings20Regular,
|
|
|
|
Storage20Regular
|
|
|
|
} from '@fluentui/react-icons';
|
2023-05-05 05:41:54 +00:00
|
|
|
import {useNavigate} from 'react-router';
|
2023-05-07 14:48:52 +00:00
|
|
|
import commonStore, {ModelStatus} from '../stores/commonStore';
|
|
|
|
import {observer} from 'mobx-react-lite';
|
2023-05-06 15:39:23 +00:00
|
|
|
import {StartServer} from '../../wailsjs/go/backend_golang/App';
|
2023-05-04 15:55:24 +00:00
|
|
|
|
|
|
|
type NavCard = {
|
|
|
|
label: string;
|
|
|
|
desc: string;
|
|
|
|
path: string;
|
|
|
|
icon: ReactElement;
|
|
|
|
};
|
|
|
|
|
2023-05-05 05:41:54 +00:00
|
|
|
export const navCards: NavCard[] = [
|
2023-05-04 15:55:24 +00:00
|
|
|
{
|
|
|
|
label: 'Chat',
|
|
|
|
desc: 'Go to chat page',
|
|
|
|
path: '/chat',
|
|
|
|
icon: <Chat20Regular/>
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Configs',
|
|
|
|
desc: 'Manage your configs',
|
|
|
|
path: '/configs',
|
|
|
|
icon: <DocumentSettings20Regular/>
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Models',
|
|
|
|
desc: 'Manage models',
|
|
|
|
path: '/models',
|
|
|
|
icon: <DataUsageSettings20Regular/>
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Train',
|
|
|
|
desc: '',
|
|
|
|
path: '/train',
|
|
|
|
icon: <Storage20Regular/>
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2023-05-07 14:48:52 +00:00
|
|
|
const mainButtonText = {
|
|
|
|
[ModelStatus.Offline]: 'Run',
|
|
|
|
[ModelStatus.Starting]: 'Starting',
|
|
|
|
[ModelStatus.Loading]: 'Loading',
|
|
|
|
[ModelStatus.Working]: 'Stop'
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Home: FC = observer(() => {
|
2023-05-04 15:55:24 +00:00
|
|
|
const [selectedConfig, setSelectedConfig] = React.useState('RWKV-3B-4G MEM');
|
|
|
|
|
2023-05-05 05:41:54 +00:00
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
const onClickNavCard = (path: string) => {
|
|
|
|
navigate({pathname: path});
|
|
|
|
};
|
|
|
|
|
2023-05-07 14:48:52 +00:00
|
|
|
const onClickMainButton = async () => {
|
|
|
|
if (commonStore.modelStatus === ModelStatus.Offline) {
|
2023-05-13 12:15:18 +00:00
|
|
|
commonStore.setModelStatus(ModelStatus.Starting);
|
2023-05-07 14:48:52 +00:00
|
|
|
StartServer('cuda fp16i8', 'E:\\RWKV-4-Raven-3B-v10-Eng49%-Chn50%-Other1%-20230419-ctx4096.pth');
|
|
|
|
|
|
|
|
let timeoutCount = 5;
|
|
|
|
let loading = false;
|
|
|
|
const intervalId = setInterval(() => {
|
|
|
|
fetch('http://127.0.0.1:8000')
|
|
|
|
.then(r => {
|
|
|
|
if (r.ok && !loading) {
|
|
|
|
clearInterval(intervalId);
|
2023-05-13 12:15:18 +00:00
|
|
|
commonStore.setModelStatus(ModelStatus.Loading);
|
2023-05-07 14:48:52 +00:00
|
|
|
loading = true;
|
|
|
|
fetch('http://127.0.0.1:8000/update-config', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify({})
|
|
|
|
}).then(async (r) => {
|
|
|
|
if (r.ok)
|
2023-05-13 12:15:18 +00:00
|
|
|
commonStore.setModelStatus(ModelStatus.Working);
|
2023-05-07 14:48:52 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}).catch(() => {
|
|
|
|
if (timeoutCount <= 0) {
|
|
|
|
clearInterval(intervalId);
|
2023-05-13 12:15:18 +00:00
|
|
|
commonStore.setModelStatus(ModelStatus.Offline);
|
2023-05-07 14:48:52 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
timeoutCount--;
|
|
|
|
}, 1000);
|
|
|
|
} else {
|
2023-05-13 12:15:18 +00:00
|
|
|
commonStore.setModelStatus(ModelStatus.Offline);
|
2023-05-07 14:48:52 +00:00
|
|
|
fetch('http://127.0.0.1:8000/exit', {method: 'POST'});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-05-04 15:55:24 +00:00
|
|
|
return (
|
|
|
|
<div className="flex flex-col justify-between h-full">
|
2023-05-13 12:15:18 +00:00
|
|
|
<img className="rounded-xl select-none hidden sm:block" src={banner}/>
|
2023-05-04 15:55:24 +00:00
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
<Text size={600} weight="medium">Introduction</Text>
|
2023-05-06 13:32:14 +00:00
|
|
|
<div className="h-40 overflow-y-auto p-1">
|
2023-05-04 15:55:24 +00:00
|
|
|
RWKV is an RNN with Transformer-level LLM performance, which can also be directly trained like a GPT
|
|
|
|
transformer (parallelizable). And it's 100% attention-free. You only need the hidden state at position t to
|
|
|
|
compute the state at position t+1. You can use the "GPT" mode to quickly compute the hidden state for the
|
|
|
|
"RNN" mode.
|
|
|
|
<br/>
|
|
|
|
So it's combining the best of RNN and transformer - great performance, fast inference, saves VRAM, fast
|
|
|
|
training, "infinite" ctx_len, and free sentence embedding (using the final hidden state).
|
2023-05-06 12:17:39 +00:00
|
|
|
</div>
|
2023-05-04 15:55:24 +00:00
|
|
|
</div>
|
2023-05-06 12:17:39 +00:00
|
|
|
<div className="grid grid-cols-2 sm:grid-cols-4 gap-5">
|
2023-05-04 15:55:24 +00:00
|
|
|
{navCards.map(({label, path, icon, desc}, index) => (
|
2023-05-06 12:17:39 +00:00
|
|
|
<CompoundButton icon={icon} secondaryContent={desc} key={`${path}-${index}`} value={path}
|
2023-05-05 05:41:54 +00:00
|
|
|
size="large" onClick={() => onClickNavCard(path)}>
|
2023-05-04 15:55:24 +00:00
|
|
|
{label}
|
|
|
|
</CompoundButton>
|
|
|
|
))}
|
|
|
|
</div>
|
2023-05-06 12:17:39 +00:00
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
<div className="flex flex-row-reverse sm:fixed bottom-2 right-2">
|
|
|
|
<div className="flex gap-3">
|
|
|
|
<Dropdown style={{minWidth: 0}}
|
|
|
|
placeholder="Config"
|
|
|
|
value={selectedConfig}
|
|
|
|
onOptionSelect={(_, data) => {
|
|
|
|
if (data.optionValue)
|
|
|
|
setSelectedConfig(data.optionValue);
|
|
|
|
}}>
|
|
|
|
<Option id="item-1" key="item-1">
|
|
|
|
RWKV-3B-4G MEM
|
|
|
|
</Option>
|
|
|
|
<Option id="item-2" key="item-2">
|
|
|
|
Item 2
|
|
|
|
</Option>
|
|
|
|
<Option id="item-3" key="item-3">
|
|
|
|
Item 3
|
|
|
|
</Option>
|
|
|
|
<Option id="item-4" key="item-4">
|
|
|
|
Item 4
|
|
|
|
</Option>
|
|
|
|
</Dropdown>
|
2023-05-07 14:48:52 +00:00
|
|
|
<Button disabled={commonStore.modelStatus === ModelStatus.Starting} appearance="primary" size="large"
|
|
|
|
onClick={onClickMainButton}>
|
|
|
|
{mainButtonText[commonStore.modelStatus]}
|
|
|
|
</Button>
|
2023-05-06 12:17:39 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-04 15:55:24 +00:00
|
|
|
<div className="flex gap-4 items-end">
|
|
|
|
Version: 1.0.0
|
|
|
|
<Link>Help</Link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2023-05-07 14:48:52 +00:00
|
|
|
});
|