mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
Redis Vector Store - addition of similaritySearchVectorWithScore method and other updates
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Escapes all '-' characters.
|
||||
* Redis Search considers '-' as a negative operator, hence we need
|
||||
* to escape it
|
||||
*/
|
||||
export const escapeSpecialChars = (str: string) => {
|
||||
return str.replaceAll('-', '\\-')
|
||||
}
|
||||
|
||||
export const escapeAllStrings = (obj: object) => {
|
||||
Object.keys(obj).forEach((key: string) => {
|
||||
// @ts-ignore
|
||||
let item = obj[key]
|
||||
if (typeof item === 'object') {
|
||||
escapeAllStrings(item)
|
||||
} else if (typeof item === 'string') {
|
||||
// @ts-ignore
|
||||
obj[key] = escapeSpecialChars(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const unEscapeSpecialChars = (str: string) => {
|
||||
return str.replaceAll('\\-', '-')
|
||||
}
|
||||
Reference in New Issue
Block a user