Feature: Custom Templates (#3169)

* New Feature: Custom Templates in the marketplace.

* New Feature: Custom Templates in the marketplace.

* Custom Template Delete and Shortcut in the dropdown menu

* auto detect framework

* minor ui fixes

* adding custom template feature for tools

* ui tool dialog save template

---------

Co-authored-by: Henry <hzj94@hotmail.com>
This commit is contained in:
Vinod Kiran
2024-09-16 19:14:39 +05:30
committed by GitHub
parent 44b70ca7e2
commit b02bdc74ad
23 changed files with 1217 additions and 170 deletions
@@ -1,5 +1,7 @@
import { Request, Response, NextFunction } from 'express'
import marketplacesService from '../../services/marketplaces'
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
import { StatusCodes } from 'http-status-codes'
// Get all templates for marketplaces
const getAllTemplates = async (req: Request, res: Response, next: NextFunction) => {
@@ -11,6 +13,48 @@ const getAllTemplates = async (req: Request, res: Response, next: NextFunction)
}
}
export default {
getAllTemplates
const deleteCustomTemplate = async (req: Request, res: Response, next: NextFunction) => {
try {
if (typeof req.params === 'undefined' || !req.params.id) {
throw new InternalFlowiseError(
StatusCodes.PRECONDITION_FAILED,
`Error: marketplacesService.deleteCustomTemplate - id not provided!`
)
}
const apiResponse = await marketplacesService.deleteCustomTemplate(req.params.id)
return res.json(apiResponse)
} catch (error) {
next(error)
}
}
const getAllCustomTemplates = async (req: Request, res: Response, next: NextFunction) => {
try {
const apiResponse = await marketplacesService.getAllCustomTemplates()
return res.json(apiResponse)
} catch (error) {
next(error)
}
}
const saveCustomTemplate = async (req: Request, res: Response, next: NextFunction) => {
try {
if ((!req.body && !(req.body.chatflowId || req.body.tool)) || !req.body.name) {
throw new InternalFlowiseError(
StatusCodes.PRECONDITION_FAILED,
`Error: marketplacesService.saveCustomTemplate - body not provided!`
)
}
const apiResponse = await marketplacesService.saveCustomTemplate(req.body)
return res.json(apiResponse)
} catch (error) {
next(error)
}
}
export default {
getAllTemplates,
getAllCustomTemplates,
saveCustomTemplate,
deleteCustomTemplate
}