chore: Update dependencies and fix import paths

This commit is contained in:
Jin Yucong 2024-07-05 15:49:43 +08:00
parent 3b737a078a
commit 81c5e30fda
46 changed files with 1626 additions and 371 deletions

View file

@ -7,16 +7,16 @@ import logger from "../utils/logger";
const router = express.Router();
router.post("/", async (req, res) => {
router.post("/", async (request, res) => {
try {
const { query, chat_history: raw_chat_history, chat_model_provider, chat_model } = req.body;
const { query, chat_history: raw_chat_history, chat_model_provider, chat_model } = request.body;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const chat_history = raw_chat_history.map((msg: any) => {
if (msg.role === "user") {
return new HumanMessage(msg.content);
} else if (msg.role === "assistant") {
return new AIMessage(msg.content);
const chat_history = raw_chat_history.map((message: any) => {
if (message.role === "user") {
return new HumanMessage(message.content);
} else if (message.role === "assistant") {
return new AIMessage(message.content);
}
});
@ -38,9 +38,9 @@ router.post("/", async (req, res) => {
const images = await handleImageSearch({ query, chat_history }, llm);
res.status(200).json({ images });
} catch (err) {
} catch (error) {
res.status(500).json({ message: "An error has occurred." });
logger.error(`Error in image search: ${err.message}`);
logger.error(`Error in image search: ${error.message}`);
}
});