mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 19:54:00 +01:00
remove api checking
This commit is contained in:
parent
ae9499301a
commit
b6bf66dcc7
|
@ -39,7 +39,7 @@ export const getChatCompletionStream = async (
|
|||
stream: true,
|
||||
}),
|
||||
});
|
||||
if (response.status === 404)
|
||||
if (response.status === 404 || response.status === 405)
|
||||
throw new Error(
|
||||
'Message from freechatgpt.chat:\nInvalid API endpoint! We recommend you to check your free API endpoint.'
|
||||
);
|
||||
|
|
|
@ -2,7 +2,6 @@ import React, { useEffect, useState } from 'react';
|
|||
import useStore from '@store/store';
|
||||
|
||||
import PopupModal from '@components/PopupModal';
|
||||
import { validateApiKey } from '@api/customApi';
|
||||
|
||||
const ApiMenu = ({
|
||||
isModalOpen,
|
||||
|
@ -22,29 +21,16 @@ const ApiMenu = ({
|
|||
const [_apiKey, _setApiKey] = useState<string>(apiKey || '');
|
||||
const [_apiFreeEndpoint, _setApiFreeEndpoint] =
|
||||
useState<string>(apiFreeEndpoint);
|
||||
const [error, setError] = useState<string>('');
|
||||
|
||||
const handleSave = async () => {
|
||||
if (_apiFree === true) {
|
||||
setApiFreeEndpoint(_apiFreeEndpoint);
|
||||
setApiFree(true);
|
||||
setError('');
|
||||
setIsModalOpen(false);
|
||||
} else {
|
||||
const valid = await validateApiKey(_apiKey);
|
||||
if (valid) {
|
||||
setApiKey(_apiKey);
|
||||
setApiFree(false);
|
||||
setError('');
|
||||
setIsModalOpen(false);
|
||||
} else {
|
||||
setError(
|
||||
'Error: Invalid API key or network blocked. Please check your API key and network settings for OpenAI API.'
|
||||
);
|
||||
setTimeout(() => {
|
||||
setError('');
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -157,11 +143,6 @@ const ApiMenu = ({
|
|||
purpose of accessing the OpenAI API and not for any other unauthorised
|
||||
use.
|
||||
</div>
|
||||
{error !== '' && (
|
||||
<div className='bg-red-600/50 p-2 rounded-sm mt-3 text-gray-900 dark:text-gray-300 text-sm'>
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</PopupModal>
|
||||
) : (
|
||||
|
|
|
@ -50,6 +50,8 @@ const useSubmit = () => {
|
|||
messages,
|
||||
chats[currentChatIndex].config
|
||||
);
|
||||
} else {
|
||||
throw new Error('No API key supplied! Please check your API settings.');
|
||||
}
|
||||
|
||||
if (stream) {
|
||||
|
|
Loading…
Reference in a new issue