langchainjs icon indicating copy to clipboard operation
langchainjs copied to clipboard

Add Qdrant custom payload on documents to query them by filter

Open uptoo-owner opened this issue 2 years ago • 7 comments

Hi !

The Qdrant integration works well with the content, vector, and payload. However, it would be great to be able to add our own payload in JSON. This would allow querying the database on more criteria, like geolocation for instance.

It would enable the creation of one's own DynamicStructuredTool and therefore search within the same Qdrant base as the vectors.

An approach like this, for instance:

     * Method to add vectors to the Qdrant database. Each vector is associated
     * with a document, which is stored as the payload for a point in the
     * database.
     * @param vectors Array of vectors to be added to the Qdrant database.
     * @param documents Array of `Document` instances associated with the vectors.
     * @returns Promise that resolves when the vectors have been added to the database.
     */
    async addVectors(vectors, documents) {
        if (vectors.length === 0) {
            return;
        }
        await this.ensureCollection();
        const points = vectors.map((embedding, idx) => ({
            id: uuid(),
            vector: embedding,
            payload: {
                // add custom payload here <========== HERE
                // ...documents[idx].payload
                content: documents[idx].pageContent,
                metadata: documents[idx].metadata,
            },
        }));
        await this.client.upsert(this.collectionName, {
            wait: true,
            points,
        });
    }```

Thanks !

uptoo-owner avatar Sep 29 '23 16:09 uptoo-owner

Hello, is anyone working on this ticket at the moment? My group and I would like to contribute to this repository for a group project.

youngjaeheo2002 avatar Oct 13 '23 20:10 youngjaeheo2002

Hi I'm going to assume that no one else is working on this and my team will get started working on it.

youngjaeheo2002 avatar Oct 18 '23 15:10 youngjaeheo2002

🤖

Hi, @uptoo-owner,

I'm helping the langchainjs team manage their backlog and am marking this issue as stale. From what I understand, you raised a request for the ability to add custom JSON payloads to documents in Qdrant, enabling diverse querying criteria such as geolocation. This feature would allow for the creation of custom DynamicStructuredTools and searching within the same Qdrant base as the vectors. The issue has garnered interest from @youngjaeheo2002 and their team, who are considering contributing to the repository for a group project.

Could you please confirm if this issue is still relevant to the latest version of the langchainjs repository? If it is, please let the langchainjs team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!

dosubot[bot] avatar Feb 29 '24 16:02 dosubot[bot]

I would like to reopen this ticket, because from my point of view it's not correct. The customPayload can be passed as general dbConfig, but will not have any effect when using fromExistingCollection(). But I think it's often the use case that I want to add a customPayload to ALL documents at once, like a tenantId. So I created another MR for this.

JustDoItSascha avatar Oct 25 '24 21:10 JustDoItSascha

Thank you! Will look as soon as possible

jacoblee93 avatar Oct 25 '24 22:10 jacoblee93

Hi, @uptoo-owner. I'm Dosu, and I'm helping the LangChain JS team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • The issue suggests enhancing Qdrant integration by allowing custom JSON payloads in documents for complex queries.
  • @youngjaeheo2002 and team showed interest in contributing to this feature.
  • @JustDoItSascha reopened the issue, highlighting the lack of support for adding custom payloads to all documents at once.
  • @jacoblee93 acknowledged the issue and promised to review the proposed changes.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the LangChain JS repository by commenting here.
  • If there is no further activity, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Jan 24 '25 16:01 dosubot[bot]

still relevant

dosubot[bot] @.***> schrieb am Fr., 24. Jan. 2025, 17:00:

Hi, @uptoo-owner https://github.com/uptoo-owner. I'm Dosu https://dosu.dev, and I'm helping the LangChain JS team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • The issue suggests enhancing Qdrant integration by allowing custom JSON payloads in documents for complex queries.
  • @youngjaeheo2002 https://github.com/youngjaeheo2002 and team showed interest in contributing to this feature.
  • @JustDoItSascha https://github.com/JustDoItSascha reopened the issue, highlighting the lack of support for adding custom payloads to all documents at once.
  • @jacoblee93 https://github.com/jacoblee93 acknowledged the issue and promised to review the proposed changes.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the LangChain JS repository by commenting here.
  • If there is no further activity, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

— Reply to this email directly, view it on GitHub https://github.com/langchain-ai/langchainjs/issues/2756#issuecomment-2612868313, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAADHQ2O4IHLHY7BDS6XRL2MJPS7AVCNFSM6AAAAABQUBMCZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMJSHA3DQMZRGM . You are receiving this because you were mentioned.Message ID: @.***>

JustDoItSascha avatar Jan 24 '25 17:01 JustDoItSascha

Let's continue this convo in #7069 .. thanks @JustDoItSascha for taking a stab at a fix for this 🙏

christian-bromann avatar Sep 12 '25 20:09 christian-bromann