From 77ad309757a6a0320f1d0634a95e47ffb0115f4a Mon Sep 17 00:00:00 2001 From: Thuc Pham <51660321+thucpn@users.noreply.github.com> Date: Fri, 2 Aug 2024 18:00:03 +0700 Subject: [PATCH] feat: add llamacloud config api for express --- .../express/src/controllers/chat-config.controller.ts | 8 ++++++++ .../types/streaming/express/src/routes/chat.route.ts | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/templates/types/streaming/express/src/controllers/chat-config.controller.ts b/templates/types/streaming/express/src/controllers/chat-config.controller.ts index 4481e10d1..79c4d9f01 100644 --- a/templates/types/streaming/express/src/controllers/chat-config.controller.ts +++ b/templates/types/streaming/express/src/controllers/chat-config.controller.ts @@ -1,4 +1,5 @@ import { Request, Response } from "express"; +import { LLamaCloudFileService } from "./llamaindex/streaming/service"; export const chatConfig = async (_req: Request, res: Response) => { let starterQuestions = undefined; @@ -12,3 +13,10 @@ export const chatConfig = async (_req: Request, res: Response) => { starterQuestions, }); }; + +export const chatLlamaCloudConfig = async (_req: Request, res: Response) => { + const config = { + projects: await LLamaCloudFileService.getAllProjectsWithPipelines(), + }; + return res.status(200).json(config); +}; diff --git a/templates/types/streaming/express/src/routes/chat.route.ts b/templates/types/streaming/express/src/routes/chat.route.ts index 96711d502..5044efcb4 100644 --- a/templates/types/streaming/express/src/routes/chat.route.ts +++ b/templates/types/streaming/express/src/routes/chat.route.ts @@ -1,5 +1,8 @@ import express, { Router } from "express"; -import { chatConfig } from "../controllers/chat-config.controller"; +import { + chatConfig, + chatLlamaCloudConfig, +} from "../controllers/chat-config.controller"; import { chatRequest } from "../controllers/chat-request.controller"; import { chatUpload } from "../controllers/chat-upload.controller"; import { chat } from "../controllers/chat.controller"; @@ -11,6 +14,7 @@ initSettings(); llmRouter.route("/").post(chat); llmRouter.route("/request").post(chatRequest); llmRouter.route("/config").get(chatConfig); +llmRouter.route("/config/llamacloud").get(chatLlamaCloudConfig); llmRouter.route("/upload").post(chatUpload); export default llmRouter;