mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-27 19:00:37 +03:00
Feature/Custom Assistant Builder (#3631)
* add custom assistant builder * add tools to custom assistant * add save assistant button
This commit is contained in:
@@ -2,6 +2,7 @@ import { Request, Response, NextFunction } from 'express'
|
||||
import assistantsService from '../../services/assistants'
|
||||
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
|
||||
import { StatusCodes } from 'http-status-codes'
|
||||
import { AssistantType } from '../../Interface'
|
||||
|
||||
const createAssistant = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
@@ -35,7 +36,8 @@ const deleteAssistant = async (req: Request, res: Response, next: NextFunction)
|
||||
|
||||
const getAllAssistants = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const apiResponse = await assistantsService.getAllAssistants()
|
||||
const type = req.query.type as AssistantType
|
||||
const apiResponse = await assistantsService.getAllAssistants(type)
|
||||
return res.json(apiResponse)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
@@ -78,10 +80,56 @@ const updateAssistant = async (req: Request, res: Response, next: NextFunction)
|
||||
}
|
||||
}
|
||||
|
||||
const getChatModels = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const apiResponse = await assistantsService.getChatModels()
|
||||
return res.json(apiResponse)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
|
||||
const getDocumentStores = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const apiResponse = await assistantsService.getDocumentStores()
|
||||
return res.json(apiResponse)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
|
||||
const getTools = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const apiResponse = await assistantsService.getTools()
|
||||
return res.json(apiResponse)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
|
||||
const generateAssistantInstruction = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
if (!req.body) {
|
||||
throw new InternalFlowiseError(
|
||||
StatusCodes.PRECONDITION_FAILED,
|
||||
`Error: assistantsController.generateAssistantInstruction - body not provided!`
|
||||
)
|
||||
}
|
||||
const apiResponse = await assistantsService.generateAssistantInstruction(req.body.task, req.body.selectedChatModel)
|
||||
return res.json(apiResponse)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
createAssistant,
|
||||
deleteAssistant,
|
||||
getAllAssistants,
|
||||
getAssistantById,
|
||||
updateAssistant
|
||||
updateAssistant,
|
||||
getChatModels,
|
||||
getDocumentStores,
|
||||
getTools,
|
||||
generateAssistantInstruction
|
||||
}
|
||||
|
||||
@@ -410,6 +410,24 @@ const refreshDocStoreMiddleware = async (req: Request, res: Response, next: Next
|
||||
}
|
||||
}
|
||||
|
||||
const generateDocStoreToolDesc = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
if (typeof req.params.id === 'undefined' || req.params.id === '') {
|
||||
throw new InternalFlowiseError(
|
||||
StatusCodes.PRECONDITION_FAILED,
|
||||
`Error: documentStoreController.generateDocStoreToolDesc - storeId not provided!`
|
||||
)
|
||||
}
|
||||
if (typeof req.body === 'undefined') {
|
||||
throw new Error('Error: documentStoreController.generateDocStoreToolDesc - body not provided!')
|
||||
}
|
||||
const apiResponse = await documentStoreService.generateDocStoreToolDesc(req.params.id, req.body.selectedChatModel)
|
||||
return res.json(apiResponse)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
deleteDocumentStore,
|
||||
createDocumentStore,
|
||||
@@ -434,5 +452,6 @@ export default {
|
||||
getRateLimiterMiddleware,
|
||||
upsertDocStoreMiddleware,
|
||||
refreshDocStoreMiddleware,
|
||||
saveProcessingLoader
|
||||
saveProcessingLoader,
|
||||
generateDocStoreToolDesc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user