diff --git a/src/features/Conversation/Error/OllamaBizError/SetupGuide.tsx b/src/features/Conversation/Error/OllamaBizError/SetupGuide.tsx index 0586bba90adf..78c14f3f6c1f 100644 --- a/src/features/Conversation/Error/OllamaBizError/SetupGuide.tsx +++ b/src/features/Conversation/Error/OllamaBizError/SetupGuide.tsx @@ -7,6 +7,8 @@ import { memo } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { Flexbox } from 'react-layout-kit'; +import { ErrorActionContainer } from '@/features/Conversation/Error/style'; + const useStyles = createStyles(({ css, prefixCls, token }) => ({ steps: css` margin-top: 32px; @@ -30,187 +32,189 @@ const SetupGuide = memo(() => { const { styles } = useStyles(); const { t } = useTranslation('modelProvider'); return ( - - 请确认你已经开启 Ollama ,如果没有安装 Ollama ,请前往官网 - 下载 - - ), - status: 'process', - title: t('ollama.setup.install.title'), - }, - { - description: ( - - {t('ollama.setup.cors.description')} + + + 请确认你已经开启 Ollama ,如果没有安装 Ollama ,请前往官网 + 下载 + + ), + status: 'process', + title: t('ollama.setup.install.title'), + }, + { + description: ( + + {t('ollama.setup.cors.description')} + + {t('ollama.setup.cors.macos')} + + {/* eslint-disable-next-line react/no-unescaped-entities */} + launchctl setenv OLLAMA_ORIGINS "*" + + {t('ollama.setup.cors.reboot')} + + + ), + status: 'process', + title: t('ollama.setup.cors.title'), + }, + ]} + size={'small'} + /> + ), + key: 'macos', + label: 'macOS', + }, + { + children: ( + + 请确认你已经开启 Ollama ,如果没有安装 Ollama ,请前往官网 + 下载 + + ), + status: 'process', + title: t('ollama.setup.install.title'), + }, + { + description: ( + + {t('ollama.setup.cors.description')} +
{t('ollama.setup.cors.windows')}
+
{t('ollama.setup.cors.reboot')}
+
+ ), + status: 'process', + title: t('ollama.setup.cors.title'), + }, + ]} + size={'small'} + /> + ), + key: 'windows', + label: t('ollama.setup.install.windowsTab'), + }, + { + children: ( + - {t('ollama.setup.cors.macos')} + {t('ollama.setup.install.linux.command')} - {/* eslint-disable-next-line react/no-unescaped-entities */} - launchctl setenv OLLAMA_ORIGINS "*" + curl -fsSL https://ollama.com/install.sh | sh - {t('ollama.setup.cors.reboot')} +
+ + 或者,你也可以参考 + + Linux 手动安装指南 + + 。 + +
- - ), - status: 'process', - title: t('ollama.setup.cors.title'), - }, - ]} - size={'small'} - /> - ), - key: 'macos', - label: 'macOS', - }, - { - children: ( - - 请确认你已经开启 Ollama ,如果没有安装 Ollama ,请前往官网 - 下载 - - ), - status: 'process', - title: t('ollama.setup.install.title'), - }, - { - description: ( - - {t('ollama.setup.cors.description')} -
{t('ollama.setup.cors.windows')}
-
{t('ollama.setup.cors.reboot')}
-
- ), - status: 'process', - title: t('ollama.setup.cors.title'), - }, - ]} - size={'small'} - /> - ), - key: 'windows', - label: t('ollama.setup.install.windowsTab'), - }, - { - children: ( - - {t('ollama.setup.install.linux.command')} - - curl -fsSL https://ollama.com/install.sh | sh - -
- - 或者,你也可以参考 - - Linux 手动安装指南 - - 。 - -
- - ), - status: 'process', - title: t('ollama.setup.install.title'), - }, - { - description: ( - -
{t('ollama.setup.cors.description')}
+ ), + status: 'process', + title: t('ollama.setup.install.title'), + }, + { + description: ( + +
{t('ollama.setup.cors.description')}
-
{t('ollama.setup.cors.linux.systemd')}
- {/* eslint-disable-next-line react/no-unescaped-entities */} - sudo systemctl edit ollama.service - {t('ollama.setup.cors.linux.env')} - {t('ollama.setup.cors.linux.systemd')} + {/* eslint-disable-next-line react/no-unescaped-entities */} + sudo systemctl edit ollama.service + {t('ollama.setup.cors.linux.env')} + - {t('ollama.setup.cors.linux.reboot')} -
- ), - status: 'process', - title: t('ollama.setup.cors.title'), - }, - ]} - size={'small'} - /> - ), - key: 'linux', - label: 'Linux', - }, - { - children: ( - - {t('ollama.setup.install.description')} -
{t('ollama.setup.install.docker')}
- docker pull ollama/ollama -
- ), - status: 'process', - title: t('ollama.setup.install.title'), - }, - { - description: ( - - {t('ollama.setup.cors.description')} - - {/* eslint-disable-next-line react/no-unescaped-entities */} - docker run -d --gpus=all -v ollama:/root/.ollama -e OLLAMA_ORIGINS="*" -p - 11434:11434 --name ollama ollama/ollama - - - ), - status: 'process', - title: t('ollama.setup.cors.title'), - }, - ]} - size={'small'} - /> - ), - key: 'docker', - label: 'Docker', - }, - ]} - /> + fileName={'ollama.service'} + fullFeatured + language={'bash'} + showLanguage + /> + {t('ollama.setup.cors.linux.reboot')} + + ), + status: 'process', + title: t('ollama.setup.cors.title'), + }, + ]} + size={'small'} + /> + ), + key: 'linux', + label: 'Linux', + }, + { + children: ( + + {t('ollama.setup.install.description')} +
{t('ollama.setup.install.docker')}
+ docker pull ollama/ollama + + ), + status: 'process', + title: t('ollama.setup.install.title'), + }, + { + description: ( + + {t('ollama.setup.cors.description')} + + {/* eslint-disable-next-line react/no-unescaped-entities */} + docker run -d --gpus=all -v ollama:/root/.ollama -e OLLAMA_ORIGINS="*" -p + 11434:11434 --name ollama ollama/ollama + + + ), + status: 'process', + title: t('ollama.setup.cors.title'), + }, + ]} + size={'small'} + /> + ), + key: 'docker', + label: 'Docker', + }, + ]} + /> + ); }); diff --git a/src/features/Conversation/Error/style.tsx b/src/features/Conversation/Error/style.tsx index ee7d6d6d0355..e3704ce546a5 100644 --- a/src/features/Conversation/Error/style.tsx +++ b/src/features/Conversation/Error/style.tsx @@ -1,7 +1,7 @@ import { Avatar } from '@lobehub/ui'; import { createStyles } from 'antd-style'; import { ReactNode, memo } from 'react'; -import { Center, Flexbox } from 'react-layout-kit'; +import { Center, CenterProps, Flexbox } from 'react-layout-kit'; export const useStyles = createStyles(({ css, token }) => ({ container: css` @@ -14,38 +14,63 @@ export const useStyles = createStyles(({ css, token }) => ({ color: ${token.colorTextTertiary}; text-align: center; `, + form: css` + width: 100%; + max-width: 300px; + `, })); -export const ErrorActionContainer = memo<{ children: ReactNode }>(({ children }) => { - const { styles } = useStyles(); +export const ErrorActionContainer = memo( + ({ children, className, gap = 24, padding = 24, ...rest }) => { + const { cx, styles } = useStyles(); - return ( -
- {children} -
- ); -}); + return ( +
+ {children} +
+ ); + }, +); -export const FormAction = memo<{ - avatar: ReactNode; - background?: string; - children: ReactNode; - description: string; - title: string; -}>(({ children, background, title, description, avatar }) => { - const { styles, theme } = useStyles(); +export const FormAction = memo< + { + animation?: boolean; + avatar: ReactNode; + background?: string; + description: string; + title: string; + } & CenterProps +>( + ({ + children, + background, + title, + description, + avatar, + animation, + className, + gap = 16, + ...rest + }) => { + const { cx, styles, theme } = useStyles(); - return ( -
- - {title} - {description} - {children} -
- ); -}); + return ( +
+ + + + {title} + + {description} + + {children} +
+ ); + }, +);