Spaces:
Sleeping
Sleeping
Download services/errorService.ts from matthoffner/starchat-ui: direct link, hf CLI and curl.
- Browser
- Download file 923 Bytes
-
https://huggingface.co/spaces/matthoffner/starchat-ui/resolve/main/services/errorService.ts
- Command line
-
hf download hf://spaces/matthoffner/starchat-ui/services/errorService.ts
-
curl -L -o errorService.ts https://huggingface.co/spaces/matthoffner/starchat-ui/resolve/main/services/errorService.ts
923 Bytes
| import { useMemo } from 'react'; | |
| import { useTranslation } from 'next-i18next'; | |
| import { ErrorMessage } from '@/types/error'; | |
| const useErrorService = () => { | |
| const { t } = useTranslation('chat'); | |
| return { | |
| getModelsError: useMemo( | |
| () => (error: any) => { | |
| return !error | |
| ? null | |
| : ({ | |
| title: t('Error fetching models.'), | |
| code: error.status || 'unknown', | |
| messageLines: error.statusText | |
| ? [error.statusText] | |
| : [ | |
| t( | |
| 'Make sure your OpenAI API key is set in the bottom left of the sidebar.', | |
| ), | |
| t( | |
| 'If you completed this step, OpenAI may be experiencing issues.', | |
| ), | |
| ], | |
| } as ErrorMessage); | |
| }, | |
| [t], | |
| ), | |
| }; | |
| }; | |
| export default useErrorService; | |