mirror of
https://github.com/ivanfioravanti/chatbot-ollama.git
synced 2023-12-01 22:17:38 +03:00
27 lines
568 B
TypeScript
27 lines
568 B
TypeScript
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
|
|
} as ErrorMessage);
|
|
},
|
|
[t],
|
|
),
|
|
};
|
|
};
|
|
|
|
export default useErrorService;
|