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
No known key found for this signature in database
GPG key ID: 8162927C7CCE3065
26 changed files with 799 additions and 596 deletions

View file

@ -1,5 +1,7 @@
import express from 'express';
import imageSearchChain from '../agents/imageSearchAgent';
import handleImageSearch from '../agents/imageSearchAgent';
import { ChatOpenAI } from '@langchain/openai';
import { getOpenaiApiKey } from '../config';
const router = express.Router();
@ -7,11 +9,13 @@ router.post('/', async (req, res) => {
try {
const { query, chat_history } = req.body;
const images = await imageSearchChain.invoke({
query,
chat_history,
const llm = new ChatOpenAI({
temperature: 0.7,
openAIApiKey: getOpenaiApiKey(),
});
const images = await handleImageSearch({ query, chat_history }, llm);
res.status(200).json({ images });
} catch (err) {
res.status(500).json({ message: 'An error has occurred.' });