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