mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
ViewMessages->Export Messages. Add Fullpath of the image/audio file.
This commit is contained in:
@@ -1150,6 +1150,12 @@ export class App {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.app.get('/api/v1/get-upload-path', async (req: Request, res: Response) => {
|
||||||
|
return res.json({
|
||||||
|
storagePath: getStoragePath()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// stream uploaded image
|
// stream uploaded image
|
||||||
this.app.get('/api/v1/get-upload-file', async (req: Request, res: Response) => {
|
this.app.get('/api/v1/get-upload-file', async (req: Request, res: Response) => {
|
||||||
if (!req.query.chatflowId || !req.query.chatId || !req.query.fileName) {
|
if (!req.query.chatflowId || !req.query.chatId || !req.query.fileName) {
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ const getInternalChatmessageFromChatflow = (id) => client.get(`/internal-chatmes
|
|||||||
const getAllChatmessageFromChatflow = (id, params = {}) => client.get(`/chatmessage/${id}`, { params: { order: 'DESC', ...params } })
|
const getAllChatmessageFromChatflow = (id, params = {}) => client.get(`/chatmessage/${id}`, { params: { order: 'DESC', ...params } })
|
||||||
const getChatmessageFromPK = (id, params = {}) => client.get(`/chatmessage/${id}`, { params: { order: 'ASC', ...params } })
|
const getChatmessageFromPK = (id, params = {}) => client.get(`/chatmessage/${id}`, { params: { order: 'ASC', ...params } })
|
||||||
const deleteChatmessage = (id, params = {}) => client.delete(`/chatmessage/${id}`, { params: { ...params } })
|
const deleteChatmessage = (id, params = {}) => client.delete(`/chatmessage/${id}`, { params: { ...params } })
|
||||||
|
const getStoragePath = () => client.get(`/get-upload-path`)
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getInternalChatmessageFromChatflow,
|
getInternalChatmessageFromChatflow,
|
||||||
getAllChatmessageFromChatflow,
|
getAllChatmessageFromChatflow,
|
||||||
getChatmessageFromPK,
|
getChatmessageFromPK,
|
||||||
deleteChatmessage
|
deleteChatmessage,
|
||||||
|
getStoragePath
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ import useApi from 'hooks/useApi'
|
|||||||
import useConfirm from 'hooks/useConfirm'
|
import useConfirm from 'hooks/useConfirm'
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { isValidURL, removeDuplicateURL } from 'utils/genericHelper'
|
import { getOS, isValidURL, removeDuplicateURL } from 'utils/genericHelper'
|
||||||
import useNotifier from 'utils/useNotifier'
|
import useNotifier from 'utils/useNotifier'
|
||||||
import { baseURL } from 'store/constant'
|
import { baseURL } from 'store/constant'
|
||||||
|
|
||||||
@@ -100,6 +100,8 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => {
|
|||||||
|
|
||||||
const getChatmessageApi = useApi(chatmessageApi.getAllChatmessageFromChatflow)
|
const getChatmessageApi = useApi(chatmessageApi.getAllChatmessageFromChatflow)
|
||||||
const getChatmessageFromPKApi = useApi(chatmessageApi.getChatmessageFromPK)
|
const getChatmessageFromPKApi = useApi(chatmessageApi.getChatmessageFromPK)
|
||||||
|
const getStoragePathFromServer = useApi(chatmessageApi.getStoragePath)
|
||||||
|
let storagePath = ''
|
||||||
|
|
||||||
const onStartDateSelected = (date) => {
|
const onStartDateSelected = (date) => {
|
||||||
setStartDate(date)
|
setStartDate(date)
|
||||||
@@ -128,16 +130,35 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportMessages = () => {
|
const exportMessages = async () => {
|
||||||
|
if (!storagePath && getStoragePathFromServer.data) {
|
||||||
|
storagePath = getStoragePathFromServer.data.storagePath
|
||||||
|
}
|
||||||
const obj = {}
|
const obj = {}
|
||||||
|
let fileSeparator = '/'
|
||||||
|
if ('windows' === getOS()) {
|
||||||
|
fileSeparator = '\\'
|
||||||
|
}
|
||||||
for (let i = 0; i < allChatlogs.length; i += 1) {
|
for (let i = 0; i < allChatlogs.length; i += 1) {
|
||||||
const chatmsg = allChatlogs[i]
|
const chatmsg = allChatlogs[i]
|
||||||
const chatPK = getChatPK(chatmsg)
|
const chatPK = getChatPK(chatmsg)
|
||||||
|
let filePaths = []
|
||||||
|
if (chatmsg.fileUploads) {
|
||||||
|
chatmsg.fileUploads = JSON.parse(chatmsg.fileUploads)
|
||||||
|
chatmsg.fileUploads.forEach((file) => {
|
||||||
|
if (file.type === 'stored-file') {
|
||||||
|
filePaths.push(
|
||||||
|
`${storagePath}${fileSeparator}${chatmsg.chatflowid}${fileSeparator}${chatmsg.chatId}${fileSeparator}${file.name}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
const msg = {
|
const msg = {
|
||||||
content: chatmsg.content,
|
content: chatmsg.content,
|
||||||
role: chatmsg.role === 'apiMessage' ? 'bot' : 'user',
|
role: chatmsg.role === 'apiMessage' ? 'bot' : 'user',
|
||||||
time: chatmsg.createdDate
|
time: chatmsg.createdDate
|
||||||
}
|
}
|
||||||
|
if (filePaths.length) msg.filePaths = filePaths
|
||||||
if (chatmsg.sourceDocuments) msg.sourceDocuments = JSON.parse(chatmsg.sourceDocuments)
|
if (chatmsg.sourceDocuments) msg.sourceDocuments = JSON.parse(chatmsg.sourceDocuments)
|
||||||
if (chatmsg.usedTools) msg.usedTools = JSON.parse(chatmsg.usedTools)
|
if (chatmsg.usedTools) msg.usedTools = JSON.parse(chatmsg.usedTools)
|
||||||
if (chatmsg.fileAnnotations) msg.fileAnnotations = JSON.parse(chatmsg.fileAnnotations)
|
if (chatmsg.fileAnnotations) msg.fileAnnotations = JSON.parse(chatmsg.fileAnnotations)
|
||||||
@@ -373,6 +394,8 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (getChatmessageApi.data) {
|
if (getChatmessageApi.data) {
|
||||||
|
getStoragePathFromServer.request()
|
||||||
|
|
||||||
setAllChatLogs(getChatmessageApi.data)
|
setAllChatLogs(getChatmessageApi.data)
|
||||||
const chatPK = processChatLogs(getChatmessageApi.data)
|
const chatPK = processChatLogs(getChatmessageApi.data)
|
||||||
setSelectedMessageIndex(0)
|
setSelectedMessageIndex(0)
|
||||||
|
|||||||
@@ -607,3 +607,25 @@ export const getConfigExamplesForCurl = (configData, bodyType, isMultiple, stopN
|
|||||||
}
|
}
|
||||||
return finalStr
|
return finalStr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getOS = () => {
|
||||||
|
let userAgent = window.navigator.userAgent.toLowerCase(),
|
||||||
|
macosPlatforms = /(macintosh|macintel|macppc|mac68k|macos)/i,
|
||||||
|
windowsPlatforms = /(win32|win64|windows|wince)/i,
|
||||||
|
iosPlatforms = /(iphone|ipad|ipod)/i,
|
||||||
|
os = null
|
||||||
|
|
||||||
|
if (macosPlatforms.test(userAgent)) {
|
||||||
|
os = 'macos'
|
||||||
|
} else if (iosPlatforms.test(userAgent)) {
|
||||||
|
os = 'ios'
|
||||||
|
} else if (windowsPlatforms.test(userAgent)) {
|
||||||
|
os = 'windows'
|
||||||
|
} else if (/android/.test(userAgent)) {
|
||||||
|
os = 'android'
|
||||||
|
} else if (!os && /linux/.test(userAgent)) {
|
||||||
|
os = 'linux'
|
||||||
|
}
|
||||||
|
|
||||||
|
return os
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user