mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-09-16 06:11:32 +00:00
Compare commits
4 Commits
44753ae3b2
...
0a49186af9
Author | SHA1 | Date | |
---|---|---|---|
|
0a49186af9 | ||
|
4c73caadf6 | ||
|
80ac0c92ba | ||
|
5ed8fb47aa |
@@ -563,12 +563,16 @@ const Page = () => {
|
|||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Model name"
|
placeholder="Model name"
|
||||||
defaultValue={config.customOpenaiModelName}
|
value={config.customOpenaiModelName}
|
||||||
onChange={(e) =>
|
isSaving={savingStates['customOpenaiModelName']}
|
||||||
setConfig({
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
...config,
|
setConfig((prev) => ({
|
||||||
|
...prev!,
|
||||||
customOpenaiModelName: e.target.value,
|
customOpenaiModelName: e.target.value,
|
||||||
})
|
}));
|
||||||
|
}}
|
||||||
|
onSave={(value) =>
|
||||||
|
saveConfig('customOpenaiModelName', value)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -579,12 +583,16 @@ const Page = () => {
|
|||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Custom OpenAI API Key"
|
placeholder="Custom OpenAI API Key"
|
||||||
defaultValue={config.customOpenaiApiKey}
|
value={config.customOpenaiApiKey}
|
||||||
onChange={(e) =>
|
isSaving={savingStates['customOpenaiApiKey']}
|
||||||
setConfig({
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
...config,
|
setConfig((prev) => ({
|
||||||
|
...prev!,
|
||||||
customOpenaiApiKey: e.target.value,
|
customOpenaiApiKey: e.target.value,
|
||||||
})
|
}));
|
||||||
|
}}
|
||||||
|
onSave={(value) =>
|
||||||
|
saveConfig('customOpenaiApiKey', value)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -595,12 +603,16 @@ const Page = () => {
|
|||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Custom OpenAI Base URL"
|
placeholder="Custom OpenAI Base URL"
|
||||||
defaultValue={config.customOpenaiApiUrl}
|
value={config.customOpenaiApiUrl}
|
||||||
onChange={(e) =>
|
isSaving={savingStates['customOpenaiApiUrl']}
|
||||||
setConfig({
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
...config,
|
setConfig((prev) => ({
|
||||||
|
...prev!,
|
||||||
customOpenaiApiUrl: e.target.value,
|
customOpenaiApiUrl: e.target.value,
|
||||||
})
|
}));
|
||||||
|
}}
|
||||||
|
onSave={(value) =>
|
||||||
|
saveConfig('customOpenaiApiUrl', value)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -397,6 +397,8 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
|||||||
|
|
||||||
const [isMessagesLoaded, setIsMessagesLoaded] = useState(false);
|
const [isMessagesLoaded, setIsMessagesLoaded] = useState(false);
|
||||||
|
|
||||||
|
const [pendingRewrite, setPendingRewrite] = useState<{ content: string; messageId: string } | null>(null);
|
||||||
|
|
||||||
const [notFound, setNotFound] = useState(false);
|
const [notFound, setNotFound] = useState(false);
|
||||||
|
|
||||||
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
||||||
@@ -436,6 +438,12 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const chatHistoryRef = useRef<[string, string][]>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
chatHistoryRef.current = chatHistory;
|
||||||
|
}, [chatHistory]);
|
||||||
|
|
||||||
const messagesRef = useRef<Message[]>([]);
|
const messagesRef = useRef<Message[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -478,7 +486,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
|||||||
files: fileIds,
|
files: fileIds,
|
||||||
focusMode: focusMode,
|
focusMode: focusMode,
|
||||||
optimizationMode: optimizationMode,
|
optimizationMode: optimizationMode,
|
||||||
history: [...chatHistory, ['human', message]],
|
history: [...chatHistoryRef.current],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -604,15 +612,22 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
|||||||
const message = messages[index - 1];
|
const message = messages[index - 1];
|
||||||
|
|
||||||
setMessages((prev) => {
|
setMessages((prev) => {
|
||||||
return [...prev.slice(0, messages.length > 2 ? index - 1 : 0)];
|
return [...prev.slice(0, messages.length >= 2 ? index - 1 : 0)];
|
||||||
});
|
});
|
||||||
setChatHistory((prev) => {
|
setChatHistory((prev) => {
|
||||||
return [...prev.slice(0, messages.length > 2 ? index - 1 : 0)];
|
return [...prev.slice(0, messages.length >= 2 ? index - 1 : 0)];
|
||||||
});
|
});
|
||||||
|
|
||||||
sendMessage(message.content, message.messageId);
|
setPendingRewrite({content: message.content, messageId: message.messageId});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (pendingRewrite) {
|
||||||
|
sendMessage(pendingRewrite.content, pendingRewrite.messageId);
|
||||||
|
setPendingRewrite(null);
|
||||||
|
}
|
||||||
|
}, [pendingRewrite]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isReady && initialMessage && ws?.readyState === 1) {
|
if (isReady && initialMessage && ws?.readyState === 1) {
|
||||||
sendMessage(initialMessage);
|
sendMessage(initialMessage);
|
||||||
|
Reference in New Issue
Block a user