6 Commits

Author SHA1 Message Date
ItzCrazyKns
38b1995677 feat(package): bump version 2024-05-06 12:36:13 +05:30
ItzCrazyKns
f28257b480 feat(settings): fetch localStorage at state change 2024-05-06 12:34:59 +05:30
ItzCrazyKns
9b088cd161 feat(package): bump version 2024-05-05 16:35:06 +05:30
ItzCrazyKns
94ea6c372a feat(chat-window): clear storage after error 2024-05-05 16:29:40 +05:30
ItzCrazyKns
6e61c88c9e feat(error-object): add key 2024-05-05 16:28:46 +05:30
ItzCrazyKns
ba7b92ffde feat(providers): add Content-Type header 2024-05-05 10:53:27 +05:30
7 changed files with 51 additions and 20 deletions

View File

@ -1,6 +1,6 @@
{
"name": "perplexica-backend",
"version": "1.3.1",
"version": "1.3.3",
"license": "MIT",
"author": "ItzCrazyKns",
"scripts": {

View File

@ -90,7 +90,11 @@ export const getAvailableChatModelProviders = async () => {
if (ollamaEndpoint) {
try {
const response = await fetch(`${ollamaEndpoint}/api/tags`);
const response = await fetch(`${ollamaEndpoint}/api/tags`, {
headers: {
'Content-Type': 'application/json',
},
});
const { models: ollamaModels } = (await response.json()) as any;
@ -137,7 +141,11 @@ export const getAvailableEmbeddingModelProviders = async () => {
if (ollamaEndpoint) {
try {
const response = await fetch(`${ollamaEndpoint}/api/tags`);
const response = await fetch(`${ollamaEndpoint}/api/tags`, {
headers: {
'Content-Type': 'application/json',
},
});
const { models: ollamaModels } = (await response.json()) as any;

View File

@ -70,7 +70,8 @@ export const handleConnection = async (
ws.send(
JSON.stringify({
type: 'error',
data: 'Invalid LLM or embeddings model selected',
data: 'Invalid LLM or embeddings model selected, please refresh the page and try again.',
key: 'INVALID_MODEL_SELECTED',
}),
);
ws.close();

View File

@ -57,7 +57,13 @@ const handleEmitterEvents = (
});
emitter.on('error', (data) => {
const parsedData = JSON.parse(data);
ws.send(JSON.stringify({ type: 'error', data: parsedData.data }));
ws.send(
JSON.stringify({
type: 'error',
data: parsedData.data,
key: 'CHAIN_ERROR',
}),
);
});
};
@ -73,7 +79,11 @@ export const handleMessage = async (
if (!parsedMessage.content)
return ws.send(
JSON.stringify({ type: 'error', data: 'Invalid message format' }),
JSON.stringify({
type: 'error',
data: 'Invalid message format',
key: 'INVALID_FORMAT',
}),
);
const history: BaseMessage[] = parsedMessage.history.map((msg) => {
@ -99,11 +109,23 @@ export const handleMessage = async (
);
handleEmitterEvents(emitter, ws, id);
} else {
ws.send(JSON.stringify({ type: 'error', data: 'Invalid focus mode' }));
ws.send(
JSON.stringify({
type: 'error',
data: 'Invalid focus mode',
key: 'INVALID_FOCUS_MODE',
}),
);
}
}
} catch (err) {
ws.send(JSON.stringify({ type: 'error', data: 'Invalid message format' }));
ws.send(
JSON.stringify({
type: 'error',
data: 'Invalid message format',
key: 'INVALID_FORMAT',
}),
);
logger.error(`Failed to handle message: ${err}`);
}
};

View File

@ -108,6 +108,9 @@ const useSocket = (url: string) => {
const parsedData = JSON.parse(e.data);
if (parsedData.type === 'error') {
toast.error(parsedData.data);
if (parsedData.key === 'INVALID_MODEL_SELECTED') {
localStorage.clear();
}
}
};
};

View File

@ -53,15 +53,6 @@ const SettingsDialog = ({
});
const data = await res.json();
setConfig(data);
setIsLoading(false);
};
fetchConfig();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isOpen]);
useEffect(() => {
setSelectedChatModelProvider(localStorage.getItem('chatModelProvider'));
setSelectedChatModel(localStorage.getItem('chatModel'));
setSelectedEmbeddingModelProvider(
@ -70,7 +61,13 @@ const SettingsDialog = ({
setSelectedEmbeddingModel(localStorage.getItem('embeddingModel'));
setCustomOpenAIApiKey(localStorage.getItem('openAIApiKey'));
setCustomOpenAIBaseURL(localStorage.getItem('openAIBaseUrl'));
}, []);
setIsLoading(false);
};
fetchConfig();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isOpen]);
const handleSubmit = async () => {
setIsUpdating(true);

View File

@ -1,6 +1,6 @@
{
"name": "perplexica-frontend",
"version": "1.3.1",
"version": "1.3.3",
"license": "MIT",
"author": "ItzCrazyKns",
"scripts": {