diff --git a/components/Chat/Chat.tsx b/components/Chat/Chat.tsx index 3fb9f0c..1a6710e 100644 --- a/components/Chat/Chat.tsx +++ b/components/Chat/Chat.tsx @@ -6,9 +6,10 @@ import { OpenAIModel, } from '@/types'; import { throttle } from '@/utils'; -import { IconClearAll, IconSettings } from '@tabler/icons-react'; +import { IconClearAll, IconKey, IconSettings } from '@tabler/icons-react'; import { useTranslation } from 'next-i18next'; import { FC, memo, MutableRefObject, useEffect, useRef, useState } from 'react'; +import { Spinner } from '../Global/Spinner'; import { ChatInput } from './ChatInput'; import { ChatLoader } from './ChatLoader'; import { ChatMessage } from './ChatMessage'; @@ -110,24 +111,31 @@ export const Chat: FC = memo(
{!(apiKey || serverSideApiKeyIsSet) ? (
+
+ +
{t('OpenAI API Key Required')}
- {t( - 'Please set your OpenAI API key in the bottom left of the sidebar.', - )} -
-
- {t("If you don't have an OpenAI API key, you can get one here: ")} - - openai.com - +
+ {t( + 'Please set your OpenAI API key in the bottom left of the sidebar.', + )} +
+
+ {t( + "If you don't have an OpenAI API key, you can get one here: ", + )} + + openai.com + +
) : modelError ? ( @@ -142,11 +150,17 @@ export const Chat: FC = memo( <>
- {models.length === 0 ? t('Loading...') : 'Chatbot UI'} + {models.length === 0 ? ( +
+ +
+ ) : ( + 'Chatbot UI' + )}
{models.length > 0 && ( -
+
= ({ error }) => { return ( -
-
- {error.title} {error.code ? ({error.code}) : ''} +
+
+
+
{error.title}
{error.messageLines.map((line, index) => ( -
+
{' '} {line}{' '}
))} +
+ {error.code ? Code: {error.code} : ''} +
); }; diff --git a/components/Global/Spinner.tsx b/components/Global/Spinner.tsx new file mode 100644 index 0000000..8ae7313 --- /dev/null +++ b/components/Global/Spinner.tsx @@ -0,0 +1,32 @@ +import { FC } from 'react'; + +interface Props { + size?: string; + className?: string; +} + +export const Spinner: FC = ({ size = '1em', className="" }) => { + return ( + + + + + + + + + + + ); +}; diff --git a/components/Sidebar/ClearConversations.tsx b/components/Sidebar/ClearConversations.tsx index 4e5551f..ba7c4b3 100644 --- a/components/Sidebar/ClearConversations.tsx +++ b/components/Sidebar/ClearConversations.tsx @@ -18,7 +18,7 @@ export const ClearConversations: FC = ({ onClearConversations }) => { }; return isConfirming ? ( -
+
diff --git a/components/Sidebar/Key.tsx b/components/Sidebar/Key.tsx index 1ca74ae..82aac8f 100644 --- a/components/Sidebar/Key.tsx +++ b/components/Sidebar/Key.tsx @@ -30,7 +30,7 @@ export const Key: FC = ({ apiKey, onApiKeyChange }) => { setNewKey(e.target.value)} diff --git a/components/Sidebar/Sidebar.tsx b/components/Sidebar/Sidebar.tsx index 292cfcf..31a3bc6 100644 --- a/components/Sidebar/Sidebar.tsx +++ b/components/Sidebar/Sidebar.tsx @@ -202,6 +202,7 @@ export const Sidebar: FC = ({ void; onApiKeyChange: (apiKey: string) => void; onClearConversations: () => void; @@ -23,6 +24,7 @@ interface Props { export const SidebarSettings: FC = ({ lightMode, apiKey, + conversationsCount, onToggleLightMode, onApiKeyChange, onClearConversations, @@ -32,7 +34,9 @@ export const SidebarSettings: FC = ({ const { t } = useTranslation('sidebar'); return (
- + {conversationsCount > 0 ? ( + + ) : null} diff --git a/public/locales/ru/chat.json b/public/locales/ru/chat.json index 218a7a1..2140d8e 100644 --- a/public/locales/ru/chat.json +++ b/public/locales/ru/chat.json @@ -6,7 +6,7 @@ "System Prompt": "Системное сообщение", "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "Вы ChatGPT, большая языковая модель, созданная компанией OpenAI. Следуйте инструкциям пользователя. Отвечайте на сообщения, используя Markdown", "Enter a prompt": "Введите сообщение", - "Regenerate response": "Сгенерировать сообщение снова", + "Regenerate response": "Перегенерировать сообщение", "Sorry, there was an error.": "Просим прощения, произошла ошибка", "Model": "Модель", "Conversation": "Чат", @@ -17,11 +17,11 @@ "AI": "Бот", "You": "Вы", "Cancel": "Отмена", - "Save & Submit": "Сохранить и отправить", + "Save & Submit": "Отредактировать", "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "Убедитесь, что вы ввели API-ключ OpenAI.", "If you completed this step, OpenAI may be experiencing issues.": "Если вы выполнили этот шаг, то возможно OpenAI может испытывать проблемы", "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "Лимит сообщения: {{maxLength}} символов. Вы ввели {{valueLength}} символов.", "Please enter a message": "Пожалуйста введите сообщение", - "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI - продвинутый интерфейс чатбота для чат-моделей OpenAI, которое имитирует интерфейс ChatGPT", + "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI - продвинутый интерфейс чатбота для чат-моделей OpenAI, имитирующий интерфейс ChatGPT", "Are you sure you want to clear all messages?": "Вы уверены, что хотите удалить все сообщения?" }