mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-12-14 23:58:14 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38b1995677 | ||
|
|
f28257b480 | ||
|
|
9b088cd161 | ||
|
|
94ea6c372a | ||
|
|
6e61c88c9e | ||
|
|
ba7b92ffde |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "perplexica-backend",
|
"name": "perplexica-backend",
|
||||||
"version": "1.3.1",
|
"version": "1.3.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "ItzCrazyKns",
|
"author": "ItzCrazyKns",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -90,7 +90,11 @@ export const getAvailableChatModelProviders = async () => {
|
|||||||
|
|
||||||
if (ollamaEndpoint) {
|
if (ollamaEndpoint) {
|
||||||
try {
|
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;
|
const { models: ollamaModels } = (await response.json()) as any;
|
||||||
|
|
||||||
@@ -137,7 +141,11 @@ export const getAvailableEmbeddingModelProviders = async () => {
|
|||||||
|
|
||||||
if (ollamaEndpoint) {
|
if (ollamaEndpoint) {
|
||||||
try {
|
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;
|
const { models: ollamaModels } = (await response.json()) as any;
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ export const handleConnection = async (
|
|||||||
ws.send(
|
ws.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: 'error',
|
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();
|
ws.close();
|
||||||
|
|||||||
@@ -57,7 +57,13 @@ const handleEmitterEvents = (
|
|||||||
});
|
});
|
||||||
emitter.on('error', (data) => {
|
emitter.on('error', (data) => {
|
||||||
const parsedData = JSON.parse(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)
|
if (!parsedMessage.content)
|
||||||
return ws.send(
|
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) => {
|
const history: BaseMessage[] = parsedMessage.history.map((msg) => {
|
||||||
@@ -99,11 +109,23 @@ export const handleMessage = async (
|
|||||||
);
|
);
|
||||||
handleEmitterEvents(emitter, ws, id);
|
handleEmitterEvents(emitter, ws, id);
|
||||||
} else {
|
} 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) {
|
} 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}`);
|
logger.error(`Failed to handle message: ${err}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ const useSocket = (url: string) => {
|
|||||||
const parsedData = JSON.parse(e.data);
|
const parsedData = JSON.parse(e.data);
|
||||||
if (parsedData.type === 'error') {
|
if (parsedData.type === 'error') {
|
||||||
toast.error(parsedData.data);
|
toast.error(parsedData.data);
|
||||||
|
if (parsedData.key === 'INVALID_MODEL_SELECTED') {
|
||||||
|
localStorage.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,15 +53,6 @@ const SettingsDialog = ({
|
|||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
setConfig(data);
|
setConfig(data);
|
||||||
setIsLoading(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchConfig();
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setSelectedChatModelProvider(localStorage.getItem('chatModelProvider'));
|
setSelectedChatModelProvider(localStorage.getItem('chatModelProvider'));
|
||||||
setSelectedChatModel(localStorage.getItem('chatModel'));
|
setSelectedChatModel(localStorage.getItem('chatModel'));
|
||||||
setSelectedEmbeddingModelProvider(
|
setSelectedEmbeddingModelProvider(
|
||||||
@@ -70,7 +61,13 @@ const SettingsDialog = ({
|
|||||||
setSelectedEmbeddingModel(localStorage.getItem('embeddingModel'));
|
setSelectedEmbeddingModel(localStorage.getItem('embeddingModel'));
|
||||||
setCustomOpenAIApiKey(localStorage.getItem('openAIApiKey'));
|
setCustomOpenAIApiKey(localStorage.getItem('openAIApiKey'));
|
||||||
setCustomOpenAIBaseURL(localStorage.getItem('openAIBaseUrl'));
|
setCustomOpenAIBaseURL(localStorage.getItem('openAIBaseUrl'));
|
||||||
}, []);
|
setIsLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchConfig();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [isOpen]);
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
setIsUpdating(true);
|
setIsUpdating(true);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "perplexica-frontend",
|
"name": "perplexica-frontend",
|
||||||
"version": "1.3.1",
|
"version": "1.3.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "ItzCrazyKns",
|
"author": "ItzCrazyKns",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user