feat(config): Use toml instead of env

This commit is contained in:
ItzCrazyKns
2024-04-20 09:32:19 +05:30
parent dd1ce4e324
commit c6a5790d33
26 changed files with 799 additions and 596 deletions

View File

@ -1,10 +1,23 @@
import { WebSocket } from 'ws';
import { handleMessage } from './messageHandler';
import { ChatOpenAI, OpenAIEmbeddings } from '@langchain/openai';
import { getOpenaiApiKey } from '../config';
export const handleConnection = (ws: WebSocket) => {
const llm = new ChatOpenAI({
temperature: 0.7,
openAIApiKey: getOpenaiApiKey(),
});
const embeddings = new OpenAIEmbeddings({
openAIApiKey: getOpenaiApiKey(),
modelName: 'text-embedding-3-large',
});
ws.on(
'message',
async (message) => await handleMessage(message.toString(), ws),
async (message) =>
await handleMessage(message.toString(), ws, llm, embeddings),
);
ws.on('close', () => console.log('Connection closed'));