Skip to content

Commit

Permalink
chore: review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Anush008 authored and netroy committed Jan 3, 2024
1 parent c5c59d2 commit c554579
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type INodeProperties } from 'n8n-workflow';
import type { QdrantLibArgs } from 'langchain/vectorstores/qdrant';
import { QdrantVectorStore } from 'langchain/vectorstores/qdrant';
import { Schemas as QdrantSchemas } from '@qdrant/js-client-rest';
import type { Schemas as QdrantSchemas } from '@qdrant/js-client-rest';
import { createVectorStoreNode } from '../shared/createVectorStoreNode';
import { qdrantCollectionRLC } from '../shared/descriptions';
import { qdrantCollectionsSearch } from '../shared/methods/listSearch';
Expand All @@ -17,13 +17,13 @@ const insertFields: INodeProperties[] = [
default: {},
options: [
{
displayName: 'Collection config',
displayName: 'Collection Config',
name: 'collectionConfig',
required: false,
type: 'json',
default: null,
description: 'JSON options for creating a collection. <a href="https://qdrant.tech/documentation/concepts/collections">Learn more</a>.',
}
default: '',
description:
'JSON options for creating a collection. <a href="https://qdrant.tech/documentation/concepts/collections">Learn more</a>.',
},
],
},
];
Expand All @@ -44,8 +44,6 @@ export const VectorStoreQdrant = createVectorStoreNode({
],
},
methods: { listSearch: { qdrantCollectionsSearch } },
retrieveFields: [],
loadFields: [],
insertFields,
sharedFields,
async getVectorStoreClient(context, filter, embeddings, itemIndex) {
Expand All @@ -71,15 +69,15 @@ export const VectorStoreQdrant = createVectorStoreNode({
// If collection config is not provided, the collection will be created with default settings
// i.e. with the size of the passed embeddings and "Cosine" distance metric
const { collectionConfig } = context.getNodeParameter('options', itemIndex, {}) as {
collectionConfig?: QdrantSchemas["CreateCollection"];
collectionConfig?: QdrantSchemas['CreateCollection'];
};
const credentials = await context.getCredentials('qdrantApi');

const config: QdrantLibArgs = {
url: credentials.qdrantUrl as string,
apiKey: credentials.apiKey as string,
collectionName,
collectionConfig
collectionConfig,
};

await QdrantVectorStore.fromDocuments(documents, embeddings, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export const qdrantCollectionRLC: INodeProperties = {
},
},
{
displayName: 'Name',
displayName: 'ID',
name: 'id',
type: 'string',
},
],
};
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ApplicationError, type IDataObject, type ILoadOptionsFunctions } from 'n8n-workflow';
import { Pinecone } from '@pinecone-database/pinecone';
import { QdrantClient } from "@qdrant/js-client-rest";

import { QdrantClient } from '@qdrant/js-client-rest';

export async function pineconeIndexSearch(this: ILoadOptionsFunctions) {
const credentials = await this.getCredentials('pineconeApi');
Expand Down Expand Up @@ -56,13 +55,13 @@ export async function qdrantCollectionsSearch(this: ILoadOptionsFunctions) {
const credentials = await this.getCredentials('qdrantApi');

const client = new QdrantClient({
"url": credentials.qdrantUrl as string,
"apiKey": credentials.apiKey as string,
});
url: credentials.qdrantUrl as string,
apiKey: credentials.apiKey as string,
});

const response = await client.getCollections();
const response = await client.getCollections();

const results = response.collections.map((collection) => ({
const results = response.collections.map((collection) => ({
name: collection.name,
value: collection.name,
}));
Expand Down

0 comments on commit c554579

Please sign in to comment.