Merge branch 'ItzCrazyKns:master' into master
This commit is contained in:
commit
3d3e5ebec2
9 changed files with 56 additions and 31 deletions
3
.github/workflows/docker-build.yaml
vendored
3
.github/workflows/docker-build.yaml
vendored
|
@ -17,6 +17,9 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
- [Ollama Connection Errors](#ollama-connection-errors)
|
- [Ollama Connection Errors](#ollama-connection-errors)
|
||||||
- [Using as a Search Engine](#using-as-a-search-engine)
|
- [Using as a Search Engine](#using-as-a-search-engine)
|
||||||
- [Using Perplexica's API](#using-perplexicas-api)
|
- [Using Perplexica's API](#using-perplexicas-api)
|
||||||
|
- [Expose Perplexica to a network](#expose-perplexica-to-network)
|
||||||
- [One-Click Deployment](#one-click-deployment)
|
- [One-Click Deployment](#one-click-deployment)
|
||||||
- [Upcoming Features](#upcoming-features)
|
- [Upcoming Features](#upcoming-features)
|
||||||
- [Support Us](#support-us)
|
- [Support Us](#support-us)
|
||||||
|
@ -135,6 +136,10 @@ Perplexica also provides an API for developers looking to integrate its powerful
|
||||||
|
|
||||||
For more details, check out the full documentation [here](https://github.com/ItzCrazyKns/Perplexica/tree/master/docs/API/SEARCH.md).
|
For more details, check out the full documentation [here](https://github.com/ItzCrazyKns/Perplexica/tree/master/docs/API/SEARCH.md).
|
||||||
|
|
||||||
|
## Expose Perplexica to network
|
||||||
|
|
||||||
|
You can access Perplexica over your home network by following our networking guide [here](https://github.com/ItzCrazyKns/Perplexica/blob/master/docs/installation/NETWORKING.md).
|
||||||
|
|
||||||
## One-Click Deployment
|
## One-Click Deployment
|
||||||
|
|
||||||
[](https://repocloud.io/details/?app_id=267)
|
[](https://repocloud.io/details/?app_id=267)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM node:slim
|
FROM node:18-slim
|
||||||
|
|
||||||
WORKDIR /home/perplexica
|
WORKDIR /home/perplexica
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ COPY yarn.lock /home/perplexica/
|
||||||
|
|
||||||
RUN mkdir /home/perplexica/data
|
RUN mkdir /home/perplexica/data
|
||||||
|
|
||||||
RUN yarn install --frozen-lockfile
|
RUN yarn install --frozen-lockfile --network-timeout 600000
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
|
||||||
CMD ["yarn", "start"]
|
CMD ["yarn", "start"]
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "perplexica-backend",
|
"name": "perplexica-backend",
|
||||||
"version": "1.9.0",
|
"version": "1.9.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "ItzCrazyKns",
|
"author": "ItzCrazyKns",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -22,12 +22,12 @@ export const loadGroqChatModels = async () => {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
'llama-3.2-11b-text-preview': {
|
'llama-3.2-11b-vision-preview': {
|
||||||
displayName: 'Llama 3.2 11B Text',
|
displayName: 'Llama 3.2 11B Vision',
|
||||||
model: new ChatOpenAI(
|
model: new ChatOpenAI(
|
||||||
{
|
{
|
||||||
openAIApiKey: groqApiKey,
|
openAIApiKey: groqApiKey,
|
||||||
modelName: 'llama-3.2-11b-text-preview',
|
modelName: 'llama-3.2-11b-vision-preview',
|
||||||
temperature: 0.7,
|
temperature: 0.7,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -35,12 +35,12 @@ export const loadGroqChatModels = async () => {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
'llama-3.2-90b-text-preview': {
|
'llama-3.2-90b-vision-preview': {
|
||||||
displayName: 'Llama 3.2 90B Text',
|
displayName: 'Llama 3.2 90B Vision',
|
||||||
model: new ChatOpenAI(
|
model: new ChatOpenAI(
|
||||||
{
|
{
|
||||||
openAIApiKey: groqApiKey,
|
openAIApiKey: groqApiKey,
|
||||||
modelName: 'llama-3.2-90b-text-preview',
|
modelName: 'llama-3.2-90b-vision-preview',
|
||||||
temperature: 0.7,
|
temperature: 0.7,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,8 +10,8 @@ import type { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||||
import type { Embeddings } from '@langchain/core/embeddings';
|
import type { Embeddings } from '@langchain/core/embeddings';
|
||||||
import logger from '../utils/logger';
|
import logger from '../utils/logger';
|
||||||
import db from '../db';
|
import db from '../db';
|
||||||
import { chats, messages } from '../db/schema';
|
import { chats, messages as messagesSchema } from '../db/schema';
|
||||||
import { eq } from 'drizzle-orm';
|
import { eq, asc, gt } from 'drizzle-orm';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
|
|
||||||
type Message = {
|
type Message = {
|
||||||
|
@ -71,7 +71,7 @@ const handleEmitterEvents = (
|
||||||
emitter.on('end', () => {
|
emitter.on('end', () => {
|
||||||
ws.send(JSON.stringify({ type: 'messageEnd', messageId: messageId }));
|
ws.send(JSON.stringify({ type: 'messageEnd', messageId: messageId }));
|
||||||
|
|
||||||
db.insert(messages)
|
db.insert(messagesSchema)
|
||||||
.values({
|
.values({
|
||||||
content: recievedMessage,
|
content: recievedMessage,
|
||||||
chatId: chatId,
|
chatId: chatId,
|
||||||
|
@ -106,7 +106,9 @@ export const handleMessage = async (
|
||||||
const parsedWSMessage = JSON.parse(message) as WSMessage;
|
const parsedWSMessage = JSON.parse(message) as WSMessage;
|
||||||
const parsedMessage = parsedWSMessage.message;
|
const parsedMessage = parsedWSMessage.message;
|
||||||
|
|
||||||
const id = crypto.randomBytes(7).toString('hex');
|
const humanMessageId =
|
||||||
|
parsedMessage.messageId ?? crypto.randomBytes(7).toString('hex');
|
||||||
|
const aiMessageId = crypto.randomBytes(7).toString('hex');
|
||||||
|
|
||||||
if (!parsedMessage.content)
|
if (!parsedMessage.content)
|
||||||
return ws.send(
|
return ws.send(
|
||||||
|
@ -141,7 +143,7 @@ export const handleMessage = async (
|
||||||
parsedWSMessage.optimizationMode,
|
parsedWSMessage.optimizationMode,
|
||||||
);
|
);
|
||||||
|
|
||||||
handleEmitterEvents(emitter, ws, id, parsedMessage.chatId);
|
handleEmitterEvents(emitter, ws, aiMessageId, parsedMessage.chatId);
|
||||||
|
|
||||||
const chat = await db.query.chats.findFirst({
|
const chat = await db.query.chats.findFirst({
|
||||||
where: eq(chats.id, parsedMessage.chatId),
|
where: eq(chats.id, parsedMessage.chatId),
|
||||||
|
@ -159,18 +161,29 @@ export const handleMessage = async (
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
await db
|
const messageExists = await db.query.messages.findFirst({
|
||||||
.insert(messages)
|
where: eq(messagesSchema.messageId, humanMessageId),
|
||||||
.values({
|
});
|
||||||
content: parsedMessage.content,
|
|
||||||
chatId: parsedMessage.chatId,
|
if (!messageExists) {
|
||||||
messageId: id,
|
await db
|
||||||
role: 'user',
|
.insert(messagesSchema)
|
||||||
metadata: JSON.stringify({
|
.values({
|
||||||
createdAt: new Date(),
|
content: parsedMessage.content,
|
||||||
}),
|
chatId: parsedMessage.chatId,
|
||||||
})
|
messageId: humanMessageId,
|
||||||
.execute();
|
role: 'user',
|
||||||
|
metadata: JSON.stringify({
|
||||||
|
createdAt: new Date(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.execute();
|
||||||
|
} else {
|
||||||
|
await db
|
||||||
|
.delete(messagesSchema)
|
||||||
|
.where(gt(messagesSchema.id, messageExists.id))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ws.send(
|
ws.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
|
|
|
@ -333,8 +333,9 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||||
}
|
}
|
||||||
}, [isMessagesLoaded, isWSReady]);
|
}, [isMessagesLoaded, isWSReady]);
|
||||||
|
|
||||||
const sendMessage = async (message: string) => {
|
const sendMessage = async (message: string, messageId?: string) => {
|
||||||
if (loading) return;
|
if (loading) return;
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setMessageAppeared(false);
|
setMessageAppeared(false);
|
||||||
|
|
||||||
|
@ -342,12 +343,13 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||||
let recievedMessage = '';
|
let recievedMessage = '';
|
||||||
let added = false;
|
let added = false;
|
||||||
|
|
||||||
const messageId = crypto.randomBytes(7).toString('hex');
|
messageId = messageId ?? crypto.randomBytes(7).toString('hex');
|
||||||
|
|
||||||
ws?.send(
|
ws?.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: 'message',
|
type: 'message',
|
||||||
message: {
|
message: {
|
||||||
|
messageId: messageId,
|
||||||
chatId: chatId!,
|
chatId: chatId!,
|
||||||
content: message,
|
content: message,
|
||||||
},
|
},
|
||||||
|
@ -474,7 +476,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||||
return [...prev.slice(0, messages.length > 2 ? index - 1 : 0)];
|
return [...prev.slice(0, messages.length > 2 ? index - 1 : 0)];
|
||||||
});
|
});
|
||||||
|
|
||||||
sendMessage(message.content);
|
sendMessage(message.content, message.messageId);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -128,7 +128,9 @@ const SettingsDialog = ({
|
||||||
const chatModel =
|
const chatModel =
|
||||||
localStorage.getItem('chatModel') ||
|
localStorage.getItem('chatModel') ||
|
||||||
(data.chatModelProviders &&
|
(data.chatModelProviders &&
|
||||||
data.chatModelProviders[chatModelProvider]?.[0].name) ||
|
data.chatModelProviders[chatModelProvider]?.length > 0
|
||||||
|
? data.chatModelProviders[chatModelProvider][0].name
|
||||||
|
: undefined) ||
|
||||||
'';
|
'';
|
||||||
const embeddingModelProvider =
|
const embeddingModelProvider =
|
||||||
localStorage.getItem('embeddingModelProvider') ||
|
localStorage.getItem('embeddingModelProvider') ||
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "perplexica-frontend",
|
"name": "perplexica-frontend",
|
||||||
"version": "1.9.0",
|
"version": "1.9.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "ItzCrazyKns",
|
"author": "ItzCrazyKns",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue