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:
Octavian FlowiseAI
2024-08-25 14:22:07 +02:00
committed by GitHub
parent 0f58d31493
commit e8f5f07735
26 changed files with 3123 additions and 270 deletions
+2 -1
View File
@@ -4,7 +4,8 @@ import { baseURL } from '@/store/constant'
const apiClient = axios.create({
baseURL: `${baseURL}/api/v1`,
headers: {
'Content-type': 'application/json'
'Content-type': 'application/json',
'x-request-from': 'internal'
}
})
+1 -1
View File
@@ -1,6 +1,6 @@
import client from './client'
const getAllDocumentStores = () => client.get('/document-store/stores')
const getAllDocumentStores = () => client.get('/document-store/store')
const getDocumentLoaders = () => client.get('/document-store/components/loaders')
const getSpecificDocumentStore = (id) => client.get(`/document-store/store/${id}`)
const createDocumentStore = (body) => client.post(`/document-store/store`, body)
@@ -22,6 +22,10 @@ const AboutDialog = ({ show, onCancel }) => {
username,
password
}
config.headers = {
'Content-type': 'application/json',
'x-request-from': 'internal'
}
}
const latestReleaseReq = axios.get('https://api.github.com/repos/FlowiseAI/Flowise/releases/latest')
const currentVersionReq = axios.get(`${baseURL}/api/v1/version`, { ...config })
@@ -187,8 +187,7 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => {
const chatmsg = allChatlogs[i]
const chatPK = getChatPK(chatmsg)
let filePaths = []
if (chatmsg.fileUploads) {
chatmsg.fileUploads = JSON.parse(chatmsg.fileUploads)
if (chatmsg.fileUploads && Array.isArray(chatmsg.fileUploads)) {
chatmsg.fileUploads.forEach((file) => {
if (file.type === 'stored-file') {
filePaths.push(
@@ -203,11 +202,11 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => {
time: chatmsg.createdDate
}
if (filePaths.length) msg.filePaths = filePaths
if (chatmsg.sourceDocuments) msg.sourceDocuments = JSON.parse(chatmsg.sourceDocuments)
if (chatmsg.usedTools) msg.usedTools = JSON.parse(chatmsg.usedTools)
if (chatmsg.fileAnnotations) msg.fileAnnotations = JSON.parse(chatmsg.fileAnnotations)
if (chatmsg.sourceDocuments) msg.sourceDocuments = chatmsg.sourceDocuments
if (chatmsg.usedTools) msg.usedTools = Jchatmsg.usedTools
if (chatmsg.fileAnnotations) msg.fileAnnotations = chatmsg.fileAnnotations
if (chatmsg.feedback) msg.feedback = chatmsg.feedback?.content
if (chatmsg.agentReasoning) msg.agentReasoning = JSON.parse(chatmsg.agentReasoning)
if (chatmsg.agentReasoning) msg.agentReasoning = chatmsg.agentReasoning
if (!Object.prototype.hasOwnProperty.call(obj, chatPK)) {
obj[chatPK] = {
@@ -326,8 +325,7 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => {
})
}
}
if (chatmsg.fileUploads) {
chatmsg.fileUploads = JSON.parse(chatmsg.fileUploads)
if (chatmsg.fileUploads && Array.isArray(chatmsg.fileUploads)) {
chatmsg.fileUploads.forEach((file) => {
if (file.type === 'stored-file') {
file.data = `${baseURL}/api/v1/get-upload-file?chatflowId=${chatmsg.chatflowid}&chatId=${chatmsg.chatId}&fileName=${file.name}`
@@ -339,10 +337,10 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => {
message: chatmsg.content,
type: chatmsg.role
}
if (chatmsg.sourceDocuments) obj.sourceDocuments = JSON.parse(chatmsg.sourceDocuments)
if (chatmsg.usedTools) obj.usedTools = JSON.parse(chatmsg.usedTools)
if (chatmsg.fileAnnotations) obj.fileAnnotations = JSON.parse(chatmsg.fileAnnotations)
if (chatmsg.agentReasoning) obj.agentReasoning = JSON.parse(chatmsg.agentReasoning)
if (chatmsg.sourceDocuments) obj.sourceDocuments = chatmsg.sourceDocuments
if (chatmsg.usedTools) obj.usedTools = chatmsg.usedTools
if (chatmsg.fileAnnotations) obj.fileAnnotations = chatmsg.fileAnnotations
if (chatmsg.agentReasoning) obj.agentReasoning = chatmsg.agentReasoning
loadedMessages.push(obj)
}
@@ -35,7 +35,10 @@ const fetchList = async ({ name, nodeData }) => {
.post(
`${baseURL}/api/v1/node-load-method/${nodeData.name}`,
{ ...nodeData, loadMethod },
{ auth: username && password ? { username, password } : undefined }
{
auth: username && password ? { username, password } : undefined,
headers: { 'Content-type': 'application/json', 'x-request-from': 'internal' }
}
)
.then(async function (response) {
return response.data
@@ -684,13 +684,13 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
feedback: message.feedback,
type: message.role
}
if (message.sourceDocuments) obj.sourceDocuments = JSON.parse(message.sourceDocuments)
if (message.usedTools) obj.usedTools = JSON.parse(message.usedTools)
if (message.fileAnnotations) obj.fileAnnotations = JSON.parse(message.fileAnnotations)
if (message.agentReasoning) obj.agentReasoning = JSON.parse(message.agentReasoning)
if (message.action) obj.action = JSON.parse(message.action)
if (message.sourceDocuments) obj.sourceDocuments = message.sourceDocuments
if (message.usedTools) obj.usedTools = message.usedTools
if (message.fileAnnotations) obj.fileAnnotations = message.fileAnnotations
if (message.agentReasoning) obj.agentReasoning = message.agentReasoning
if (message.action) obj.action = message.action
if (message.fileUploads) {
obj.fileUploads = JSON.parse(message.fileUploads)
obj.fileUploads = message.fileUploads
obj.fileUploads.forEach((file) => {
if (file.type === 'stored-file') {
file.data = `${baseURL}/api/v1/get-upload-file?chatflowId=${chatflowid}&chatId=${chatId}&fileName=${file.name}`
@@ -1390,44 +1390,13 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
</>
)}
</div>
{message.type === 'apiMessage' && message.id && chatFeedbackStatus ? (
<>
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'start',
gap: 1
}}
>
<CopyToClipboardButton onClick={() => copyMessageToClipboard(message.message)} />
{!message.feedback ||
message.feedback.rating === '' ||
message.feedback.rating === 'THUMBS_UP' ? (
<ThumbsUpButton
isDisabled={message.feedback && message.feedback.rating === 'THUMBS_UP'}
rating={message.feedback ? message.feedback.rating : ''}
onClick={() => onThumbsUpClick(message.id)}
/>
) : null}
{!message.feedback ||
message.feedback.rating === '' ||
message.feedback.rating === 'THUMBS_DOWN' ? (
<ThumbsDownButton
isDisabled={message.feedback && message.feedback.rating === 'THUMBS_DOWN'}
rating={message.feedback ? message.feedback.rating : ''}
onClick={() => onThumbsDownClick(message.id)}
/>
) : null}
</Box>
</>
) : null}
{message.fileAnnotations && (
<div
style={{
display: 'block',
flexDirection: 'row',
width: '100%'
width: '100%',
marginBottom: '8px'
}}
>
{message.fileAnnotations.map((fileAnnotation, index) => {
@@ -1454,7 +1423,8 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
style={{
display: 'block',
flexDirection: 'row',
width: '100%'
width: '100%',
marginBottom: '8px'
}}
>
{removeDuplicateURL(message).map((source, index) => {
@@ -1486,7 +1456,8 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
flexWrap: 'wrap',
flexDirection: 'row',
width: '100%',
gap: '8px'
gap: '8px',
marginBottom: '8px'
}}
>
{(message.action.elements || []).map((elem, index) => {
@@ -1537,6 +1508,38 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
})}
</div>
)}
{message.type === 'apiMessage' && message.id && chatFeedbackStatus ? (
<>
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'start',
gap: 1
}}
>
<CopyToClipboardButton onClick={() => copyMessageToClipboard(message.message)} />
{!message.feedback ||
message.feedback.rating === '' ||
message.feedback.rating === 'THUMBS_UP' ? (
<ThumbsUpButton
isDisabled={message.feedback && message.feedback.rating === 'THUMBS_UP'}
rating={message.feedback ? message.feedback.rating : ''}
onClick={() => onThumbsUpClick(message.id)}
/>
) : null}
{!message.feedback ||
message.feedback.rating === '' ||
message.feedback.rating === 'THUMBS_DOWN' ? (
<ThumbsDownButton
isDisabled={message.feedback && message.feedback.rating === 'THUMBS_DOWN'}
rating={message.feedback ? message.feedback.rating : ''}
onClick={() => onThumbsDownClick(message.id)}
/>
) : null}
</Box>
</>
) : null}
</div>
</Box>
)