parent
9e88c45051
commit
78e60e22d2
|
|
@ -214,7 +214,7 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
|
||||||
data: s,
|
data: s,
|
||||||
preview: s,
|
preview: s,
|
||||||
type: 'url',
|
type: 'url',
|
||||||
name: s.substring(s.lastIndexOf('/') + 1)
|
name: s ? s.substring(s.lastIndexOf('/') + 1) : ''
|
||||||
}
|
}
|
||||||
setPreviews((prevPreviews) => [...prevPreviews, upload])
|
setPreviews((prevPreviews) => [...prevPreviews, upload])
|
||||||
})
|
})
|
||||||
|
|
@ -222,14 +222,14 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
|
||||||
item.getAsString((s) => {
|
item.getAsString((s) => {
|
||||||
if (s.indexOf('href') === -1) return
|
if (s.indexOf('href') === -1) return
|
||||||
//extract href
|
//extract href
|
||||||
let start = s.substring(s.indexOf('href') + 6)
|
let start = s ? s.substring(s.indexOf('href') + 6) : ''
|
||||||
let hrefStr = start.substring(0, start.indexOf('"'))
|
let hrefStr = start.substring(0, start.indexOf('"'))
|
||||||
|
|
||||||
let upload = {
|
let upload = {
|
||||||
data: hrefStr,
|
data: hrefStr,
|
||||||
preview: hrefStr,
|
preview: hrefStr,
|
||||||
type: 'url',
|
type: 'url',
|
||||||
name: hrefStr.substring(hrefStr.lastIndexOf('/') + 1)
|
name: hrefStr ? hrefStr.substring(hrefStr.lastIndexOf('/') + 1) : ''
|
||||||
}
|
}
|
||||||
setPreviews((prevPreviews) => [...prevPreviews, upload])
|
setPreviews((prevPreviews) => [...prevPreviews, upload])
|
||||||
})
|
})
|
||||||
|
|
@ -282,7 +282,7 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
|
||||||
if (pos === -1) {
|
if (pos === -1) {
|
||||||
mimeType = blob.type
|
mimeType = blob.type
|
||||||
} else {
|
} else {
|
||||||
mimeType = blob.type.substring(0, pos)
|
mimeType = blob.type ? blob.type.substring(0, pos) : ''
|
||||||
}
|
}
|
||||||
// read blob and add to previews
|
// read blob and add to previews
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
|
|
@ -598,6 +598,26 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getLabel = (URL, source) => {
|
||||||
|
if (URL && typeof URL === 'object') {
|
||||||
|
if (URL.pathname && typeof URL.pathname === 'string') {
|
||||||
|
if (URL.pathname.substring(0, 15) === '/') {
|
||||||
|
return URL.host || ''
|
||||||
|
} else {
|
||||||
|
return `${URL.pathname.substring(0, 15)}...`
|
||||||
|
}
|
||||||
|
} else if (URL.host) {
|
||||||
|
return URL.host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source && source.pageContent && typeof source.pageContent === 'string') {
|
||||||
|
return `${source.pageContent.substring(0, 15)}...`
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
const downloadFile = async (fileAnnotation) => {
|
const downloadFile = async (fileAnnotation) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
|
|
@ -1180,13 +1200,7 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
|
||||||
<Chip
|
<Chip
|
||||||
size='small'
|
size='small'
|
||||||
key={index}
|
key={index}
|
||||||
label={
|
label={getLabel(URL, source) || ''}
|
||||||
URL
|
|
||||||
? URL.pathname.substring(0, 15) === '/'
|
|
||||||
? URL.host
|
|
||||||
: `${URL.pathname.substring(0, 15)}...`
|
|
||||||
: `${source.pageContent.substring(0, 15)}...`
|
|
||||||
}
|
|
||||||
component='a'
|
component='a'
|
||||||
sx={{ mr: 1, mb: 1 }}
|
sx={{ mr: 1, mb: 1 }}
|
||||||
variant='outlined'
|
variant='outlined'
|
||||||
|
|
@ -1390,13 +1404,7 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
|
||||||
<Chip
|
<Chip
|
||||||
size='small'
|
size='small'
|
||||||
key={index}
|
key={index}
|
||||||
label={
|
label={getLabel(URL, source) || ''}
|
||||||
URL
|
|
||||||
? URL.pathname.substring(0, 15) === '/'
|
|
||||||
? URL.host
|
|
||||||
: `${URL.pathname.substring(0, 15)}...`
|
|
||||||
: `${source.pageContent.substring(0, 15)}...`
|
|
||||||
}
|
|
||||||
component='a'
|
component='a'
|
||||||
sx={{ mr: 1, mb: 1 }}
|
sx={{ mr: 1, mb: 1 }}
|
||||||
variant='outlined'
|
variant='outlined'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue