mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
Feature: interactive swagger-ui auto-generated API docs from express (#1812)
* Add interactive swagger-ui auto-generated API docs from express * Update README.md * Update index.ts //@ts-ignore * Fix eslint no-console error * Add swagger paths * Add all end points * Update swagger.yml * update swagger yml file * update swagger config --------- Co-authored-by: Henry <hzj94@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
0f58d31493
commit
e8f5f07735
@@ -18,7 +18,7 @@ const createChatMessage = async (req: Request, res: Response, next: NextFunction
|
||||
)
|
||||
}
|
||||
const apiResponse = await chatMessagesService.createChatMessage(req.body)
|
||||
return res.json(apiResponse)
|
||||
return res.json(parseAPIResponse(apiResponse))
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
@@ -88,7 +88,8 @@ const getAllChatMessages = async (req: Request, res: Response, next: NextFunctio
|
||||
feedback,
|
||||
feedbackTypeFilters
|
||||
)
|
||||
return res.json(apiResponse)
|
||||
|
||||
return res.json(parseAPIResponse(apiResponse))
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
@@ -116,7 +117,7 @@ const getAllInternalChatMessages = async (req: Request, res: Response, next: Nex
|
||||
messageId,
|
||||
feedback
|
||||
)
|
||||
return res.json(apiResponse)
|
||||
return res.json(parseAPIResponse(apiResponse))
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
@@ -186,6 +187,39 @@ const abortChatMessage = async (req: Request, res: Response, next: NextFunction)
|
||||
}
|
||||
}
|
||||
|
||||
const parseAPIResponse = (apiResponse: ChatMessage | ChatMessage[]): ChatMessage | ChatMessage[] => {
|
||||
const parseResponse = (response: ChatMessage): ChatMessage => {
|
||||
const parsedResponse = { ...response }
|
||||
|
||||
if (parsedResponse.sourceDocuments) {
|
||||
parsedResponse.sourceDocuments = JSON.parse(parsedResponse.sourceDocuments)
|
||||
}
|
||||
if (parsedResponse.usedTools) {
|
||||
parsedResponse.usedTools = JSON.parse(parsedResponse.usedTools)
|
||||
}
|
||||
if (parsedResponse.fileAnnotations) {
|
||||
parsedResponse.fileAnnotations = JSON.parse(parsedResponse.fileAnnotations)
|
||||
}
|
||||
if (parsedResponse.agentReasoning) {
|
||||
parsedResponse.agentReasoning = JSON.parse(parsedResponse.agentReasoning)
|
||||
}
|
||||
if (parsedResponse.fileUploads) {
|
||||
parsedResponse.fileUploads = JSON.parse(parsedResponse.fileUploads)
|
||||
}
|
||||
if (parsedResponse.action) {
|
||||
parsedResponse.action = JSON.parse(parsedResponse.action)
|
||||
}
|
||||
|
||||
return parsedResponse
|
||||
}
|
||||
|
||||
if (Array.isArray(apiResponse)) {
|
||||
return apiResponse.map(parseResponse)
|
||||
} else {
|
||||
return parseResponse(apiResponse)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
createChatMessage,
|
||||
getAllChatMessages,
|
||||
|
||||
Reference in New Issue
Block a user