Skip to content

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

feat(qdrant): add AI actions and output schemas (#16812)

Kishan Parmar1fe94ffcb124
diff --git a/packages/pieces/community/qdrant/package.json b/packages/pieces/community/qdrant/package.json
index da5a38040a4..3d98d8d1eaa 100644
--- a/packages/pieces/community/qdrant/package.json
+++ b/packages/pieces/community/qdrant/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-qdrant",
- "version": "0.3.7",
+ "version": "0.4.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/qdrant/src/index.ts b/packages/pieces/community/qdrant/src/index.ts
index b06869274bb..22e69dd2ce0 100644
--- a/packages/pieces/community/qdrant/src/index.ts
+++ b/packages/pieces/community/qdrant/src/index.ts
@@ -1,50 +1,22 @@
-import {
- createPiece,
- PieceAuth,
- Property,
-} from '@activepieces/pieces-framework';
-import { PieceCategory } from '@activepieces/pieces-framework';
+import { createCustomApiCallAction } from '@activepieces/pieces-common';
+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';
+
import { addPointsToCollection } from './lib/actions/add-points';
+import { qdrantAiActions } from './lib/actions/ai';
import { deleteCollection } from './lib/actions/delete-collection';
import { deletePoints } from './lib/actions/delete-points';
import { collectionInfos } from './lib/actions/get-collection-infos';
import { collectionList } from './lib/actions/get-collection-list';
import { getPoints } from './lib/actions/get-points';
import { searchPoints } from './lib/actions/search-points';
-
-const qdrantConnectionDescription = `
-### Using Qdrant cloud
-1. Connect to your [Qdrant cloud account](https://cloud.qdrant.io)
-2. Create a new cluster if it's the first time you use Qdrant
-3. Go to Data Access Control and create a new api key and copy it
-4. Go to clusters, click on the arrow \`>\` and copy the Cluster URL.
-
-### Using self-hosted Qdrant
-Try to create your own qdrant instance using the [documentation guides](https://qdrant.tech/documentation/guides/)
-`;
-
-export const qdrantAuth = PieceAuth.CustomAuth({
- description: qdrantConnectionDescription,
- props: {
- serverAddress: Property.ShortText({
- displayName: 'Server Address',
- required: true,
- description: 'The url of the Qdrant instance.',
- }),
- key: PieceAuth.SecretText({
- displayName: 'API KEY',
- required: true,
- description: 'Enter the API Key of your Qdrant account',
- }),
- },
- required: true,
-});
+import { qdrantAuth } from './lib/auth';
+import { qdrantClient } from './lib/common/client';
export const qdrant = createPiece({
displayName: 'Qdrant',
description: 'Make any action on your qdrant vector database',
auth: qdrantAuth,
- minimumSupportedRelease: '0.30.0',
+ minimumSupportedRelease: '0.88.2',
logoUrl: 'https://cdn.activepieces.com/pieces/qdrant.png',
authors: ["ArmanGiau3","kishanprmr","abuaboud"],
categories: [PieceCategory.DEVELOPER_TOOLS],
@@ -56,6 +28,12 @@ export const qdrant = createPiece({
deletePoints,
getPoints,
searchPoints,
+ ...qdrantAiActions,
+ createCustomApiCallAction({
+ auth: qdrantAuth,
+ baseUrl: (auth) => (auth ? qdrantClient.baseUrl({ auth }) : ''),
+ authMapping: async (auth) => ({ 'api-key': auth.props.key }),
+ }),
],
triggers: [],
});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/add-points.ts b/packages/pieces/community/qdrant/src/lib/actions/add-points.ts
index 6392d1a1ae5..00cfa3fc2d0 100644
--- a/packages/pieces/community/qdrant/src/lib/actions/add-points.ts
+++ b/packages/pieces/community/qdrant/src/lib/actions/add-points.ts
@@ -1,25 +1,30 @@
-import { QdrantClient } from '@qdrant/js-client-rest';
-import { qdrantAuth } from '../..';
import { createAction, Property } from '@activepieces/pieces-framework';
import { randomUUID } from 'crypto';
-import { collectionName, decodeEmbeddings } from '../common';
+
+import { qdrantAuth } from '../auth';
+import { qdrantClient } from '../common/client';
+import { qdrantProps } from '../common/props';
+import type { QdrantDistance } from '../common/types';
+import { qdrantUtils } from '../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../output-schemas';
export const addPointsToCollection = createAction({
auth: qdrantAuth,
requireAuth: true,
name: 'add_points_to_collection',
+ outputSchema: qdrantUpdateResultOutputSchema,
classification: 'WRITE',
displayName: 'Add points to collection',
description:
'Insert a point (= embedding or vector + other infos) to a specific collection, if the collection does not exist it will be created',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Upsert one or more points (vectors plus optional payload) into a Qdrant collection, auto-creating the collection with the chosen distance metric if it does not yet exist. Use to load embeddings into a vector store. Embeddings are passed as a file and must all share the same dimensionality. Not idempotent: when point ids are omitted they are randomly generated, so each call appends new points; supply stable ids to overwrite the same points instead.',
idempotent: false,
},
props: {
- collectionName,
+ collectionName: qdrantProps.collectionName({ required: true }),
embeddings: Property.File({
displayName: 'Embeddings',
description: 'Embeddings (= vectors) for the points',
@@ -31,7 +36,7 @@ export const addPointsToCollection = createAction({
'The ids of the embeddings for the points. If not provided, the ids will be generated automatically',
required: false,
}),
- distance: Property.StaticDropdown({
+ distance: Property.StaticDropdown<QdrantDistance, true>({
displayName: 'Calculation Method of distance',
description:
"The calculation method helps to rank vectors when you want to find the closest points, the method to use depends on the model who's created the embeddings, see the documentation of your model",
@@ -64,11 +69,10 @@ export const addPointsToCollection = createAction({
}),
},
run: async ({ auth, propsValue }) => {
- const client = new QdrantClient({
- apiKey: auth.props.key,
- url: auth.props.serverAddress,
+ const client = qdrantClient.create({ auth });
+ const embeddings = qdrantUtils.decodeEmbeddings({
+ data: propsValue.embeddings.data,
});
- const embeddings = decodeEmbeddings(propsValue.embeddings.data);
const numberOfEmbeddings = embeddings.length;
const embeddingsLen = embeddings[0].length;
@@ -80,7 +84,9 @@ export const addPointsToCollection = createAction({
);
}
- const embeddingsIds = (propsValue.embeddingsIds as string[]) ?? [];
+ const embeddingsIds = (propsValue.embeddingsIds ?? []).map(
+ qdrantUtils.toPointId
+ );
const autoEmbeddingsIds = embeddingsIds.length === 0;
@@ -101,14 +107,13 @@ export const addPointsToCollection = createAction({
});
}
-
const collections = (await client.getCollections()).collections;
- const collectionName = propsValue.collectionName as string;
+ const collectionName = propsValue.collectionName;
if (!collections.find((collection) => collection.name === collectionName)) {
await client.createCollection(collectionName, {
vectors: {
size: embeddingsLen,
- distance: propsValue.distance as 'Dot' | 'Cosine' | 'Euclid',
+ distance: propsValue.distance,
on_disk: propsValue.storage === 'Disk',
},
on_disk_payload: propsValue.storage === 'Disk',
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/clear-payload.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/clear-payload.ts
new file mode 100644
index 00000000000..717ba529372
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/clear-payload.ts
@@ -0,0 +1,36 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const clearPayloadAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_clear_payload',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Clear Payload',
+ description: 'Removes the whole payload from points.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Remove the entire payload from the points selected by exactly one of Point IDs or Filter. The vectors stay.',
+ idempotent: false,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ pointIds: qdrantAiProps.pointIds({ required: false }),
+ filter: qdrantAiProps.filter({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.clearPayload({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ ...qdrantUtils.pointsSelector({ pointIds: propsValue.pointIds, filter: propsValue.filter }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/collection-exists.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/collection-exists.ts
new file mode 100644
index 00000000000..b71c4e3d5dc
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/collection-exists.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantCollectionExistsOutputSchema } from '../../output-schemas';
+
+export const collectionExistsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_collection_exists',
+ outputSchema: qdrantCollectionExistsOutputSchema,
+ displayName: 'Collection Exists',
+ description: 'Checks whether a collection exists.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Check whether a collection with the given name exists, returning exists true or false instead of failing. Use before Create Collection, which fails on an existing name.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.collectionExists({ auth, collectionName: propsValue.collectionName });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/count-points.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/count-points.ts
new file mode 100644
index 00000000000..72db7b3c4cb
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/count-points.ts
@@ -0,0 +1,41 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantCountPointsOutputSchema } from '../../output-schemas';
+
+export const countPointsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_count_points',
+ outputSchema: qdrantCountPointsOutputSchema,
+ displayName: 'Count Points',
+ description: 'Counts the points in a collection.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Count the points in a collection, optionally only those matching a payload filter.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ filter: qdrantAiProps.filter({ required: false }),
+ exact: Property.Checkbox({
+ displayName: 'Exact',
+ description: 'Count exactly. Set false for a faster estimate. Defaults to true.',
+ required: false,
+ defaultValue: true,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.countPoints({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ filter: propsValue.filter,
+ exact: propsValue.exact,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/create-alias.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/create-alias.ts
new file mode 100644
index 00000000000..085908d0597
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/create-alias.ts
@@ -0,0 +1,46 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantSuccessOutputSchema } from '../../output-schemas';
+
+export const createAliasAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_create_alias',
+ outputSchema: qdrantSuccessOutputSchema,
+ displayName: 'Create Alias',
+ description: 'Creates an alias for a collection.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Point an alias at a collection, so readers can use a stable name while the collection behind it changes. If the alias already exists it is moved to this collection, so repeating the call converges on the same state.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({
+ required: true,
+ description: 'Collection the alias points to. Use List Collections to find it.',
+ }),
+ aliasName: Property.ShortText({
+ displayName: 'Alias Name',
+ description: 'New alias name, e.g. "products-live".',
+ required: true,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ const created = await qdrantApi.updateAliases({
+ auth,
+ actions: [
+ {
+ create_alias: {
+ collection_name: propsValue.collectionName,
+ alias_name: propsValue.aliasName,
+ },
+ },
+ ],
+ });
+ return { success: created };
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/create-collection.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/create-collection.ts
new file mode 100644
index 00000000000..5fc512e0729
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/create-collection.ts
@@ -0,0 +1,77 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantSuccessOutputSchema } from '../../output-schemas';
+
+export const createCollectionAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_create_collection',
+ outputSchema: qdrantSuccessOutputSchema,
+ displayName: 'Create Collection',
+ description: 'Creates a collection.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Create a collection with either one unnamed dense vector (Vector Size and Distance) or several named vectors, plus optional sparse vectors. Fails if the name already exists (check with Collection Exists). Points written later must use exactly these vector sizes and names.',
+ idempotent: false,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ vectorSize: Property.Number({
+ displayName: 'Vector Size',
+ description:
+ 'Dimension of the single unnamed dense vector, e.g. 1536. Set together with Distance, or use Named Vectors instead.',
+ required: false,
+ }),
+ distance: Property.StaticDropdown({
+ displayName: 'Distance',
+ description: 'Distance metric for the unnamed vector. Required with Vector Size.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Cosine', value: 'Cosine' },
+ { label: 'Euclidean', value: 'Euclid' },
+ { label: 'Dot', value: 'Dot' },
+ { label: 'Manhattan', value: 'Manhattan' },
+ ],
+ },
+ }),
+ namedVectors: Property.Json({
+ displayName: 'Named Vectors',
+ description:
+ 'Named dense vectors as a map of name to parameters, e.g. {"text": {"size": 768, "distance": "Cosine"}, "image": {"size": 512, "distance": "Dot"}}. Use instead of Vector Size.',
+ required: false,
+ }),
+ sparseVectors: Property.Json({
+ displayName: 'Sparse Vectors',
+ description: 'Named sparse vectors as a map of name to parameters, e.g. {"keywords": {}}.',
+ required: false,
+ }),
+ additionalSettings: Property.Json({
+ displayName: 'Additional Settings',
+ description:
+ 'Other create parameters, e.g. {"on_disk_payload": true, "hnsw_config": {"m": 16}}. The fields above take precedence.',
+ required: false,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ const { vectorSize, distance, namedVectors, sparseVectors, additionalSettings } = propsValue;
+ if (vectorSize !== undefined && namedVectors !== undefined) {
+ throw new Error('Set either Vector Size or Named Vectors, not both.');
+ }
+ const created = await qdrantApi.createCollection({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ ...additionalSettings,
+ ...(namedVectors !== undefined ? { vectors: namedVectors } : {}),
+ ...(vectorSize !== undefined ? { vectors: { size: vectorSize, distance } } : {}),
+ ...(sparseVectors !== undefined ? { sparse_vectors: sparseVectors } : {}),
+ },
+ });
+ return { success: created };
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/create-payload-index.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/create-payload-index.ts
new file mode 100644
index 00000000000..0ea3fe9d0ac
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/create-payload-index.ts
@@ -0,0 +1,56 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const createPayloadIndexAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_create_payload_index',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Create Payload Index',
+ description: 'Creates an index on a payload field.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Create an index on a payload field so filters, Facet Payload and ordering on it are fast; collections in strict mode only filter on indexed fields. Waits until the index is built. Creating an index that already exists with the same type is a no-op.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ fieldName: Property.ShortText({
+ displayName: 'Field Name',
+ description: 'Payload key to index; nested keys use dots, e.g. "metadata.city".',
+ required: true,
+ }),
+ fieldSchema: Property.StaticDropdown({
+ displayName: 'Field Type',
+ description: 'Type of the values stored in the field.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Keyword', value: 'keyword' },
+ { label: 'Integer', value: 'integer' },
+ { label: 'Float', value: 'float' },
+ { label: 'Boolean', value: 'bool' },
+ { label: 'Geo', value: 'geo' },
+ { label: 'Datetime', value: 'datetime' },
+ { label: 'Full Text', value: 'text' },
+ { label: 'UUID', value: 'uuid' },
+ ],
+ },
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.createPayloadIndex({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ field_name: propsValue.fieldName,
+ field_schema: propsValue.fieldSchema,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/create-snapshot.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/create-snapshot.ts
new file mode 100644
index 00000000000..cc288111d42
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/create-snapshot.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantCreateSnapshotOutputSchema } from '../../output-schemas';
+
+export const createSnapshotAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_create_snapshot',
+ outputSchema: qdrantCreateSnapshotOutputSchema,
+ displayName: 'Create Snapshot',
+ description: 'Creates a snapshot of a collection.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Create a snapshot (a full backup file stored on the Qdrant server) of a collection and wait until it is written. Returns the snapshot name that Delete Snapshot takes. Each call creates a new snapshot.',
+ idempotent: false,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.createSnapshot({ auth, collectionName: propsValue.collectionName });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/delete-alias.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-alias.ts
new file mode 100644
index 00000000000..b41df721c8e
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-alias.ts
@@ -0,0 +1,33 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantApi } from '../../common/api';
+import { qdrantSuccessOutputSchema } from '../../output-schemas';
+
+export const deleteAliasAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_delete_alias',
+ outputSchema: qdrantSuccessOutputSchema,
+ displayName: 'Delete Alias',
+ description: 'Deletes an alias.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description: 'Delete an alias. The collection it pointed to and its points are not affected.',
+ idempotent: false,
+ },
+ props: {
+ aliasName: Property.ShortText({
+ displayName: 'Alias Name',
+ description: 'Alias to delete. Use List Aliases to find it.',
+ required: true,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ const deleted = await qdrantApi.updateAliases({
+ auth,
+ actions: [{ delete_alias: { alias_name: propsValue.aliasName } }],
+ });
+ return { success: deleted };
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/delete-collection.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-collection.ts
new file mode 100644
index 00000000000..ae53489ebad
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-collection.ts
@@ -0,0 +1,31 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantSuccessOutputSchema } from '../../output-schemas';
+
+export const deleteCollectionAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_delete_collection',
+ outputSchema: qdrantSuccessOutputSchema,
+ displayName: 'Delete Collection',
+ description: 'Deletes a collection and all of its points.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently delete a collection and every point in it. Cannot be undone; run Create Snapshot first to keep a backup.',
+ idempotent: false,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ },
+ run: async ({ auth, propsValue }) => {
+ const deleted = await qdrantApi.deleteCollection({
+ auth,
+ collectionName: propsValue.collectionName,
+ });
+ return { success: deleted };
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/delete-payload-index.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-payload-index.ts
new file mode 100644
index 00000000000..8be040cab06
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-payload-index.ts
@@ -0,0 +1,37 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const deletePayloadIndexAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_delete_payload_index',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Delete Payload Index',
+ description: 'Deletes the index on a payload field.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Delete the index on a payload field. The payload values stay; only the index is removed.',
+ idempotent: false,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ fieldName: Property.ShortText({
+ displayName: 'Field Name',
+ description:
+ 'Indexed payload key, e.g. "metadata.city". Get Collection lists indexed fields under payload_schema.',
+ required: true,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.deletePayloadIndex({
+ auth,
+ collectionName: propsValue.collectionName,
+ fieldName: propsValue.fieldName,
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/delete-payload-keys.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-payload-keys.ts
new file mode 100644
index 00000000000..cf2af9961d1
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-payload-keys.ts
@@ -0,0 +1,42 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const deletePayloadKeysAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_delete_payload_keys',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Delete Payload Keys',
+ description: 'Removes payload keys from points.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Remove the given payload keys from the points selected by exactly one of Point IDs or Filter. Other keys and the vectors stay.',
+ idempotent: false,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ keys: Property.Array({
+ displayName: 'Keys',
+ description: 'Payload keys to remove, e.g. ["status", "metadata.city"].',
+ required: true,
+ }),
+ pointIds: qdrantAiProps.pointIds({ required: false }),
+ filter: qdrantAiProps.filter({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.deletePayloadKeys({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ keys: qdrantUtils.requireItems({ items: propsValue.keys, propName: 'Keys' }),
+ ...qdrantUtils.pointsSelector({ pointIds: propsValue.pointIds, filter: propsValue.filter }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/delete-points.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-points.ts
new file mode 100644
index 00000000000..f29789f9b78
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-points.ts
@@ -0,0 +1,36 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const deletePointsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_delete_points',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Delete Points',
+ description: 'Deletes points by ID or filter.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently delete the points selected by exactly one of Point IDs or Filter. Waits until applied.',
+ idempotent: false,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ pointIds: qdrantAiProps.pointIds({ required: false }),
+ filter: qdrantAiProps.filter({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.deletePoints({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ ...qdrantUtils.pointsSelector({ pointIds: propsValue.pointIds, filter: propsValue.filter }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/delete-snapshot.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-snapshot.ts
new file mode 100644
index 00000000000..0e269009f3c
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-snapshot.ts
@@ -0,0 +1,38 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantSuccessOutputSchema } from '../../output-schemas';
+
+export const deleteSnapshotAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_delete_snapshot',
+ outputSchema: qdrantSuccessOutputSchema,
+ displayName: 'Delete Snapshot',
+ description: 'Deletes a snapshot of a collection.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently delete one snapshot file of a collection. The collection itself is not affected.',
+ idempotent: false,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ snapshotName: Property.ShortText({
+ displayName: 'Snapshot Name',
+ description:
+ 'Snapshot file name, e.g. "products-2026-10-24-10-00-00.snapshot". Use List Snapshots to find it.',
+ required: true,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ const deleted = await qdrantApi.deleteSnapshot({
+ auth,
+ collectionName: propsValue.collectionName,
+ snapshotName: propsValue.snapshotName,
+ });
+ return { success: deleted };
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/delete-vectors.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-vectors.ts
new file mode 100644
index 00000000000..38d62bdec2d
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/delete-vectors.ts
@@ -0,0 +1,46 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const deleteVectorsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_delete_vectors',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Delete Vectors',
+ description: 'Removes named vectors from points.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Remove the given named vectors from the points selected by exactly one of Point IDs or Filter. The points and their other vectors stay; the unnamed vector cannot be removed.',
+ idempotent: false,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ vectorNames: Property.Array({
+ displayName: 'Vector Names',
+ description:
+ 'Names of the named vectors to remove, e.g. ["image"]. Get Collection lists the names.',
+ required: true,
+ }),
+ pointIds: qdrantAiProps.pointIds({ required: false }),
+ filter: qdrantAiProps.filter({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.deleteVectors({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ vector: qdrantUtils.requireItems({
+ items: propsValue.vectorNames,
+ propName: 'Vector Names',
+ }),
+ ...qdrantUtils.pointsSelector({ pointIds: propsValue.pointIds, filter: propsValue.filter }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/facet-payload.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/facet-payload.ts
new file mode 100644
index 00000000000..bb31d28ef65
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/facet-payload.ts
@@ -0,0 +1,52 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantFacetPayloadOutputSchema } from '../../output-schemas';
+
+export const facetPayloadAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_facet_payload',
+ outputSchema: qdrantFacetPayloadOutputSchema,
+ displayName: 'Facet Payload',
+ description: 'Counts the points per distinct value of a payload field.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Count how many points have each distinct value of a payload field, optionally within a filter, e.g. points per category. The field needs a keyword, integer, boolean or UUID payload index (Create Payload Index).',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ key: Property.ShortText({
+ displayName: 'Field Name',
+ description: 'Payload field to count the values of, e.g. "category".',
+ required: true,
+ }),
+ filter: qdrantAiProps.filter({ required: false }),
+ limit: qdrantAiProps.limit({
+ required: false,
+ description: 'Maximum number of distinct values to return. Defaults to 10.',
+ }),
+ exact: Property.Checkbox({
+ displayName: 'Exact',
+ description: 'Count exactly; slower on large collections. Defaults to false.',
+ required: false,
+ defaultValue: false,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.facet({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ key: propsValue.key,
+ filter: propsValue.filter,
+ limit: propsValue.limit,
+ exact: propsValue.exact,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/get-collection.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/get-collection.ts
new file mode 100644
index 00000000000..2b8449be7ae
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/get-collection.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantGetCollectionOutputSchema } from '../../output-schemas';
+
+export const getCollectionAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_get_collection',
+ outputSchema: qdrantGetCollectionOutputSchema,
+ displayName: 'Get Collection',
+ description: 'Gets the configuration and status of a collection.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ "Get one collection's configuration and status: vector size and distance (or named vectors), point count, indexing status and payload schema (indexed fields). Use before writing to learn the vector sizes and names the collection expects.",
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.getCollection({ auth, collectionName: propsValue.collectionName });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/get-points.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/get-points.ts
new file mode 100644
index 00000000000..9907e5e6cf6
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/get-points.ts
@@ -0,0 +1,42 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantGetPointsOutputSchema } from '../../output-schemas';
+
+export const getPointsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_get_points',
+ outputSchema: qdrantGetPointsOutputSchema,
+ displayName: 'Get Points',
+ description: 'Gets points by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Get points by id with their payload and, optionally, vectors. Ids that do not exist are left out of the result instead of failing.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ pointIds: qdrantAiProps.pointIds({ required: true }),
+ withPayload: qdrantAiProps.withPayload({ required: false }),
+ withVector: qdrantAiProps.withVector({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ const points = await qdrantApi.getPoints({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ ids: qdrantUtils
+ .requireItems({ items: propsValue.pointIds, propName: 'Point IDs' })
+ .map((id) => qdrantUtils.parsePointId({ id })),
+ with_payload: propsValue.withPayload ?? true,
+ with_vector: propsValue.withVector,
+ },
+ });
+ return { points, count: points.length };
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/index.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/index.ts
new file mode 100644
index 00000000000..f5fed878558
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/index.ts
@@ -0,0 +1,63 @@
+import { clearPayloadAction } from './clear-payload';
+import { collectionExistsAction } from './collection-exists';
+import { countPointsAction } from './count-points';
+import { createAliasAction } from './create-alias';
+import { createCollectionAction } from './create-collection';
+import { createPayloadIndexAction } from './create-payload-index';
+import { createSnapshotAction } from './create-snapshot';
+import { deleteAliasAction } from './delete-alias';
+import { deleteCollectionAction } from './delete-collection';
+import { deletePayloadIndexAction } from './delete-payload-index';
+import { deletePayloadKeysAction } from './delete-payload-keys';
+import { deletePointsAction } from './delete-points';
+import { deleteSnapshotAction } from './delete-snapshot';
+import { deleteVectorsAction } from './delete-vectors';
+import { facetPayloadAction } from './facet-payload';
+import { getCollectionAction } from './get-collection';
+import { getPointsAction } from './get-points';
+import { listAliasesAction } from './list-aliases';
+import { listCollectionAliasesAction } from './list-collection-aliases';
+import { listCollectionsAction } from './list-collections';
+import { listSnapshotsAction } from './list-snapshots';
+import { overwritePayloadAction } from './overwrite-payload';
+import { queryPointsAction } from './query-points';
+import { queryPointsGroupsAction } from './query-points-groups';
+import { renameAliasAction } from './rename-alias';
+import { scrollPointsAction } from './scroll-points';
+import { setPayloadAction } from './set-payload';
+import { updateCollectionAction } from './update-collection';
+import { updateVectorsAction } from './update-vectors';
+import { upsertPointsAction } from './upsert-points';
+
+export const qdrantAiActions = [
+ listCollectionsAction,
+ getCollectionAction,
+ collectionExistsAction,
+ createCollectionAction,
+ updateCollectionAction,
+ deleteCollectionAction,
+ listAliasesAction,
+ listCollectionAliasesAction,
+ createAliasAction,
+ renameAliasAction,
+ deleteAliasAction,
+ createSnapshotAction,
+ listSnapshotsAction,
+ deleteSnapshotAction,
+ createPayloadIndexAction,
+ deletePayloadIndexAction,
+ upsertPointsAction,
+ getPointsAction,
+ scrollPointsAction,
+ countPointsAction,
+ deletePointsAction,
+ setPayloadAction,
+ overwritePayloadAction,
+ deletePayloadKeysAction,
+ clearPayloadAction,
+ updateVectorsAction,
+ deleteVectorsAction,
+ queryPointsAction,
+ queryPointsGroupsAction,
+ facetPayloadAction,
+];
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/list-aliases.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/list-aliases.ts
new file mode 100644
index 00000000000..81fc839ab50
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/list-aliases.ts
@@ -0,0 +1,24 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantApi } from '../../common/api';
+import { qdrantListAliasesOutputSchema } from '../../output-schemas';
+
+export const listAliasesAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_list_aliases',
+ outputSchema: qdrantListAliasesOutputSchema,
+ displayName: 'List Aliases',
+ description: 'Lists all aliases and the collections they point to.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'List every alias in the instance with the collection it points to. An alias works wherever a collection name is accepted.',
+ idempotent: true,
+ },
+ props: {},
+ run: async ({ auth }) => {
+ return await qdrantApi.listAliases({ auth });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/list-collection-aliases.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/list-collection-aliases.ts
new file mode 100644
index 00000000000..a1189b31f29
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/list-collection-aliases.ts
@@ -0,0 +1,29 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantListAliasesOutputSchema } from '../../output-schemas';
+
+export const listCollectionAliasesAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_list_collection_aliases',
+ outputSchema: qdrantListAliasesOutputSchema,
+ displayName: 'List Collection Aliases',
+ description: 'Lists the aliases of a collection.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description: 'List the aliases that point to one collection.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.listCollectionAliases({
+ auth,
+ collectionName: propsValue.collectionName,
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/list-collections.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/list-collections.ts
new file mode 100644
index 00000000000..2f223a0e14a
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/list-collections.ts
@@ -0,0 +1,24 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantApi } from '../../common/api';
+import { qdrantListCollectionsOutputSchema } from '../../output-schemas';
+
+export const listCollectionsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_list_collections',
+ outputSchema: qdrantListCollectionsOutputSchema,
+ displayName: 'List Collections',
+ description: 'Lists all collections in the Qdrant instance.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'List the names of all collections in the connected Qdrant instance. Use first to find the collection name every other action needs. Read-only.',
+ idempotent: true,
+ },
+ props: {},
+ run: async ({ auth }) => {
+ return await qdrantApi.listCollections({ auth });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/list-snapshots.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/list-snapshots.ts
new file mode 100644
index 00000000000..7db1f1fa675
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/list-snapshots.ts
@@ -0,0 +1,30 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantListSnapshotsOutputSchema } from '../../output-schemas';
+
+export const listSnapshotsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_list_snapshots',
+ outputSchema: qdrantListSnapshotsOutputSchema,
+ displayName: 'List Snapshots',
+ description: 'Lists the snapshots of a collection.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description: "List a collection's snapshots with their name, creation time and size.",
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ },
+ run: async ({ auth, propsValue }) => {
+ const snapshots = await qdrantApi.listSnapshots({
+ auth,
+ collectionName: propsValue.collectionName,
+ });
+ return { snapshots, count: snapshots.length };
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/overwrite-payload.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/overwrite-payload.ts
new file mode 100644
index 00000000000..c7100d7801c
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/overwrite-payload.ts
@@ -0,0 +1,38 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const overwritePayloadAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_overwrite_payload',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Overwrite Payload',
+ description: 'Replaces the whole payload of points.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Replace the entire payload of the points selected by exactly one of Point IDs or Filter; keys not in the new payload are removed. Use Set Payload to change only some keys.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ payload: qdrantAiProps.payload({ required: true }),
+ pointIds: qdrantAiProps.pointIds({ required: false }),
+ filter: qdrantAiProps.filter({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.overwritePayload({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ payload: propsValue.payload,
+ ...qdrantUtils.pointsSelector({ pointIds: propsValue.pointIds, filter: propsValue.filter }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/query-points-groups.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/query-points-groups.ts
new file mode 100644
index 00000000000..db5cf213a9f
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/query-points-groups.ts
@@ -0,0 +1,59 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantQueryPointsGroupsOutputSchema } from '../../output-schemas';
+
+export const queryPointsGroupsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_query_points_groups',
+ outputSchema: qdrantQueryPointsGroupsOutputSchema,
+ displayName: 'Query Points Groups',
+ description: 'Finds the most similar points, grouped by a payload field.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Like Query Points, but returns the best matches grouped by a payload field (e.g. the top chunks per document), so one group cannot fill all the results.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ query: qdrantAiProps.query({ required: false }),
+ using: qdrantAiProps.using({ required: false }),
+ groupBy: Property.ShortText({
+ displayName: 'Group By',
+ description: 'Payload field to group results by, e.g. "document_id".',
+ required: true,
+ }),
+ groupSize: Property.Number({
+ displayName: 'Group Size',
+ description: 'Maximum points per group. Defaults to 3.',
+ required: false,
+ }),
+ filter: qdrantAiProps.filter({ required: false }),
+ limit: qdrantAiProps.limit({
+ required: false,
+ description: 'Maximum number of groups to return. Defaults to 10.',
+ }),
+ withPayload: qdrantAiProps.withPayload({ required: false }),
+ withVector: qdrantAiProps.withVector({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.queryPointsGroups({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ query: propsValue.query,
+ using: propsValue.using,
+ group_by: propsValue.groupBy,
+ group_size: propsValue.groupSize,
+ filter: propsValue.filter,
+ limit: propsValue.limit,
+ with_payload: propsValue.withPayload ?? true,
+ with_vector: propsValue.withVector,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/query-points.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/query-points.ts
new file mode 100644
index 00000000000..79a6519fa1c
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/query-points.ts
@@ -0,0 +1,58 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantQueryPointsOutputSchema } from '../../output-schemas';
+
+export const queryPointsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_query_points',
+ outputSchema: qdrantQueryPointsOutputSchema,
+ displayName: 'Query Points',
+ description: 'Finds the points most similar to a vector or point.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Find the points most similar to a vector or to an existing point, on the unnamed or a named vector, optionally filtered by payload. Also runs hybrid search by fusing Prefetch sub-queries. Use Scroll Points to list by filter only.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ query: qdrantAiProps.query({ required: false }),
+ using: qdrantAiProps.using({ required: false }),
+ prefetch: Property.Json({
+ displayName: 'Prefetch',
+ description:
+ 'Sub-queries run first, whose results Query then ranks; needed for fusion, e.g. [{"query": [0.1, 0.2], "using": "text", "limit": 20}, {"query": [0.3, 0.4], "using": "image", "limit": 20}].',
+ required: false,
+ }),
+ filter: qdrantAiProps.filter({ required: false }),
+ limit: qdrantAiProps.limit({ required: false }),
+ scoreThreshold: Property.Number({
+ displayName: 'Score Threshold',
+ description:
+ 'Only return points scoring at least this; for Euclidean distance, at most this.',
+ required: false,
+ }),
+ withPayload: qdrantAiProps.withPayload({ required: false }),
+ withVector: qdrantAiProps.withVector({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.queryPoints({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ query: propsValue.query,
+ using: propsValue.using,
+ prefetch: propsValue.prefetch,
+ filter: propsValue.filter,
+ limit: propsValue.limit,
+ score_threshold: propsValue.scoreThreshold,
+ with_payload: propsValue.withPayload ?? true,
+ with_vector: propsValue.withVector,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/rename-alias.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/rename-alias.ts
new file mode 100644
index 00000000000..82dc241c687
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/rename-alias.ts
@@ -0,0 +1,45 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantApi } from '../../common/api';
+import { qdrantSuccessOutputSchema } from '../../output-schemas';
+
+export const renameAliasAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_rename_alias',
+ outputSchema: qdrantSuccessOutputSchema,
+ displayName: 'Rename Alias',
+ description: 'Renames an alias.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description: 'Rename an existing alias. The collection it points to does not change.',
+ idempotent: false,
+ },
+ props: {
+ oldAliasName: Property.ShortText({
+ displayName: 'Current Alias Name',
+ description: 'Alias to rename. Use List Aliases to find it.',
+ required: true,
+ }),
+ newAliasName: Property.ShortText({
+ displayName: 'New Alias Name',
+ description: 'New name for the alias.',
+ required: true,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ const renamed = await qdrantApi.updateAliases({
+ auth,
+ actions: [
+ {
+ rename_alias: {
+ old_alias_name: propsValue.oldAliasName,
+ new_alias_name: propsValue.newAliasName,
+ },
+ },
+ ],
+ });
+ return { success: renamed };
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/scroll-points.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/scroll-points.ts
new file mode 100644
index 00000000000..7d1d5afd061
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/scroll-points.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantScrollPointsOutputSchema } from '../../output-schemas';
+
+export const scrollPointsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_scroll_points',
+ outputSchema: qdrantScrollPointsOutputSchema,
+ displayName: 'Scroll Points',
+ description: 'Lists points page by page, optionally filtered by payload.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Page through points in id order, optionally narrowed by a payload filter, without vector similarity (use Query Points for that). Returns next_page_offset: pass it as Offset with the same filter to get the next page; null means there are no more pages.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ filter: qdrantAiProps.filter({ required: false }),
+ limit: qdrantAiProps.limit({ required: false }),
+ offset: Property.ShortText({
+ displayName: 'Offset',
+ description:
+ 'next_page_offset from a previous Scroll Points call, to get the next page. Leave empty for the first page.',
+ required: false,
+ }),
+ withPayload: qdrantAiProps.withPayload({ required: false }),
+ withVector: qdrantAiProps.withVector({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.scrollPoints({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ filter: propsValue.filter,
+ limit: propsValue.limit,
+ offset: propsValue.offset ? qdrantUtils.parsePointId({ id: propsValue.offset }) : undefined,
+ with_payload: propsValue.withPayload ?? true,
+ with_vector: propsValue.withVector,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/set-payload.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/set-payload.ts
new file mode 100644
index 00000000000..48035640a98
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/set-payload.ts
@@ -0,0 +1,40 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const setPayloadAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_set_payload',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Set Payload',
+ description: 'Sets payload keys on points.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Set payload keys on the points selected by exactly one of Point IDs or Filter. Only the given keys change; other keys stay. Use Overwrite Payload to replace the whole payload.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ payload: qdrantAiProps.payload({ required: true }),
+ nestedKey: qdrantAiProps.nestedKey({ required: false }),
+ pointIds: qdrantAiProps.pointIds({ required: false }),
+ filter: qdrantAiProps.filter({ required: false }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.setPayload({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ payload: propsValue.payload,
+ key: propsValue.nestedKey,
+ ...qdrantUtils.pointsSelector({ pointIds: propsValue.pointIds, filter: propsValue.filter }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/update-collection.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/update-collection.ts
new file mode 100644
index 00000000000..6df16346e9c
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/update-collection.ts
@@ -0,0 +1,38 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantSuccessOutputSchema } from '../../output-schemas';
+
+export const updateCollectionAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_update_collection',
+ outputSchema: qdrantSuccessOutputSchema,
+ displayName: 'Update Collection',
+ description: 'Updates the parameters of a collection.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ "Change parameters of an existing collection: optimizer, HNSW, quantization, replication or per-vector settings. Only the keys you send change, and vector sizes and distances can't be changed. Repeating the same update is safe.",
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ settings: Property.Json({
+ displayName: 'Settings',
+ description:
+ 'Parameters to change, e.g. {"optimizers_config": {"indexing_threshold": 10000}}, {"params": {"replication_factor": 2}}, {"hnsw_config": {"m": 32}} or {"vectors": {"text": {"on_disk": true}}}.',
+ required: true,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ const updated = await qdrantApi.updateCollection({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: propsValue.settings,
+ });
+ return { success: updated };
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/update-vectors.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/update-vectors.ts
new file mode 100644
index 00000000000..45578014a84
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/update-vectors.ts
@@ -0,0 +1,40 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const updateVectorsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_update_vectors',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Update Vectors',
+ description: 'Replaces the vectors of existing points.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Replace the vectors of existing points; payloads stay, and for named vectors only the names you send change. The points must already exist (Upsert Points creates them).',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ points: Property.Array({
+ displayName: 'Points',
+ description:
+ 'JSON array of {id, vector}. vector is an array of numbers, or a map of vector name to values for named vectors, e.g. [{"id": 1, "vector": {"text": [0.1, 0.2]}}].',
+ required: true,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.updateVectors({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ points: qdrantUtils.requireItems({ items: propsValue.points, propName: 'Points' }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/ai/upsert-points.ts b/packages/pieces/community/qdrant/src/lib/actions/ai/upsert-points.ts
new file mode 100644
index 00000000000..7b6e76cddb0
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/actions/ai/upsert-points.ts
@@ -0,0 +1,40 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../../auth';
+import { qdrantAiProps } from '../../common/ai-props';
+import { qdrantApi } from '../../common/api';
+import { qdrantUtils } from '../../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../../output-schemas';
+
+export const upsertPointsAction = createAction({
+ auth: qdrantAuth,
+ name: 'qdrant_upsert_points',
+ outputSchema: qdrantUpdateResultOutputSchema,
+ displayName: 'Upsert Points',
+ description: 'Inserts points or replaces points with the same ID.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Insert points, or fully replace the vector and payload of points with the same id. The collection must already exist (Create Collection) and vectors must match its sizes and names. Waits until applied. Repeating with the same ids converges on the same state.',
+ idempotent: true,
+ },
+ props: {
+ collectionName: qdrantAiProps.collectionName({ required: true }),
+ points: Property.Array({
+ displayName: 'Points',
+ description:
+ 'Points as a JSON array of objects with id (unsigned integer or UUID), vector and optional payload, e.g. [{"id": 1, "vector": [0.1, 0.2, 0.3], "payload": {"city": "London"}}]. For named vectors, vector is a map: {"text": [0.1, 0.2]}.',
+ required: true,
+ }),
+ },
+ run: async ({ auth, propsValue }) => {
+ return await qdrantApi.upsertPoints({
+ auth,
+ collectionName: propsValue.collectionName,
+ body: {
+ points: qdrantUtils.requireItems({ items: propsValue.points, propName: 'Points' }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/qdrant/src/lib/actions/delete-collection.ts b/packages/pieces/community/qdrant/src/lib/actions/delete-collection.ts
index 19e3e03d48e..96d892d09ef 100644
--- a/packages/pieces/community/qdrant/src/lib/actions/delete-collection.ts
+++ b/packages/pieces/community/qdrant/src/lib/actions/delete-collection.ts
@@ -1,29 +1,29 @@
import { createAction } from '@activepieces/pieces-framework';
-import { qdrantAuth } from '../..';
-import { QdrantClient } from '@qdrant/js-client-rest';
-import { collectionName } from '../common';
+
+import { qdrantAuth } from '../auth';
+import { qdrantClient } from '../common/client';
+import { qdrantProps } from '../common/props';
+import { deleteCollectionOutputSchema } from '../output-schemas';
export const deleteCollection = createAction({
auth: qdrantAuth,
name: 'delete_collection',
+ outputSchema: deleteCollectionOutputSchema,
classification: 'DESTRUCTIVE',
displayName: 'Delete Collection',
description: 'Delete a collection of your database',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Permanently delete an entire Qdrant collection, including all of its points, identified by collection name. Use to tear down a vector store. Idempotent: re-running once the collection is gone leaves the same end state.',
idempotent: true,
},
props: {
- collectionName,
+ collectionName: qdrantProps.collectionName({ required: true }),
},
run: async ({ auth, propsValue }) => {
- const client = new QdrantClient({
- apiKey: auth.props.key,
- url: auth.props.serverAddress,
- });
- const collectionName = propsValue.collectionName as string;
+ const client = qdrantClient.create({ auth });
+ const collectionName = propsValue.collectionName;
const response = await client.deleteCollection(collectionName);
return response;
},
diff --git a/packages/pieces/community/qdrant/src/lib/actions/delete-points.ts b/packages/pieces/community/qdrant/src/lib/actions/delete-points.ts
index 78de4622b26..c62ab3fe07d 100644
--- a/packages/pieces/community/qdrant/src/lib/actions/delete-points.ts
+++ b/packages/pieces/community/qdrant/src/lib/actions/delete-points.ts
@@ -1,41 +1,43 @@
import { createAction } from '@activepieces/pieces-framework';
-import { collectionName, convertToFilter, seclectPointsProps } from '../common';
-import { qdrantAuth } from '../..';
-import { QdrantClient } from '@qdrant/js-client-rest';
+
+import { qdrantAuth } from '../auth';
+import { qdrantClient } from '../common/client';
+import { qdrantProps } from '../common/props';
+import { qdrantUtils } from '../common/utils';
+import { qdrantUpdateResultOutputSchema } from '../output-schemas';
export const deletePoints = createAction({
auth: qdrantAuth,
name: 'delete_points',
+ outputSchema: qdrantUpdateResultOutputSchema,
classification: 'DESTRUCTIVE',
displayName: 'Delete Points',
description: 'Delete points of a specific collection',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Delete points from a Qdrant collection, selecting them either by an explicit list of ids or by a payload filter (must / must_not conditions). Use to remove specific vectors from a collection. Idempotent: deleting points that are already absent leaves the same end state.',
idempotent: true,
},
props: {
- collectionName,
- ...seclectPointsProps,
+ collectionName: qdrantProps.collectionName({ required: true }),
+ getPointsBy: qdrantProps.getPointsBy({ required: true }),
+ infosToGetPoint: qdrantProps.infosToGetPoint({ required: true }),
},
run: async ({ auth, propsValue }) => {
- const client = new QdrantClient({
- apiKey: auth.props.key,
- url: auth.props.serverAddress,
- });
+ const client = qdrantClient.create({ auth });
- const collectionName = propsValue.collectionName as string;
+ const collectionName = propsValue.collectionName;
if (propsValue.getPointsBy === 'Ids') {
const ids = JSON.parse(propsValue.infosToGetPoint['ids']);
return await client.delete(collectionName, {
points: ids instanceof Array ? ids : [ids],
});
}
- const filter = convertToFilter(
- propsValue.infosToGetPoint as { must: any; must_not: any }
- );
- // console.log(JSON.stringify(filter))
+ const filter = qdrantUtils.convertToFilter({
+ must: propsValue.infosToGetPoint['must'],
+ must_not: propsValue.infosToGetPoint['must_not'],
+ });
return await client.delete(collectionName, {
filter,
wait: true,
diff --git a/packages/pieces/community/qdrant/src/lib/actions/get-collection-infos.ts b/packages/pieces/community/qdrant/src/lib/actions/get-collection-infos.ts
index 1e43d12e553..9a6dba51eb7 100644
--- a/packages/pieces/community/qdrant/src/lib/actions/get-collection-infos.ts
+++ b/packages/pieces/community/qdrant/src/lib/actions/get-collection-infos.ts
@@ -1,29 +1,29 @@
-import { QdrantClient } from '@qdrant/js-client-rest';
-import { qdrantAuth } from '../..';
import { createAction } from '@activepieces/pieces-framework';
-import { collectionName } from '../common';
+
+import { qdrantAuth } from '../auth';
+import { qdrantClient } from '../common/client';
+import { qdrantProps } from '../common/props';
+import { qdrantGetCollectionOutputSchema } from '../output-schemas';
export const collectionInfos = createAction({
auth: qdrantAuth,
name: 'collection_infos',
+ outputSchema: qdrantGetCollectionOutputSchema,
classification: 'READ',
displayName: 'Get Collection Infos',
description: 'Get the all the infos of a specific collection',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Retrieve configuration and status details for a single Qdrant collection by name (vector params, point counts, indexing state, etc.). Use to inspect a collection before reading from or writing to it. Read-only and idempotent.',
idempotent: true,
},
props: {
- collectionName,
+ collectionName: qdrantProps.collectionName({ required: true }),
},
run: async ({ auth, propsValue }) => {
- const client = new QdrantClient({
- apiKey: auth.props.key,
- url: auth.props.serverAddress,
- });
- const collectionName = propsValue.collectionName as string;
+ const client = qdrantClient.create({ auth });
+ const collectionName = propsValue.collectionName;
const collectionInfos = await client.getCollection(collectionName);
return collectionInfos;
},
diff --git a/packages/pieces/community/qdrant/src/lib/actions/get-collection-list.ts b/packages/pieces/community/qdrant/src/lib/actions/get-collection-list.ts
index 26ec92d251c..ecae93e2a35 100644
--- a/packages/pieces/community/qdrant/src/lib/actions/get-collection-list.ts
+++ b/packages/pieces/community/qdrant/src/lib/actions/get-collection-list.ts
@@ -1,14 +1,17 @@
-import { QdrantClient } from '@qdrant/js-client-rest';
-import { qdrantAuth } from '../..';
import { createAction } from '@activepieces/pieces-framework';
+import { qdrantAuth } from '../auth';
+import { qdrantClient } from '../common/client';
+import { qdrantListCollectionsOutputSchema } from '../output-schemas';
+
export const collectionList = createAction({
auth: qdrantAuth,
name: 'collection_list',
+ outputSchema: qdrantListCollectionsOutputSchema,
classification: 'SEARCH',
displayName: 'Get Collection List',
description: 'Get the list of all the collections of your database',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'List all collections in the connected Qdrant instance. Use to discover available collection names before targeting one with another action. Takes no input. Read-only and idempotent.',
@@ -16,10 +19,7 @@ export const collectionList = createAction({
},
props: {},
run: async ({ auth }) => {
- const client = new QdrantClient({
- apiKey: auth.props.key,
- url: auth.props.serverAddress,
- });
+ const client = qdrantClient.create({ auth });
const collections = await client.getCollections();
return collections;
},
diff --git a/packages/pieces/community/qdrant/src/lib/actions/get-points.ts b/packages/pieces/community/qdrant/src/lib/actions/get-points.ts
index 4824c61dc8c..f5b692278b2 100644
--- a/packages/pieces/community/qdrant/src/lib/actions/get-points.ts
+++ b/packages/pieces/community/qdrant/src/lib/actions/get-points.ts
@@ -1,7 +1,9 @@
import { createAction } from '@activepieces/pieces-framework';
-import { seclectPointsProps, convertToFilter, collectionName } from '../common';
-import { qdrantAuth } from '../..';
-import { QdrantClient } from '@qdrant/js-client-rest';
+
+import { qdrantAuth } from '../auth';
+import { qdrantClient } from '../common/client';
+import { qdrantProps } from '../common/props';
+import { qdrantUtils } from '../common/utils';
export const getPoints = createAction({
auth: qdrantAuth,
@@ -9,22 +11,20 @@ export const getPoints = createAction({
classification: 'SEARCH',
displayName: 'Get Points',
description: 'Get the points of a specific collection',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Fetch points from a Qdrant collection, selecting them either by an explicit list of ids or by a payload filter (must / must_not conditions). Use to look up known points or scroll through points matching metadata, as opposed to vector-similarity search. Read-only and idempotent.',
idempotent: true,
},
props: {
- collectionName,
- ...seclectPointsProps,
+ collectionName: qdrantProps.collectionName({ required: true }),
+ getPointsBy: qdrantProps.getPointsBy({ required: true }),
+ infosToGetPoint: qdrantProps.infosToGetPoint({ required: true }),
},
run: async ({ auth, propsValue }) => {
- const client = new QdrantClient({
- apiKey: auth.props.key,
- url: auth.props.serverAddress,
- });
- const collectionName = propsValue.collectionName as string;
+ const client = qdrantClient.create({ auth });
+ const collectionName = propsValue.collectionName;
if (propsValue.getPointsBy === 'Ids') {
let ids = JSON.parse(propsValue.infosToGetPoint['ids']);
@@ -37,12 +37,11 @@ export const getPoints = createAction({
ids: ids instanceof Array ? ids : [ids],
});
} else {
- const filtering = propsValue.infosToGetPoint as {
- must: any;
- must_not: any;
- };
return await client.scroll(collectionName, {
- filter: convertToFilter(filtering),
+ filter: qdrantUtils.convertToFilter({
+ must: propsValue.infosToGetPoint['must'],
+ must_not: propsValue.infosToGetPoint['must_not'],
+ }),
});
}
},
diff --git a/packages/pieces/community/qdrant/src/lib/actions/search-points.ts b/packages/pieces/community/qdrant/src/lib/actions/search-points.ts
index 5a315f02479..c0976fded31 100644
--- a/packages/pieces/community/qdrant/src/lib/actions/search-points.ts
+++ b/packages/pieces/community/qdrant/src/lib/actions/search-points.ts
@@ -1,33 +1,33 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import {
- collectionName,
- convertToFilter,
- decodeEmbeddings,
- filteringProps,
-} from '../common';
-import { qdrantAuth } from '../..';
-import { QdrantClient } from '@qdrant/js-client-rest';
+
+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: 'both',
+ 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,
+ collectionName: qdrantProps.collectionName({ required: true }),
vector: Property.File({
displayName: 'Embedding',
required: true,
description: 'The vector (= embedding) you want to search for.',
}),
- ...filteringProps,
+ must: qdrantProps.must({ required: false }),
+ must_not: qdrantProps.mustNot({ required: false }),
negativeVector: Property.File({
displayName: 'Negative Vector',
required: false,
@@ -41,20 +41,21 @@ export const searchPoints = createAction({
}),
},
run: async ({ auth, propsValue }) => {
- const client = new QdrantClient({
- apiKey: auth.props.key,
- url: auth.props.serverAddress,
- });
+ const client = qdrantClient.create({ auth });
const { must, must_not } = propsValue;
- const filter = convertToFilter({
+ const filter = qdrantUtils.convertToFilter({
must,
must_not,
});
- let vector = Array.from(decodeEmbeddings(propsValue.vector.data)[0]);
+ let vector = Array.from(
+ qdrantUtils.decodeEmbeddings({ data: propsValue.vector.data })[0]
+ );
const negativeVector = propsValue.negativeVector
- ? Array.from(decodeEmbeddings(propsValue.vector.data)[0])
+ ? Array.from(
+ qdrantUtils.decodeEmbeddings({ data: propsValue.vector.data })[0]
+ )
: undefined;
if (
@@ -66,7 +67,6 @@ export const searchPoints = createAction({
const limit = propsValue.limitResult ?? 20;
if (negativeVector) {
- // math func on: https://qdrant.tech/documentation/concepts/search/?selector=aHRtbCA%2BIGJvZHkgPiBkaXY6bnRoLW9mLXR5cGUoMSkgPiBzZWN0aW9uID4gZGl2ID4gZGl2ID4gZGl2ID4gYXJ0aWNsZSA%2BIGgyOm50aC1vZi10eXBlKDUp
vector = vector.map((vec, i) => vec * 2 + negativeVector[i]);
}
return await client.search(propsValue.collectionName, {
diff --git a/packages/pieces/community/qdrant/src/lib/auth.ts b/packages/pieces/community/qdrant/src/lib/auth.ts
new file mode 100644
index 00000000000..852b0016a13
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/auth.ts
@@ -0,0 +1,29 @@
+import { PieceAuth, Property } from '@activepieces/pieces-framework';
+
+const qdrantConnectionDescription = `
+### Using Qdrant cloud
+1. Connect to your [Qdrant cloud account](https://cloud.qdrant.io)
+2. Create a new cluster if it's the first time you use Qdrant
+3. Go to Data Access Control and create a new api key and copy it
+4. Go to clusters, click on the arrow \`>\` and copy the Cluster URL.
+
+### Using self-hosted Qdrant
+Try to create your own qdrant instance using the [documentation guides](https://qdrant.tech/documentation/guides/)
+`;
+
+export const qdrantAuth = PieceAuth.CustomAuth({
+ description: qdrantConnectionDescription,
+ props: {
+ serverAddress: Property.ShortText({
+ displayName: 'Server Address',
+ required: true,
+ description: 'The url of the Qdrant instance.',
+ }),
+ key: PieceAuth.SecretText({
+ displayName: 'API KEY',
+ required: true,
+ description: 'Enter the API Key of your Qdrant account',
+ }),
+ },
+ required: true,
+});
diff --git a/packages/pieces/community/qdrant/src/lib/common/ai-props.ts b/packages/pieces/community/qdrant/src/lib/common/ai-props.ts
new file mode 100644
index 00000000000..99a66633930
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/common/ai-props.ts
@@ -0,0 +1,96 @@
+import { Property } from '@activepieces/pieces-framework';
+
+import type { PropParams } from './props';
+
+function collectionName<R extends boolean>({
+ required,
+ displayName = 'Collection Name',
+ description = 'Exact name of the collection, e.g. "products". Use List Collections to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function pointIds<R extends boolean>({
+ required,
+ displayName = 'Point IDs',
+ description = 'Point IDs: unsigned integers (e.g. 42) or UUID strings. Returned by Scroll Points and Query Points.',
+}: PropParams<R>) {
+ return Property.Array({ displayName, description, required });
+}
+
+function filter<R extends boolean>({
+ required,
+ displayName = 'Filter',
+ description = 'Qdrant filter object with must, should and must_not condition lists, e.g. {"must": [{"key": "city", "match": {"value": "London"}}]}. Filtering on a field is fastest with a payload index (Create Payload Index).',
+}: PropParams<R>) {
+ return Property.Json({ displayName, description, required });
+}
+
+function withPayload<R extends boolean>({
+ required,
+ displayName = 'Include Payload',
+ description = "Return each point's payload. Defaults to true.",
+}: PropParams<R>) {
+ return Property.Checkbox({ displayName, description, required, defaultValue: true });
+}
+
+function withVector<R extends boolean>({
+ required,
+ displayName = 'Include Vectors',
+ description = "Return each point's vectors. Defaults to false; vectors can be large.",
+}: PropParams<R>) {
+ return Property.Checkbox({ displayName, description, required, defaultValue: false });
+}
+
+function limit<R extends boolean>({
+ required,
+ displayName = 'Limit',
+ description = 'Maximum number of results to return. Defaults to 10.',
+}: PropParams<R>) {
+ return Property.Number({ displayName, description, required });
+}
+
+function query<R extends boolean>({
+ required,
+ displayName = 'Query',
+ description = 'What to rank by, as JSON. Nearest to a vector: {"nearest": [0.1, 0.2, 0.3]}. Nearest to an existing point: {"nearest": 42}. Fuse prefetch results: {"fusion": "rrf"}. Order by a payload field: {"order_by": "price"}. Leave empty to return points matching the filter.',
+}: PropParams<R>) {
+ return Property.Json({ displayName, description, required });
+}
+
+function using<R extends boolean>({
+ required,
+ displayName = 'Vector Name',
+ description = 'Named vector to search with, e.g. "text". Leave empty for a collection with one unnamed vector. Get Collection lists the names.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function payload<R extends boolean>({
+ required,
+ displayName = 'Payload',
+ description = 'Payload keys and values as a JSON object, e.g. {"status": "archived", "tags": ["a", "b"]}.',
+}: PropParams<R>) {
+ return Property.Json({ displayName, description, required });
+}
+
+function nestedKey<R extends boolean>({
+ required,
+ displayName = 'Nested Key',
+ description = 'Payload path to write the keys under, e.g. "metadata.address". Leave empty to write at the top level.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+export const qdrantAiProps = {
+ collectionName,
+ pointIds,
+ filter,
+ withPayload,
+ withVector,
+ limit,
+ query,
+ using,
+ payload,
+ nestedKey,
+};
diff --git a/packages/pieces/community/qdrant/src/lib/common/api.ts b/packages/pieces/community/qdrant/src/lib/common/api.ts
new file mode 100644
index 00000000000..bc911b3eed7
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/common/api.ts
@@ -0,0 +1,428 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+
+import { qdrantClient } from './client';
+
+import type {
+ QdrantAliasesList,
+ QdrantAuthValue,
+ QdrantBody,
+ QdrantCollectionsList,
+ QdrantRecord,
+ QdrantScoredPoint,
+ QdrantScrollResult,
+ QdrantSnapshot,
+ QdrantUpdateResult,
+} from './types';
+
+async function listCollections({
+ auth,
+}: {
+ auth: QdrantAuthValue;
+}): Promise<QdrantCollectionsList> {
+ return await qdrantClient.request<QdrantCollectionsList>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/collections',
+ });
+}
+
+async function getCollection({
+ auth,
+ collectionName,
+}: CollectionParams & { auth: QdrantAuthValue }): Promise<QdrantBody> {
+ return await qdrantClient.request<QdrantBody>({
+ auth,
+ method: HttpMethod.GET,
+ path: collectionPath({ collectionName }),
+ });
+}
+
+async function collectionExists({
+ auth,
+ collectionName,
+}: CollectionParams & { auth: QdrantAuthValue }): Promise<{ exists: boolean }> {
+ return await qdrantClient.request<{ exists: boolean }>({
+ auth,
+ method: HttpMethod.GET,
+ path: `${collectionPath({ collectionName })}/exists`,
+ });
+}
+
+async function createCollection({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<boolean> {
+ return await qdrantClient.request<boolean>({
+ auth,
+ method: HttpMethod.PUT,
+ path: collectionPath({ collectionName }),
+ body,
+ });
+}
+
+async function updateCollection({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<boolean> {
+ return await qdrantClient.request<boolean>({
+ auth,
+ method: HttpMethod.PATCH,
+ path: collectionPath({ collectionName }),
+ body,
+ });
+}
+
+async function deleteCollection({
+ auth,
+ collectionName,
+}: CollectionParams & { auth: QdrantAuthValue }): Promise<boolean> {
+ return await qdrantClient.request<boolean>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: collectionPath({ collectionName }),
+ });
+}
+
+async function listAliases({ auth }: { auth: QdrantAuthValue }): Promise<QdrantAliasesList> {
+ return await qdrantClient.request<QdrantAliasesList>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/aliases',
+ });
+}
+
+async function listCollectionAliases({
+ auth,
+ collectionName,
+}: CollectionParams & { auth: QdrantAuthValue }): Promise<QdrantAliasesList> {
+ return await qdrantClient.request<QdrantAliasesList>({
+ auth,
+ method: HttpMethod.GET,
+ path: `${collectionPath({ collectionName })}/aliases`,
+ });
+}
+
+async function updateAliases({
+ auth,
+ actions,
+}: {
+ auth: QdrantAuthValue;
+ actions: QdrantBody[];
+}): Promise<boolean> {
+ return await qdrantClient.request<boolean>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/collections/aliases',
+ body: { actions },
+ });
+}
+
+async function createSnapshot({
+ auth,
+ collectionName,
+}: CollectionParams & { auth: QdrantAuthValue }): Promise<QdrantSnapshot> {
+ return await qdrantClient.request<QdrantSnapshot>({
+ auth,
+ method: HttpMethod.POST,
+ path: `${collectionPath({ collectionName })}/snapshots`,
+ query: WAIT,
+ });
+}
+
+async function listSnapshots({
+ auth,
+ collectionName,
+}: CollectionParams & { auth: QdrantAuthValue }): Promise<QdrantSnapshot[]> {
+ return await qdrantClient.request<QdrantSnapshot[]>({
+ auth,
+ method: HttpMethod.GET,
+ path: `${collectionPath({ collectionName })}/snapshots`,
+ });
+}
+
+async function deleteSnapshot({
+ auth,
+ collectionName,
+ snapshotName,
+}: CollectionParams & { auth: QdrantAuthValue; snapshotName: string }): Promise<boolean> {
+ return await qdrantClient.request<boolean>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: `${collectionPath({ collectionName })}/snapshots/${encodeURIComponent(snapshotName)}`,
+ query: WAIT,
+ });
+}
+
+async function createPayloadIndex({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantUpdateResult> {
+ return await qdrantClient.request<QdrantUpdateResult>({
+ auth,
+ method: HttpMethod.PUT,
+ path: `${collectionPath({ collectionName })}/index`,
+ query: WAIT,
+ body,
+ });
+}
+
+async function deletePayloadIndex({
+ auth,
+ collectionName,
+ fieldName,
+}: CollectionParams & { auth: QdrantAuthValue; fieldName: string }): Promise<QdrantUpdateResult> {
+ return await qdrantClient.request<QdrantUpdateResult>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: `${collectionPath({ collectionName })}/index/${encodeURIComponent(fieldName)}`,
+ query: WAIT,
+ });
+}
+
+async function upsertPoints({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantUpdateResult> {
+ return await pointsWrite({ auth, collectionName, method: HttpMethod.PUT, subPath: '', body });
+}
+
+async function getPoints({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantRecord[]> {
+ return await qdrantClient.request<QdrantRecord[]>({
+ auth,
+ method: HttpMethod.POST,
+ path: `${collectionPath({ collectionName })}/points`,
+ body,
+ });
+}
+
+async function scrollPoints({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantScrollResult> {
+ return await qdrantClient.request<QdrantScrollResult>({
+ auth,
+ method: HttpMethod.POST,
+ path: `${collectionPath({ collectionName })}/points/scroll`,
+ body,
+ });
+}
+
+async function countPoints({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<{ count: number }> {
+ return await qdrantClient.request<{ count: number }>({
+ auth,
+ method: HttpMethod.POST,
+ path: `${collectionPath({ collectionName })}/points/count`,
+ body,
+ });
+}
+
+async function deletePoints({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantUpdateResult> {
+ return await pointsWrite({
+ auth,
+ collectionName,
+ method: HttpMethod.POST,
+ subPath: '/delete',
+ body,
+ });
+}
+
+async function setPayload({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantUpdateResult> {
+ return await pointsWrite({
+ auth,
+ collectionName,
+ method: HttpMethod.POST,
+ subPath: '/payload',
+ body,
+ });
+}
+
+async function overwritePayload({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantUpdateResult> {
+ return await pointsWrite({
+ auth,
+ collectionName,
+ method: HttpMethod.PUT,
+ subPath: '/payload',
+ body,
+ });
+}
+
+async function deletePayloadKeys({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantUpdateResult> {
+ return await pointsWrite({
+ auth,
+ collectionName,
+ method: HttpMethod.POST,
+ subPath: '/payload/delete',
+ body,
+ });
+}
+
+async function clearPayload({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantUpdateResult> {
+ return await pointsWrite({
+ auth,
+ collectionName,
+ method: HttpMethod.POST,
+ subPath: '/payload/clear',
+ body,
+ });
+}
+
+async function updateVectors({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantUpdateResult> {
+ return await pointsWrite({
+ auth,
+ collectionName,
+ method: HttpMethod.PUT,
+ subPath: '/vectors',
+ body,
+ });
+}
+
+async function deleteVectors({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<QdrantUpdateResult> {
+ return await pointsWrite({
+ auth,
+ collectionName,
+ method: HttpMethod.POST,
+ subPath: '/vectors/delete',
+ body,
+ });
+}
+
+async function queryPoints({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<{ points: QdrantScoredPoint[] }> {
+ return await qdrantClient.request<{ points: QdrantScoredPoint[] }>({
+ auth,
+ method: HttpMethod.POST,
+ path: `${collectionPath({ collectionName })}/points/query`,
+ body,
+ });
+}
+
+async function queryPointsGroups({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<{ groups: QdrantBody[] }> {
+ return await qdrantClient.request<{ groups: QdrantBody[] }>({
+ auth,
+ method: HttpMethod.POST,
+ path: `${collectionPath({ collectionName })}/points/query/groups`,
+ body,
+ });
+}
+
+async function facet({
+ auth,
+ collectionName,
+ body,
+}: CollectionBodyParams & { auth: QdrantAuthValue }): Promise<{ hits: QdrantBody[] }> {
+ return await qdrantClient.request<{ hits: QdrantBody[] }>({
+ auth,
+ method: HttpMethod.POST,
+ path: `${collectionPath({ collectionName })}/facet`,
+ body,
+ });
+}
+
+function collectionPath({ collectionName }: CollectionParams): string {
+ return `/collections/${encodeURIComponent(collectionName)}`;
+}
+
+async function pointsWrite({
+ auth,
+ collectionName,
+ method,
+ subPath,
+ body,
+}: CollectionBodyParams & {
+ auth: QdrantAuthValue;
+ method: HttpMethod;
+ subPath: string;
+}): Promise<QdrantUpdateResult> {
+ return await qdrantClient.request<QdrantUpdateResult>({
+ auth,
+ method,
+ path: `${collectionPath({ collectionName })}/points${subPath}`,
+ query: WAIT,
+ body,
+ });
+}
+
+export const qdrantApi = {
+ listCollections,
+ getCollection,
+ collectionExists,
+ createCollection,
+ updateCollection,
+ deleteCollection,
+ listAliases,
+ listCollectionAliases,
+ updateAliases,
+ createSnapshot,
+ listSnapshots,
+ deleteSnapshot,
+ createPayloadIndex,
+ deletePayloadIndex,
+ upsertPoints,
+ getPoints,
+ scrollPoints,
+ countPoints,
+ deletePoints,
+ setPayload,
+ overwritePayload,
+ deletePayloadKeys,
+ clearPayload,
+ updateVectors,
+ deleteVectors,
+ queryPoints,
+ queryPointsGroups,
+ facet,
+};
+
+const WAIT = { wait: 'true' };
+
+type CollectionParams = { collectionName: string };
+
+type CollectionBodyParams = CollectionParams & { body: QdrantBody };
diff --git a/packages/pieces/community/qdrant/src/lib/common/client.ts b/packages/pieces/community/qdrant/src/lib/common/client.ts
new file mode 100644
index 00000000000..fc2bb365a5e
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/common/client.ts
@@ -0,0 +1,40 @@
+import { QdrantClient } from '@qdrant/js-client-rest';
+
+import { HttpMethod, httpClient, QueryParams } from '@activepieces/pieces-common';
+
+import type { QdrantAuthValue, QdrantEnvelope } from './types';
+
+function create({ auth }: { auth: QdrantAuthValue }): QdrantClient {
+ return new QdrantClient({
+ apiKey: auth.props.key,
+ url: auth.props.serverAddress,
+ });
+}
+
+function baseUrl({ auth }: { auth: QdrantAuthValue }): string {
+ const url = new URL(auth.props.serverAddress);
+ return `${url.protocol}//${url.hostname}:${url.port || DEFAULT_PORT}`;
+}
+
+async function request<T>({
+ auth,
+ method,
+ path,
+ query,
+ body,
+}: RequestParams & { auth: QdrantAuthValue }): Promise<T> {
+ const response = await httpClient.sendRequest<QdrantEnvelope<T>>({
+ method,
+ url: `${baseUrl({ auth })}${path}`,
+ headers: { 'api-key': auth.props.key },
+ queryParams: query,
+ body,
+ });
+ return response.body.result;
+}
+
+export const qdrantClient = { create, baseUrl, request };
+
+const DEFAULT_PORT = '6333';
+
+type RequestParams = { method: HttpMethod; path: string; query?: QueryParams; body?: unknown };
diff --git a/packages/pieces/community/qdrant/src/lib/common/index.ts b/packages/pieces/community/qdrant/src/lib/common/index.ts
deleted file mode 100644
index 7d5bbe87d73..00000000000
--- a/packages/pieces/community/qdrant/src/lib/common/index.ts
+++ /dev/null
@@ -1,143 +0,0 @@
-import { Property } from '@activepieces/pieces-framework';
-import { qdrantAuth } from '../..';
-
-export const decodeEmbeddings = (embeddingsString: Buffer) => {
- let embeddings = embeddingsString.toString('utf-8') as
- | string[]
- | number[][]
- | number[]
- | string;
-
- if (embeddings[0] === '[') {
- try {
- embeddings = JSON.parse(embeddings as string);
- } catch {
- null;
- }
- }
-
- if (
- typeof embeddings[0] === 'number' ||
- (typeof embeddings[0] === 'string' && embeddings[0].length === 1)
- ) {
- embeddings = [embeddings] as string[] | number[][];
- }
-
- if (embeddings.length === 0)
- throw new Error('Embeddings must contain one element minimum');
-
- if (typeof embeddings[0] === 'string') {
- return (embeddings as string[]).map(
- (embedding) =>
- new Float32Array(
- new Uint8Array(Buffer.from(embedding, 'base64')).buffer
- )
- );
- } else {
- return (embeddings as number[][]).map(
- (embedding) => new Float32Array(embedding)
- );
- }
-};
-
-export const filteringProps = {
- must: Property.Object({
- displayName: 'Must Have',
- description:
- 'If the point have this property in his payload it will be selected',
- required: false,
- }),
- must_not: Property.Object({
- displayName: 'Must Not Have',
- description:
- 'If the point have this property in his payload it will not be selected',
- required: false,
- }),
-};
-
-export const seclectPointsProps = {
- getPointsBy: Property.StaticDropdown({
- displayName: 'Choose Points By',
- description: 'The method to use to get the points',
- options: {
- options: [
- { label: 'Ids', value: 'Ids' },
- { label: 'Filtering', value: 'Filtering' },
- ],
- },
- defaultValue: 'Ids',
- required: true,
- }),
- infosToGetPoint: Property.DynamicProperties({
- auth: qdrantAuth,
- displayName: 'By ids or filtering',
- description: 'The infos to select points',
- refreshers: ['getPointsBy'],
- props: async (propsValue) => {
- const { getPointsBy } = propsValue as unknown as {
- getPointsBy: 'Ids' | 'Filtering';
- };
- if (getPointsBy === 'Ids')
- return {
- ids: Property.ShortText({
- displayName: 'Ids',
- description: 'The ids of the points to choose',
- required: true,
- }),
- };
- return filteringProps as any;
- },
- required: true,
- }),
-};
-
-export const convertToFilter = (infosToGetPoint: {
- must: any;
- must_not: any;
-}) => {
- type Tfilter = (
- | { has_id: (string | number)[] }
- | { key: string; match: { value: any } | { any: any[] } }
- )[];
- const filter = { must: [], must_not: [] } as {
- must: Tfilter;
- must_not: Tfilter;
- };
-
- for (const getKey in infosToGetPoint) {
- for (const key in infosToGetPoint[getKey as keyof typeof filter]) {
- let value = infosToGetPoint[getKey as keyof typeof filter][key];
-
- if (['{', '['].includes(value[0])) {
- try {
- value = JSON.parse(value);
- } catch {
- null;
- }
- }
-
- if (['id', 'ids'].includes(key.toLocaleLowerCase())) {
- filter[getKey as keyof typeof filter].push({
- has_id: value instanceof Array ? value : [value],
- });
- continue;
- }
-
- if (value instanceof Array) {
- filter[getKey as keyof typeof filter].push({
- key,
- match: { any: value },
- });
- }
-
- filter[getKey as keyof typeof filter].push({ key, match: { value } });
- }
- }
- return filter;
-};
-
-export const collectionName = Property.ShortText({
- displayName: 'Collection Name',
- description: 'The name of the collection needed for this action',
- required: true,
-});
diff --git a/packages/pieces/community/qdrant/src/lib/common/props.ts b/packages/pieces/community/qdrant/src/lib/common/props.ts
new file mode 100644
index 00000000000..bb2f848fe77
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/common/props.ts
@@ -0,0 +1,88 @@
+import { InputPropertyMap, Property } from '@activepieces/pieces-framework';
+
+import { qdrantAuth } from '../auth';
+
+function collectionName<R extends boolean>({
+ required,
+ displayName = 'Collection Name',
+ description = 'The name of the collection needed for this action',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function must<R extends boolean>({
+ required,
+ displayName = 'Must Have',
+ description = 'If the point have this property in his payload it will be selected',
+}: PropParams<R>) {
+ return Property.Object({ displayName, description, required });
+}
+
+function mustNot<R extends boolean>({
+ required,
+ displayName = 'Must Not Have',
+ description = 'If the point have this property in his payload it will not be selected',
+}: PropParams<R>) {
+ return Property.Object({ displayName, description, required });
+}
+
+function getPointsBy<R extends boolean>({
+ required,
+ displayName = 'Choose Points By',
+ description = 'The method to use to get the points',
+}: PropParams<R>) {
+ return Property.StaticDropdown({
+ displayName,
+ description,
+ options: {
+ options: [
+ { label: 'Ids', value: 'Ids' },
+ { label: 'Filtering', value: 'Filtering' },
+ ],
+ },
+ defaultValue: 'Ids',
+ required,
+ });
+}
+
+function infosToGetPoint<R extends boolean>({
+ required,
+ displayName = 'By ids or filtering',
+ description = 'The infos to select points',
+}: PropParams<R>) {
+ return Property.DynamicProperties({
+ auth: qdrantAuth,
+ displayName,
+ description,
+ refreshers: ['getPointsBy'],
+ props: async ({ getPointsBy }): Promise<InputPropertyMap> => {
+ if (getPointsBy === 'Ids')
+ return {
+ ids: Property.ShortText({
+ displayName: 'Ids',
+ description: 'The ids of the points to choose',
+ required: true,
+ }),
+ };
+ return {
+ must: must({ required: false }),
+ must_not: mustNot({ required: false }),
+ };
+ },
+ required,
+ });
+}
+
+export const qdrantProps = {
+ collectionName,
+ must,
+ mustNot,
+ getPointsBy,
+ infosToGetPoint,
+};
+
+export type PropParams<R extends boolean> = {
+ required: R;
+ displayName?: string;
+ description?: string;
+};
diff --git a/packages/pieces/community/qdrant/src/lib/common/types.ts b/packages/pieces/community/qdrant/src/lib/common/types.ts
new file mode 100644
index 00000000000..38546540cc7
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/common/types.ts
@@ -0,0 +1,55 @@
+import type { AppConnectionType } from '@activepieces/pieces-framework';
+
+import type { Schemas } from '@qdrant/js-client-rest';
+
+export type QdrantAuthValue = {
+ type: AppConnectionType.CUSTOM_AUTH;
+ props: { serverAddress: string; key: string };
+};
+
+export type QdrantDistance = 'Cosine' | 'Euclid' | 'Dot';
+
+export type QdrantEmbedding = string | number[];
+
+export type QdrantEmbeddingsInput = string | (number | QdrantEmbedding)[];
+
+export type QdrantPointId = Schemas['ExtendedPointId'];
+
+export type QdrantCondition = Schemas['Condition'];
+
+export type QdrantFilter = {
+ must: QdrantCondition[];
+ must_not: QdrantCondition[];
+};
+
+export type QdrantBody = Record<string, unknown>;
+
+export type QdrantEnvelope<T> = { result: T; status?: string; time?: number };
+
+export type QdrantUpdateResult = { operation_id?: number | null; status: string };
+
+export type QdrantRecord = {
+ id: QdrantPointId;
+ payload?: Record<string, unknown> | null;
+ vector?: unknown;
+};
+
+export type QdrantScoredPoint = QdrantRecord & { version?: number; score: number };
+
+export type QdrantCollectionsList = { collections: { name: string }[] };
+
+export type QdrantAliasesList = { aliases: { alias_name: string; collection_name: string }[] };
+
+export type QdrantSnapshot = {
+ name: string;
+ creation_time?: string | null;
+ size: number;
+ checksum?: string | null;
+};
+
+export type QdrantScrollResult = {
+ points: QdrantRecord[];
+ next_page_offset?: QdrantPointId | null;
+};
+
+export type QdrantPointsSelector = { points: QdrantPointId[] } | { filter: QdrantBody };
diff --git a/packages/pieces/community/qdrant/src/lib/common/utils.ts b/packages/pieces/community/qdrant/src/lib/common/utils.ts
new file mode 100644
index 00000000000..fa1ccef7e7e
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/common/utils.ts
@@ -0,0 +1,143 @@
+import type {
+ QdrantCondition,
+ QdrantEmbedding,
+ QdrantEmbeddingsInput,
+ QdrantFilter,
+ QdrantPointId,
+ QdrantPointsSelector,
+} from './types';
+
+function decodeEmbeddings({ data }: { data: Buffer }): Float32Array[] {
+ const embeddings = toEmbeddingList({
+ value: parseEmbeddings({ text: data.toString('utf-8') }),
+ });
+
+ if (embeddings.length === 0) throw new Error('Embeddings must contain one element minimum');
+
+ return embeddings.map((embedding) =>
+ typeof embedding === 'string'
+ ? new Float32Array(new Uint8Array(Buffer.from(embedding, 'base64')).buffer)
+ : new Float32Array(embedding),
+ );
+}
+
+function convertToFilter({
+ must,
+ must_not,
+}: {
+ must?: Record<string, unknown>;
+ must_not?: Record<string, unknown>;
+}): QdrantFilter {
+ return {
+ must: toConditions({ fields: must }),
+ must_not: toConditions({ fields: must_not }),
+ };
+}
+
+function parseEmbeddings({ text }: { text: string }): QdrantEmbeddingsInput {
+ if (text[0] === '[') {
+ try {
+ return JSON.parse(text);
+ } catch {
+ return text;
+ }
+ }
+ return text;
+}
+
+function toEmbeddingList({ value }: { value: QdrantEmbeddingsInput }): QdrantEmbedding[] {
+ if (typeof value === 'string') {
+ return value.length === 0 ? [] : [value];
+ }
+ const [first] = value;
+ if (typeof first === 'number' || (typeof first === 'string' && first.length === 1)) {
+ return [value.map(Number)];
+ }
+ return value.map((embedding) => (typeof embedding === 'number' ? [embedding] : embedding));
+}
+
+function toConditions({ fields }: { fields?: Record<string, unknown> }): QdrantCondition[] {
+ return Object.entries(fields ?? {}).flatMap(([key, rawValue]): QdrantCondition[] => {
+ const value = parseFilterValue({ value: rawValue });
+
+ if (['id', 'ids'].includes(key.toLocaleLowerCase())) {
+ return [{ has_id: (value instanceof Array ? value : [value]).map(toPointId) }];
+ }
+
+ if (value instanceof Array) {
+ return [
+ { key, match: { any: value } },
+ { key, match: { value } },
+ ];
+ }
+
+ return [{ key, match: { value } }];
+ });
+}
+
+function toPointId(id: unknown): QdrantPointId {
+ return typeof id === 'number' ? id : String(id);
+}
+
+function parsePointId({ id }: { id: unknown }): QdrantPointId {
+ const value = typeof id === 'string' && /^\d+$/.test(id) ? Number(id) : id;
+ if (typeof value === 'string') {
+ return value;
+ }
+ if (typeof value === 'number' && Number.isSafeInteger(value) && value >= 0) {
+ return value;
+ }
+ throw new Error(
+ `Point ID ${String(id)} is invalid: use a UUID string or an unsigned integer up to ${
+ Number.MAX_SAFE_INTEGER
+ }.`,
+ );
+}
+
+function pointsSelector({
+ pointIds,
+ filter,
+}: {
+ pointIds?: unknown[];
+ filter?: Record<string, unknown>;
+}): QdrantPointsSelector {
+ if (pointIds !== undefined && pointIds.length > 0) {
+ if (filter !== undefined) {
+ throw new Error(EXACTLY_ONE_SELECTOR);
+ }
+ return { points: pointIds.map((id) => parsePointId({ id })) };
+ }
+ if (filter === undefined) {
+ throw new Error(EXACTLY_ONE_SELECTOR);
+ }
+ return { filter };
+}
+
+function requireItems<T>({ items, propName }: { items: T[]; propName: string }): T[] {
+ if (items.length === 0) {
+ throw new Error(`${propName} must contain at least one item.`);
+ }
+ return items;
+}
+
+function parseFilterValue({ value }: { value: unknown }): unknown {
+ if (typeof value === 'string' && ['{', '['].includes(value[0])) {
+ try {
+ return JSON.parse(value);
+ } catch {
+ return value;
+ }
+ }
+ return value;
+}
+
+export const qdrantUtils = {
+ decodeEmbeddings,
+ convertToFilter,
+ toPointId,
+ parsePointId,
+ pointsSelector,
+ requireItems,
+};
+
+const EXACTLY_ONE_SELECTOR = 'Provide exactly one of Point IDs or Filter.';
diff --git a/packages/pieces/community/qdrant/src/lib/output-schemas.ts b/packages/pieces/community/qdrant/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..5e6619ee23c
--- /dev/null
+++ b/packages/pieces/community/qdrant/src/lib/output-schemas.ts
@@ -0,0 +1,187 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const payloadField: OutputSchema['fields'][number] = {
+ key: 'payload',
+ label: 'Payload',
+ dynamicKey: true,
+};
+
+const vectorField: OutputSchema['fields'][number] = {
+ key: 'vector',
+ label: 'Vector',
+ dynamicKey: true,
+};
+
+const pointFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Point ID' },
+ payloadField,
+ vectorField,
+];
+
+const scoredPointFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Point ID' },
+ { key: 'score', label: 'Score', format: 'number' },
+ { key: 'version', label: 'Version', format: 'number' },
+ payloadField,
+];
+
+const snapshotFields: OutputSchema['fields'] = [
+ { key: 'name', label: 'Snapshot Name' },
+ { key: 'creation_time', label: 'Created At', format: 'datetime' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+ { key: 'checksum', label: 'Checksum' },
+];
+
+export const qdrantSuccessOutputSchema: OutputSchema = {
+ fields: [{ key: 'success', label: 'Success', format: 'boolean' }],
+};
+
+export const qdrantUpdateResultOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'operation_id', label: 'Operation ID', format: 'number' },
+ { key: 'status', label: 'Status' },
+ ],
+};
+
+export const qdrantCollectionExistsOutputSchema: OutputSchema = {
+ fields: [{ key: 'exists', label: 'Exists', format: 'boolean' }],
+};
+
+export const qdrantListCollectionsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'collections',
+ label: 'Collections',
+ labelKey: 'name',
+ listItems: [{ key: 'name', label: 'Collection Name' }],
+ },
+ ],
+};
+
+export const qdrantGetCollectionOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'status', label: 'Status' },
+ { key: 'optimizer_status', label: 'Optimizer Status' },
+ { key: 'points_count', label: 'Points Count', format: 'number' },
+ { key: 'indexed_vectors_count', label: 'Indexed Vectors Count', format: 'number' },
+ { key: 'segments_count', label: 'Segments Count', format: 'number' },
+ {
+ key: 'config',
+ label: 'Configuration',
+ children: [
+ {
+ key: 'params',
+ label: 'Parameters',
+ children: [
+ { key: 'vectors', label: 'Vectors', dynamicKey: true },
+ { key: 'sparse_vectors', label: 'Sparse Vectors', dynamicKey: true },
+ { key: 'shard_number', label: 'Shard Number', format: 'number' },
+ { key: 'replication_factor', label: 'Replication Factor', format: 'number' },
+ {
+ key: 'write_consistency_factor',
+ label: 'Write Consistency Factor',
+ format: 'number',
+ },
+ { key: 'on_disk_payload', label: 'On-Disk Payload', format: 'boolean' },
+ ],
+ },
+ { key: 'hnsw_config', label: 'HNSW Config', dynamicKey: true },
+ { key: 'optimizer_config', label: 'Optimizer Config', dynamicKey: true },
+ { key: 'wal_config', label: 'WAL Config', dynamicKey: true },
+ { key: 'quantization_config', label: 'Quantization Config' },
+ ],
+ },
+ { key: 'payload_schema', label: 'Payload Indexes', dynamicKey: true },
+ ],
+};
+
+export const qdrantListAliasesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'aliases',
+ label: 'Aliases',
+ labelKey: 'alias_name',
+ listItems: [
+ { key: 'alias_name', label: 'Alias Name' },
+ { key: 'collection_name', label: 'Collection Name' },
+ ],
+ },
+ ],
+};
+
+export const qdrantCreateSnapshotOutputSchema: OutputSchema = {
+ fields: snapshotFields,
+};
+
+export const qdrantListSnapshotsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'snapshots', label: 'Snapshots', labelKey: 'name', listItems: snapshotFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const qdrantGetPointsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'points', label: 'Points', labelKey: 'id', listItems: pointFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const qdrantScrollPointsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'points', label: 'Points', labelKey: 'id', listItems: pointFields },
+ { key: 'next_page_offset', label: 'Next Page Offset' },
+ ],
+};
+
+export const qdrantCountPointsOutputSchema: OutputSchema = {
+ fields: [{ key: 'count', label: 'Count', format: 'number' }],
+};
+
+export const qdrantQueryPointsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'points',
+ label: 'Points',
+ labelKey: 'id',
+ listItems: [...scoredPointFields, vectorField],
+ },
+ ],
+};
+
+export const qdrantQueryPointsGroupsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'groups',
+ label: 'Groups',
+ labelKey: 'id',
+ listItems: [
+ { key: 'id', label: 'Group Value' },
+ { key: 'hits', label: 'Hits', labelKey: 'id', listItems: scoredPointFields },
+ ],
+ },
+ ],
+};
+
+export const qdrantFacetPayloadOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'hits',
+ label: 'Values',
+ labelKey: 'value',
+ listItems: [
+ { key: 'value', label: 'Value' },
+ { key: 'count', label: 'Points Count', format: 'number' },
+ ],
+ },
+ ],
+};
+
+export const deleteCollectionOutputSchema: OutputSchema = {
+ fields: [{ key: 'deleted', label: 'Deleted', value: '', format: 'boolean' }],
+};
+
+export const searchPointsOutputSchema: OutputSchema = {
+ itemLabel: 'Point {id}',
+ fields: [{ key: 'points', label: 'Points', value: '', listItems: scoredPointFields }],
+};