display lastModelName at the top (WorkHeader)

This commit is contained in:
josc146 2023-11-20 23:27:44 +08:00
parent 41e5bd5eb8
commit 66e43c9d9b
5 changed files with 17 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import { ConfigSelector } from './ConfigSelector';
import { RunButton } from './RunButton';
import { PresenceBadgeStatus } from '@fluentui/react-badge';
import { useTranslation } from 'react-i18next';
import { useMediaQuery } from 'usehooks-ts';
const statusText = {
[ModelStatus.Offline]: 'Offline',
@ -23,6 +24,7 @@ const badgeStatus: { [modelStatus: number]: PresenceBadgeStatus } = {
export const WorkHeader: FC = observer(() => {
const { t } = useTranslation();
const mq = useMediaQuery('(min-width: 640px)');
const port = commonStore.getCurrentModelConfig().apiParameters.apiPort;
return commonStore.platform === 'web' ?
@ -33,6 +35,10 @@ export const WorkHeader: FC = observer(() => {
<PresenceBadge status={badgeStatus[commonStore.status.status]} />
<Text size={100}>{t('Model Status') + ': ' + t(statusText[commonStore.status.status])}</Text>
</div>
{commonStore.lastModelName && mq &&
<Text size={100}>
{commonStore.lastModelName}
</Text>}
<div className="flex items-center gap-2">
<ConfigSelector size="small" />
<RunButton iconMode />

View File

@ -352,6 +352,8 @@ const ChatPanel: FC = observer(() => {
console.debug('json error', error);
return;
}
if (data.model)
commonStore.setLastModelName(data.model);
if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) {
answer += data.choices[0]?.delta?.content || '';
commonStore.conversation[answerId!].content = answer;

View File

@ -114,6 +114,8 @@ const CompletionPanel: FC = observer(() => {
console.debug('json error', error);
return;
}
if (data.model)
commonStore.setLastModelName(data.model);
if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) {
answer += data.choices[0]?.text || data.choices[0]?.delta?.content || '';
setPrompt(prompt + answer.replace(/\s+$/, '') + params.injectEnd.replaceAll('\\n', '\n'));

View File

@ -169,6 +169,8 @@ const CompositionPanel: FC = observer(() => {
console.debug('json error', error);
return;
}
if (data.model)
commonStore.setLastModelName(data.model);
if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) {
answer += data.choices[0]?.text || data.choices[0]?.delta?.content || '';
setPrompt(prompt + answer.replace(/\s+$/, ''));

View File

@ -51,6 +51,7 @@ class CommonStore {
monitorData: MonitorData | null = null;
depComplete: boolean = false;
platform: Platform = 'windows';
lastModelName: string = '';
// presets manager
editingPreset: Preset | null = null;
presets: Preset[] = [];
@ -232,6 +233,10 @@ class CommonStore {
this.about = value;
};
setLastModelName(value: string) {
this.lastModelName = value;
}
setDepComplete = (value: boolean, inSaveCache: boolean = true) => {
this.depComplete = value;
if (inSaveCache)