mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
Merge branch 'main' into feature/output-parsers
# Conflicts: # packages/ui/src/views/chatmessage/ChatMessage.js
This commit is contained in:
@@ -416,6 +416,23 @@ export const getInputVariables = (paramValue) => {
|
||||
return inputVariables
|
||||
}
|
||||
|
||||
export const removeDuplicateURL = (message) => {
|
||||
const visitedURLs = []
|
||||
const newSourceDocuments = []
|
||||
|
||||
if (!message.sourceDocuments) return newSourceDocuments
|
||||
|
||||
message.sourceDocuments.forEach((source) => {
|
||||
if (isValidURL(source.metadata.source) && !visitedURLs.includes(source.metadata.source)) {
|
||||
visitedURLs.push(source.metadata.source)
|
||||
newSourceDocuments.push(source)
|
||||
} else if (!isValidURL(source.metadata.source)) {
|
||||
newSourceDocuments.push(source)
|
||||
}
|
||||
})
|
||||
return newSourceDocuments
|
||||
}
|
||||
|
||||
export const isValidURL = (url) => {
|
||||
try {
|
||||
return new URL(url)
|
||||
|
||||
Reference in New Issue
Block a user