mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 15:44:00 +01:00
parent
dfd8cfc32a
commit
e4468fd93f
5
.env.example
Normal file
5
.env.example
Normal file
|
@ -0,0 +1,5 @@
|
|||
# All options are optional, remove those you do not need
|
||||
VITE_CUSTOM_API_ENDPOINT=
|
||||
VITE_DEFAULT_API_ENDPOINT=
|
||||
VITE_OPENAI_API_KEY=
|
||||
VITE_DEFAULT_SYSTEM_MESSAGE= # Remove this line if you want to use the default system message of Better ChatGPT
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -24,3 +24,5 @@ dist-ssr
|
|||
*.sw?
|
||||
|
||||
release/
|
||||
|
||||
.env
|
|
@ -14,7 +14,9 @@ const ApiPopup = () => {
|
|||
const setFirstVisit = useStore((state) => state.setFirstVisit);
|
||||
|
||||
const [_apiKey, _setApiKey] = useState<string>(apiKey || '');
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(firstVisit);
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(
|
||||
!apiKey && firstVisit
|
||||
);
|
||||
const [error, setError] = useState<string>('');
|
||||
|
||||
const handleConfirm = () => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export const officialAPIEndpoint = 'https://api.openai.com/v1/chat/completions';
|
||||
export const defaultAPIEndpoint = officialAPIEndpoint;
|
||||
const customAPIEndpoint =
|
||||
import.meta.env.VITE_CUSTOM_API_ENDPOINT || 'https://chatgpt-api.shn.hk/v1/';
|
||||
export const defaultAPIEndpoint =
|
||||
import.meta.env.VITE_DEFAULT_API_ENDPOINT || officialAPIEndpoint;
|
||||
|
||||
export const availableEndpoints = [
|
||||
officialAPIEndpoint,
|
||||
'https://chatgpt-api.shn.hk/v1/',
|
||||
];
|
||||
export const availableEndpoints = [officialAPIEndpoint, customAPIEndpoint];
|
||||
|
|
|
@ -11,7 +11,9 @@ const dateString =
|
|||
('0' + date.getDate()).slice(-2);
|
||||
|
||||
// default system message obtained using the following method: https://twitter.com/DeminDimin/status/1619935545144279040
|
||||
export const _defaultSystemMessage = `You are ChatGPT, a large language model trained by OpenAI.
|
||||
export const _defaultSystemMessage =
|
||||
import.meta.env.VITE_DEFAULT_SYSTEM_MESSAGE ??
|
||||
`You are ChatGPT, a large language model trained by OpenAI.
|
||||
Carefully heed the user's instructions.
|
||||
Respond using Markdown.`;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ export interface AuthSlice {
|
|||
}
|
||||
|
||||
export const createAuthSlice: StoreSlice<AuthSlice> = (set, get) => ({
|
||||
apiKey: import.meta.env.VITE_OPENAI_API_KEY || undefined,
|
||||
apiEndpoint: defaultAPIEndpoint,
|
||||
firstVisit: true,
|
||||
setApiKey: (apiKey: string) => {
|
||||
|
|
Loading…
Reference in a new issue