AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { createAction, Property } from '@activepieces/pieces-framework';
import { qdrantAuth } from '../auth';
import { qdrantClient } from '../common/client';
import { qdrantProps } from '../common/props';
import { qdrantUtils } from '../common/utils';
import { searchPointsOutputSchema } from '../output-schemas';
export const searchPoints = createAction({
auth: qdrantAuth,
name: 'search_points',
outputSchema: searchPointsOutputSchema,
classification: 'SEARCH',
displayName: 'Search Points',
description: 'Search for points closest to your given vector (= embedding)',
audience: 'human',
aiMetadata: {
description:
'Run a vector-similarity search against a Qdrant collection, returning the points nearest to a supplied query embedding, optionally narrowed by a payload filter and steered away from an optional negative vector. Use this for semantic / nearest-neighbor retrieval; use Get Points instead when selecting by id or metadata only. The query vector is passed as a file and must match the collection dimensionality. Read-only and idempotent.',
idempotent: true,
},
props: {
collectionName: qdrantProps.collectionName({ required: true }),
vector: Property.File({
displayName: 'Embedding',
required: true,
description: 'The vector (= embedding) you want to search for.',
}),
must: qdrantProps.must({ required: false }),
must_not: qdrantProps.mustNot({ required: false }),
negativeVector: Property.File({
displayName: 'Negative Vector',
required: false,
description: 'The vector (= embedding) you want to be the farthest.',
}),
limitResult: Property.Number({
displayName: 'Limit Result',
required: false,
description: 'The max number of results you want to get.',
defaultValue: 20,
}),
},
run: async ({ auth, propsValue }) => {
const client = qdrantClient.create({ auth });
const { must, must_not } = propsValue;
const filter = qdrantUtils.convertToFilter({
must,
must_not,
});
let vector = Array.from(
qdrantUtils.decodeEmbeddings({ data: propsValue.vector.data })[0]
);
const negativeVector = propsValue.negativeVector
? Array.from(
qdrantUtils.decodeEmbeddings({ data: propsValue.vector.data })[0]
)
: undefined;
if (
!(vector instanceof Array) ||
(negativeVector != undefined && !(negativeVector instanceof Array))
)
throw new Error('Vectors should be arrays of numbers');
const limit = propsValue.limitResult ?? 20;
if (negativeVector) {
vector = vector.map((vec, i) => vec * 2 + negativeVector[i]);
}
return await client.search(propsValue.collectionName, {
vector,
filter,
limit,
with_payload: true,
});
},
});