mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Merge branch 'main' into feature/ChatHistory2
This commit is contained in:
@@ -79,7 +79,10 @@ class AWSBedrockEmbedding_Embeddings implements INode {
|
|||||||
label: 'Model Name',
|
label: 'Model Name',
|
||||||
name: 'model',
|
name: 'model',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
options: [{ label: 'amazon.titan-embed-text-v1', name: 'amazon.titan-embed-text-v1' }],
|
options: [
|
||||||
|
{ label: 'amazon.titan-embed-text-v1', name: 'amazon.titan-embed-text-v1' },
|
||||||
|
{ label: 'amazon.titan-embed-g1-text-02', name: 'amazon.titan-embed-g1-text-02' }
|
||||||
|
],
|
||||||
default: 'amazon.titan-embed-text-v1'
|
default: 'amazon.titan-embed-text-v1'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class Qdrant_Existing_VectorStores implements INode {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Qdrant Load Existing Index'
|
this.label = 'Qdrant Load Existing Index'
|
||||||
this.name = 'qdrantExistingIndex'
|
this.name = 'qdrantExistingIndex'
|
||||||
this.version = 1.0
|
this.version = 2.0
|
||||||
this.type = 'Qdrant'
|
this.type = 'Qdrant'
|
||||||
this.icon = 'qdrant.png'
|
this.icon = 'qdrant.png'
|
||||||
this.category = 'Vector Stores'
|
this.category = 'Vector Stores'
|
||||||
@@ -55,8 +55,39 @@ class Qdrant_Existing_VectorStores implements INode {
|
|||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Qdrant Collection Cofiguration',
|
label: 'Vector Dimension',
|
||||||
|
name: 'qdrantVectorDimension',
|
||||||
|
type: 'number',
|
||||||
|
default: 1536,
|
||||||
|
additionalParams: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Similarity',
|
||||||
|
name: 'qdrantSimilarity',
|
||||||
|
description: 'Similarity measure used in Qdrant.',
|
||||||
|
type: 'options',
|
||||||
|
default: 'Cosine',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'Cosine',
|
||||||
|
name: 'Cosine'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Euclid',
|
||||||
|
name: 'Euclid'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Dot',
|
||||||
|
name: 'Dot'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
additionalParams: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Additional Collection Cofiguration',
|
||||||
name: 'qdrantCollectionConfiguration',
|
name: 'qdrantCollectionConfiguration',
|
||||||
|
description:
|
||||||
|
'Refer to <a target="_blank" href="https://qdrant.tech/documentation/concepts/collections">collection docs</a> for more reference',
|
||||||
type: 'json',
|
type: 'json',
|
||||||
optional: true,
|
optional: true,
|
||||||
additionalParams: true
|
additionalParams: true
|
||||||
@@ -98,6 +129,8 @@ class Qdrant_Existing_VectorStores implements INode {
|
|||||||
const collectionName = nodeData.inputs?.qdrantCollection as string
|
const collectionName = nodeData.inputs?.qdrantCollection as string
|
||||||
let qdrantCollectionConfiguration = nodeData.inputs?.qdrantCollectionConfiguration
|
let qdrantCollectionConfiguration = nodeData.inputs?.qdrantCollectionConfiguration
|
||||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||||
|
const qdrantSimilarity = nodeData.inputs?.qdrantSimilarity
|
||||||
|
const qdrantVectorDimension = nodeData.inputs?.qdrantVectorDimension
|
||||||
const output = nodeData.outputs?.output as string
|
const output = nodeData.outputs?.output as string
|
||||||
const topK = nodeData.inputs?.topK as string
|
const topK = nodeData.inputs?.topK as string
|
||||||
let queryFilter = nodeData.inputs?.queryFilter
|
let queryFilter = nodeData.inputs?.queryFilter
|
||||||
@@ -126,7 +159,14 @@ class Qdrant_Existing_VectorStores implements INode {
|
|||||||
typeof qdrantCollectionConfiguration === 'object'
|
typeof qdrantCollectionConfiguration === 'object'
|
||||||
? qdrantCollectionConfiguration
|
? qdrantCollectionConfiguration
|
||||||
: JSON.parse(qdrantCollectionConfiguration)
|
: JSON.parse(qdrantCollectionConfiguration)
|
||||||
dbConfig.collectionConfig = qdrantCollectionConfiguration
|
dbConfig.collectionConfig = {
|
||||||
|
...qdrantCollectionConfiguration,
|
||||||
|
vectors: {
|
||||||
|
...qdrantCollectionConfiguration.vectors,
|
||||||
|
size: qdrantVectorDimension ? parseInt(qdrantVectorDimension, 10) : 1536,
|
||||||
|
distance: qdrantSimilarity ?? 'Cosine'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryFilter) {
|
if (queryFilter) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class QdrantUpsert_VectorStores implements INode {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Qdrant Upsert Document'
|
this.label = 'Qdrant Upsert Document'
|
||||||
this.name = 'qdrantUpsert'
|
this.name = 'qdrantUpsert'
|
||||||
this.version = 1.0
|
this.version = 2.0
|
||||||
this.type = 'Qdrant'
|
this.type = 'Qdrant'
|
||||||
this.icon = 'qdrant.png'
|
this.icon = 'qdrant.png'
|
||||||
this.category = 'Vector Stores'
|
this.category = 'Vector Stores'
|
||||||
@@ -62,6 +62,35 @@ class QdrantUpsert_VectorStores implements INode {
|
|||||||
name: 'qdrantCollection',
|
name: 'qdrantCollection',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Vector Dimension',
|
||||||
|
name: 'qdrantVectorDimension',
|
||||||
|
type: 'number',
|
||||||
|
default: 1536,
|
||||||
|
additionalParams: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Similarity',
|
||||||
|
name: 'qdrantSimilarity',
|
||||||
|
description: 'Similarity measure used in Qdrant.',
|
||||||
|
type: 'options',
|
||||||
|
default: 'Cosine',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'Cosine',
|
||||||
|
name: 'Cosine'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Euclid',
|
||||||
|
name: 'Euclid'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Dot',
|
||||||
|
name: 'Dot'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
additionalParams: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Top K',
|
label: 'Top K',
|
||||||
name: 'topK',
|
name: 'topK',
|
||||||
@@ -99,6 +128,9 @@ class QdrantUpsert_VectorStores implements INode {
|
|||||||
const collectionName = nodeData.inputs?.qdrantCollection as string
|
const collectionName = nodeData.inputs?.qdrantCollection as string
|
||||||
const docs = nodeData.inputs?.document as Document[]
|
const docs = nodeData.inputs?.document as Document[]
|
||||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||||
|
const qdrantSimilarity = nodeData.inputs?.qdrantSimilarity
|
||||||
|
const qdrantVectorDimension = nodeData.inputs?.qdrantVectorDimension
|
||||||
|
|
||||||
const output = nodeData.outputs?.output as string
|
const output = nodeData.outputs?.output as string
|
||||||
const topK = nodeData.inputs?.topK as string
|
const topK = nodeData.inputs?.topK as string
|
||||||
const k = topK ? parseFloat(topK) : 4
|
const k = topK ? parseFloat(topK) : 4
|
||||||
@@ -121,7 +153,13 @@ class QdrantUpsert_VectorStores implements INode {
|
|||||||
const dbConfig: QdrantLibArgs = {
|
const dbConfig: QdrantLibArgs = {
|
||||||
client,
|
client,
|
||||||
url: qdrantServerUrl,
|
url: qdrantServerUrl,
|
||||||
collectionName
|
collectionName,
|
||||||
|
collectionConfig: {
|
||||||
|
vectors: {
|
||||||
|
size: qdrantVectorDimension ? parseInt(qdrantVectorDimension, 10) : 1536,
|
||||||
|
distance: qdrantSimilarity ?? 'Cosine'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const retrieverConfig: RetrieverConfig = {
|
const retrieverConfig: RetrieverConfig = {
|
||||||
|
|||||||
@@ -812,18 +812,21 @@ export class App {
|
|||||||
* @param {Response} res
|
* @param {Response} res
|
||||||
* @param {ChatFlow} chatflow
|
* @param {ChatFlow} chatflow
|
||||||
*/
|
*/
|
||||||
async validateKey(req: Request, res: Response, chatflow: ChatFlow) {
|
async validateKey(req: Request, chatflow: ChatFlow) {
|
||||||
const chatFlowApiKeyId = chatflow.apikeyid
|
const chatFlowApiKeyId = chatflow.apikeyid
|
||||||
const authorizationHeader = (req.headers['Authorization'] as string) ?? (req.headers['authorization'] as string) ?? ''
|
if (!chatFlowApiKeyId) return true
|
||||||
|
|
||||||
if (chatFlowApiKeyId && !authorizationHeader) return res.status(401).send(`Unauthorized`)
|
const authorizationHeader = (req.headers['Authorization'] as string) ?? (req.headers['authorization'] as string) ?? ''
|
||||||
|
if (chatFlowApiKeyId && !authorizationHeader) return false
|
||||||
|
|
||||||
const suppliedKey = authorizationHeader.split(`Bearer `).pop()
|
const suppliedKey = authorizationHeader.split(`Bearer `).pop()
|
||||||
if (chatFlowApiKeyId && suppliedKey) {
|
if (suppliedKey) {
|
||||||
const keys = await getAPIKeys()
|
const keys = await getAPIKeys()
|
||||||
const apiSecret = keys.find((key) => key.id === chatFlowApiKeyId)?.apiSecret
|
const apiSecret = keys.find((key) => key.id === chatFlowApiKeyId)?.apiSecret
|
||||||
if (!compareKeys(apiSecret, suppliedKey)) return res.status(401).send(`Unauthorized`)
|
if (!compareKeys(apiSecret, suppliedKey)) return false
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -896,7 +899,8 @@ export class App {
|
|||||||
const userMessageDateTime = new Date()
|
const userMessageDateTime = new Date()
|
||||||
|
|
||||||
if (!isInternal) {
|
if (!isInternal) {
|
||||||
await this.validateKey(req, res, chatflow)
|
const isKeyValidated = await this.validateKey(req, chatflow)
|
||||||
|
if (!isKeyValidated) return res.status(401).send('Unauthorized')
|
||||||
}
|
}
|
||||||
|
|
||||||
let isStreamValid = false
|
let isStreamValid = false
|
||||||
|
|||||||
Reference in New Issue
Block a user