feat(app): add file uploads

This commit is contained in:
ItzCrazyKns
2024-11-23 15:04:19 +05:30
parent c650d1c3d9
commit 4b89008f3a
25 changed files with 1035 additions and 86 deletions

View File

@ -13,6 +13,7 @@ import db from '../db';
import { chats, messages as messagesSchema } from '../db/schema';
import { eq, asc, gt } from 'drizzle-orm';
import crypto from 'crypto';
import { getFileDetails } from '../utils/files';
type Message = {
messageId: string;
@ -26,6 +27,7 @@ type WSMessage = {
type: string;
focusMode: string;
history: Array<[string, string]>;
files: Array<string>;
};
export const searchHandlers = {
@ -141,6 +143,7 @@ export const handleMessage = async (
llm,
embeddings,
parsedWSMessage.optimizationMode,
parsedWSMessage.files,
);
handleEmitterEvents(emitter, ws, aiMessageId, parsedMessage.chatId);
@ -157,6 +160,7 @@ export const handleMessage = async (
title: parsedMessage.content,
createdAt: new Date().toString(),
focusMode: parsedWSMessage.focusMode,
files: parsedWSMessage.files.map(getFileDetails),
})
.execute();
}