improve chat page

This commit is contained in:
josc146 2023-05-19 21:24:09 +08:00
parent 5e76493da2
commit 21c200d767
2 changed files with 20 additions and 3 deletions

View File

@ -68,5 +68,7 @@
"Send": "发送", "Send": "发送",
"Type your message here": "在此输入消息", "Type your message here": "在此输入消息",
"Copy": "复制", "Copy": "复制",
"Read Aloud": "朗读" "Read Aloud": "朗读",
"Hello! I'm RWKV, an open-source and commercially available large language model.": "你好! 我是RWKV, 一个开源可商用的大语言模型.",
"This tools API is compatible with OpenAI API. It can be used with any ChatGPT tool you like. Go to the settings of some ChatGPT tool, replace the 'https://api.openai.com' part in the API address with '": "本工具的API与OpenAI API兼容. 因此可以配合任意你喜欢的ChatGPT工具使用. 打开某个ChatGPT工具的设置, 将API地址中的'https://api.openai.com'部分替换为'"
} }

View File

@ -47,8 +47,19 @@ type Conversations = {
const ChatPanel: FC = observer(() => { const ChatPanel: FC = observer(() => {
const {t} = useTranslation(); const {t} = useTranslation();
const [message, setMessage] = useState(''); const [message, setMessage] = useState('');
const [conversations, setConversations] = useState<Conversations>({}); const [conversations, setConversations] = useState<Conversations>({
const [conversationsOrder, setConversationsOrder] = useState<string[]>([]); 'welcome': {
sender: botName,
type: MessageType.Normal,
color: 'colorful',
avatarImg: logo,
time: new Date().toISOString(),
content: t('Hello! I\'m RWKV, an open-source and commercially available large language model.'),
side: 'left',
done: true
}
});
const [conversationsOrder, setConversationsOrder] = useState<string[]>(['welcome']);
const bodyRef = useRef<HTMLDivElement>(null); const bodyRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLTextAreaElement>(null); const inputRef = useRef<HTMLTextAreaElement>(null);
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort; const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
@ -284,6 +295,7 @@ const badgeStatus: { [modelStatus: number]: PresenceBadgeStatus } = {
export const Chat: FC = observer(() => { export const Chat: FC = observer(() => {
const {t} = useTranslation(); const {t} = useTranslation();
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
return ( return (
<div className="flex flex-col gap-1 p-2 h-full overflow-hidden"> <div className="flex flex-col gap-1 p-2 h-full overflow-hidden">
@ -297,6 +309,9 @@ export const Chat: FC = observer(() => {
<RunButton iconMode/> <RunButton iconMode/>
</div> </div>
</div> </div>
<Text size={100}>
{t('This tools API is compatible with OpenAI API. It can be used with any ChatGPT tool you like. Go to the settings of some ChatGPT tool, replace the \'https://api.openai.com\' part in the API address with \'') + `http://127.0.0.1:${port}` + '\'.'}
</Text>
<Divider style={{flexGrow: 0}}/> <Divider style={{flexGrow: 0}}/>
<ChatPanel/> <ChatPanel/>
</div> </div>