mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
add hyperlink
This commit is contained in:
@@ -401,3 +401,11 @@ export const getInputVariables = (paramValue) => {
|
|||||||
}
|
}
|
||||||
return inputVariables
|
return inputVariables
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isValidURL = (url) => {
|
||||||
|
try {
|
||||||
|
return new URL(url)
|
||||||
|
} catch (err) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import { baseURL, maxScroll } from 'store/constant'
|
|||||||
|
|
||||||
import robotPNG from 'assets/images/robot.png'
|
import robotPNG from 'assets/images/robot.png'
|
||||||
import userPNG from 'assets/images/account.png'
|
import userPNG from 'assets/images/account.png'
|
||||||
|
import { isValidURL } from 'utils/genericHelper'
|
||||||
|
|
||||||
export const ChatMessage = ({ open, chatflowid, isDialog }) => {
|
export const ChatMessage = ({ open, chatflowid, isDialog }) => {
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
@@ -59,6 +60,10 @@ export const ChatMessage = ({ open, chatflowid, isDialog }) => {
|
|||||||
setSourceDialogOpen(true)
|
setSourceDialogOpen(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onURLClick = (data) => {
|
||||||
|
window.open(data, '_blank')
|
||||||
|
}
|
||||||
|
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
if (ps.current) {
|
if (ps.current) {
|
||||||
ps.current.scrollTo({ top: maxScroll })
|
ps.current.scrollTo({ top: maxScroll })
|
||||||
@@ -320,16 +325,23 @@ export const ChatMessage = ({ open, chatflowid, isDialog }) => {
|
|||||||
{message.sourceDocuments && (
|
{message.sourceDocuments && (
|
||||||
<div style={{ display: 'block', flexDirection: 'row', width: '100%' }}>
|
<div style={{ display: 'block', flexDirection: 'row', width: '100%' }}>
|
||||||
{message.sourceDocuments.map((source, index) => {
|
{message.sourceDocuments.map((source, index) => {
|
||||||
|
const URL = isValidURL(source.metadata.source)
|
||||||
return (
|
return (
|
||||||
<Chip
|
<Chip
|
||||||
size='small'
|
size='small'
|
||||||
key={index}
|
key={index}
|
||||||
label={`${source.pageContent.substring(0, 15)}...`}
|
label={
|
||||||
|
URL
|
||||||
|
? `${(URL.hostname + 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'
|
||||||
clickable
|
clickable
|
||||||
onClick={() => onSourceDialogClick(source)}
|
onClick={() =>
|
||||||
|
URL ? onURLClick(source.metadata.source) : onSourceDialogClick(source)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in New Issue
Block a user