Skip to content

Commit

Permalink
💄 style(settings): improve LLM connection checker style (lobehub#1222)
Browse files Browse the repository at this point in the history
* 🚸 perf(check): improve user experience/usability
* 🚸 perf(check): adapt to mobile devices


Co-authored-by: QuentinHsu <xuquentinyang@gmail.com>
  • Loading branch information
arvinxx and QuentinHsu committed Feb 5, 2024
1 parent 7002489 commit 8c349a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/app/settings/llm/LLM/Checker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import { useIsMobile } from '@/hooks/useIsMobile';
import { chatService } from '@/services/chat';
import { ChatMessageError } from '@/types/message';

Expand Down Expand Up @@ -52,13 +53,11 @@ const Checker = memo<CheckerProps>(({ checkModel }) => {
setPass(true);
}
};
return (
<Flexbox gap={8}>
<Flexbox align={'center'} gap={12} horizontal>
<Button loading={loading} onClick={checkConnection}>
{t('llm.OpenAI.check.button')}
</Button>
const isMobile = useIsMobile();

return (
<Flexbox align={isMobile ? 'flex-start' : 'flex-end'} gap={8}>
<Flexbox align={'center'} direction={isMobile ? 'horizontal-reverse' : 'horizontal'} gap={12}>
{pass && (
<Flexbox gap={4} horizontal>
<CheckCircleFilled
Expand All @@ -69,14 +68,16 @@ const Checker = memo<CheckerProps>(({ checkModel }) => {
{t('llm.OpenAI.check.pass')}
</Flexbox>
)}
<Button loading={loading} onClick={checkConnection}>
{t('llm.OpenAI.check.button')}
</Button>
</Flexbox>

{error && (
<Flexbox gap={8}>
<Flexbox gap={8} style={{ maxWidth: '600px', width: '100%' }}>
<Alert
banner
extra={
<Flexbox style={{ maxWidth: 600 }}>
<Flexbox>
<Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
{JSON.stringify(error.body, null, 2)}
</Highlighter>
Expand Down
2 changes: 1 addition & 1 deletion src/app/settings/llm/LLM/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const LLM = memo(() => {
children: <Checker checkModel={!useAzure} />,
desc: t('llm.OpenAI.check.desc'),
label: t('llm.OpenAI.check.title'),
minWidth: undefined,
minWidth: '100%',
},
// {
// children: useAzure ? <Flexbox>{t('llm.OpenAI.models.notSupport')}</Flexbox> : <ModelList />,
Expand Down

0 comments on commit 8c349a1

Please sign in to comment.