Skip to content

docs: add integration guide for PlainID SDK #32129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mottig30
Copy link

Description:
This PR adds a usage notebook for the PlainID integration with LangChain. It includes examples demonstrating how to build chains for data categorization, anonymization, and retrieval based on PlainID policy enforcement. This provides a practical guide for developers looking to embed authorization-aware agents using LangChain.

Issue:
None

Dependencies:
None

Copy link

vercel bot commented Jul 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Comments Updated (UTC)
langchain Ready Preview 💬 Add feedback Aug 11, 2025 10:42pm

Copy link

codspeed-hq bot commented Jul 21, 2025

CodSpeed WallTime Performance Report

Merging #32129 will not alter performance

Comparing mottig30:patch-2 (fb7cf40) with master (166c027)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched benchmarks

Copy link

codspeed-hq bot commented Jul 21, 2025

CodSpeed Instrumentation Performance Report

Merging #32129 will not alter performance

Comparing mottig30:patch-2 (fb7cf40) with master (166c027)

Summary

✅ 14 untouched benchmarks

@mdrxy mdrxy added the new-integration Adding a new partner library package label Jul 22, 2025
@mdrxy mdrxy changed the title docs(plainid): add integration guide for PlainID SDK docs: add integration guide for PlainID SDK Aug 11, 2025
@mdrxy mdrxy requested a review from Copilot August 11, 2025 22:33
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive documentation for integrating PlainID SDK with LangChain, providing developers with practical guidance on implementing authorization-aware agents. The documentation covers the complete workflow from installation to building chains that handle data categorization, anonymization, and secure retrieval.

Key changes:

  • Complete integration guide with PlainID setup instructions
  • Examples for category filtering, data anonymization, and retrieval with policy enforcement
  • Code examples demonstrating chain composition and vector store integration
Comments suppressed due to low confidence (3)

docs/docs/integrations/tools/plainid.ipynb:1

  • The placeholder '' is invalid Python syntax and will cause a syntax error. This should be replaced with a proper classifier instance.
{"cells": [{"cell_type": "markdown", "id": "f77a88b0", "metadata": {}, "source": ["# LangChain PlainID Integration Guide"]}, {"cell_type": "markdown", "id": "d3a825b0", "metadata": {}, "source": ["## Installation"]}, {"cell_type": "markdown", "id": "91f1382a", "metadata": {}, "source": ["Based on your environment, you can install the library using pip:"]}, {"cell_type": "code", "execution_count": null, "id": "b3aefa28", "metadata": {}, "outputs": [], "source": ["!pip install langchain_plainid"]}, {"cell_type": "markdown", "id": "d05905bd", "metadata": {}, "source": ["## Setup with PlainID"]}, {"cell_type": "markdown", "id": "63146826", "metadata": {}, "source": ["1. Retrieve your PlainID credentials to access the platform - client ID and client secret.\n", "2. Find your PlainID base URL. For production use: `https://platform-product.us1.plainid.io` (note: starts with `platform-product.`)\n", "\n", "**Security Note:** Do not store credentials in code. Use environment variables or secret managers."]}, {"cell_type": "markdown", "id": "7fbc84dc", "metadata": {}, "source": ["## Category Filtering Setup in PlainID"]}, {"cell_type": "markdown", "id": "977d6d86", "metadata": {}, "source": ["You need to configure the relevant Ruleset in PlainID. For example, for template `categories`:\n", "```rego\n", "# METADATA\n", "# custom:\n", "#   plainid:\n", "#     kind: Ruleset\n", "#     name: All\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"categories\"\n", "}\n", "```\n", "Also configure asset types like `contract`, `HR` in PlainID."]}, {"cell_type": "code", "execution_count": null, "id": "993b425f", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDCategorizer, PlainIDPermissionsProvider\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", "    client_id=\"your_client_id\",\n", "    client_secret=\"your_client_secret\",\n", "    base_url=\"https://platform-product.us1.plainid.io\",\n", "    plainid_categories_resource_type=\"categories\"\n", ")\n", "\n", "plainid_categorizer = PlainIDCategorizer(\n", "    classifier_provider=<classifier>,\n", "    permissions_provider=permissions_provider\n", ")\n", "\n", "query = \"I'd like to know the weather forecast for today\"\n", "result = plainid_categorizer.invoke(query)"]}, {"cell_type": "markdown", "id": "f45ed4fd", "metadata": {}, "source": ["## Category Classifiers"]}, {"cell_type": "markdown", "id": "f9536725", "metadata": {}, "source": ["### 1. LLMCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "a3d8a816", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import LLMCategoryClassifierProvider\n", "llm_classifier = LLMCategoryClassifierProvider(llm=OllamaLLM(model=\"llama2\"))"]}, {"cell_type": "markdown", "id": "c24e92b1", "metadata": {}, "source": ["### 2. ZeroShotCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "601563bd", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import ZeroShotCategoryClassifierProvider\n", "zeroshot_classifier = ZeroShotCategoryClassifierProvider()"]}, {"cell_type": "markdown", "id": "ed0b6a48", "metadata": {}, "source": ["## Anonymizer Setup in PlainID"]}, {"cell_type": "markdown", "id": "4c215a0f", "metadata": {}, "source": ["Example Ruleset for `entities` template:\n", "```rego\n", "# METADATA\n", "# custom:\n", "#   plainid:\n", "#     kind: Ruleset\n", "#     name: PERSON\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"entities\"\n", "    asset[\"path\"] == \"PERSON\"\n", "    action.id in [\"MASK\"]\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "40de20d5", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDPermissionsProvider, PlainIDAnonymizer\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", "    client_id=\"your_client_id\",\n", "    client_secret=\"your_client_secret\",\n", "    base_url=\"https://platform-product.us1.plainid.io\",\n", "    plainid_entities_resource_type=\"entities\"\n", ")\n", "\n", "plainid_anonymizer = PlainIDAnonymizer(\n", "    permissions_provider=permissions_provider,\n", "    encrypt_key=\"your_encryption_key\"\n", ")\n", "\n", "query = \"What's the name of the person who is responsible for the contract?\"\n", "result = plainid_anonymizer.invoke(query)"]}, {"cell_type": "markdown", "id": "cfa9b772", "metadata": {}, "source": ["## Full Chain Example"]}, {"cell_type": "code", "execution_count": null, "id": "7cb60e73", "metadata": {}, "outputs": [], "source": ["chain = plainid_categorizer | llm | vector_store | plainid_anonymizer | output_parser"]}, {"cell_type": "markdown", "id": "d43010fa", "metadata": {}, "source": ["## Retriever Setup"]}, {"cell_type": "markdown", "id": "ea6f43ce", "metadata": {}, "source": ["Rulesets for customer template:\n", "```rego\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"customer\"\n", "    asset[\"country\"] == \"Sweden\"\n", "    asset[\"country\"] != \"Russia\"\n", "    contains(asset[\"country\"], \"we\")\n", "    startswith(asset[\"country\"], \"Sw\")\n", "}\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"customer\"\n", "    asset[\"country\"] in [\"aaa\", \"bbb\"]\n", "    asset[\"age\"] <= 11111\n", "    endswith(asset[\"country\"], \"wwww\")\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "8b3a41af", "metadata": {}, "outputs": [], "source": ["from langchain_community.vectorstores import Chroma\n", "from langchain_core.documents import Document\n", "from langchain_plainid import PlainIDRetriever\n", "\n", "documents = [\n", "    Document(\"Stockholm is the capital of Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", "    Document(\"Oslo is the capital of Norway.\", metadata={\"country\": \"Norway\", \"age\": 5}),\n", "    Document(\"Copenhagen is the capital of Denmark.\", metadata={\"country\": \"Denmark\", \"age\": 5}),\n", "    Document(\"Helsinki is the capital of Finland.\", metadata={\"country\": \"Finland\", \"age\": 5}),\n", "    Document(\"Malm\u00f6 is a city in Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", "]\n", "\n", "vector_store = Chroma.from_documents(documents, embeddings)\n", "plainid_retriever = PlainIDRetriever(vectorstore=vector_store, filter_provider=filter_provider)\n", "docs = plainid_retriever.invoke(\"What is the capital of Sweden?\")"]}, {"cell_type": "markdown", "id": "b0b3ceb8", "metadata": {}, "source": ["## Supported Vector Stores and Limitations"]}, {"cell_type": "markdown", "id": "11f1ec03", "metadata": {}, "source": ["| Vector Store | Not Supported Operators                       |\n", "|--------------|-----------------------------------------------|\n", "| FAISS        | STARTSWITH, ENDSWITH, CONTAINS                |\n", "| Chroma       | IN, NOT_IN, STARTSWITH, ENDSWITH, CONTAINS    |"]}], "metadata": {"title": "LangChain PlainID Integration"}, "nbformat": 4, "nbformat_minor": 5}

docs/docs/integrations/tools/plainid.ipynb:1

  • OllamaLLM is used without importing it. This will result in a NameError at runtime.
{"cells": [{"cell_type": "markdown", "id": "f77a88b0", "metadata": {}, "source": ["# LangChain PlainID Integration Guide"]}, {"cell_type": "markdown", "id": "d3a825b0", "metadata": {}, "source": ["## Installation"]}, {"cell_type": "markdown", "id": "91f1382a", "metadata": {}, "source": ["Based on your environment, you can install the library using pip:"]}, {"cell_type": "code", "execution_count": null, "id": "b3aefa28", "metadata": {}, "outputs": [], "source": ["!pip install langchain_plainid"]}, {"cell_type": "markdown", "id": "d05905bd", "metadata": {}, "source": ["## Setup with PlainID"]}, {"cell_type": "markdown", "id": "63146826", "metadata": {}, "source": ["1. Retrieve your PlainID credentials to access the platform - client ID and client secret.\n", "2. Find your PlainID base URL. For production use: `https://platform-product.us1.plainid.io` (note: starts with `platform-product.`)\n", "\n", "**Security Note:** Do not store credentials in code. Use environment variables or secret managers."]}, {"cell_type": "markdown", "id": "7fbc84dc", "metadata": {}, "source": ["## Category Filtering Setup in PlainID"]}, {"cell_type": "markdown", "id": "977d6d86", "metadata": {}, "source": ["You need to configure the relevant Ruleset in PlainID. For example, for template `categories`:\n", "```rego\n", "# METADATA\n", "# custom:\n", "#   plainid:\n", "#     kind: Ruleset\n", "#     name: All\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"categories\"\n", "}\n", "```\n", "Also configure asset types like `contract`, `HR` in PlainID."]}, {"cell_type": "code", "execution_count": null, "id": "993b425f", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDCategorizer, PlainIDPermissionsProvider\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", "    client_id=\"your_client_id\",\n", "    client_secret=\"your_client_secret\",\n", "    base_url=\"https://platform-product.us1.plainid.io\",\n", "    plainid_categories_resource_type=\"categories\"\n", ")\n", "\n", "plainid_categorizer = PlainIDCategorizer(\n", "    classifier_provider=<classifier>,\n", "    permissions_provider=permissions_provider\n", ")\n", "\n", "query = \"I'd like to know the weather forecast for today\"\n", "result = plainid_categorizer.invoke(query)"]}, {"cell_type": "markdown", "id": "f45ed4fd", "metadata": {}, "source": ["## Category Classifiers"]}, {"cell_type": "markdown", "id": "f9536725", "metadata": {}, "source": ["### 1. LLMCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "a3d8a816", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import LLMCategoryClassifierProvider\n", "llm_classifier = LLMCategoryClassifierProvider(llm=OllamaLLM(model=\"llama2\"))"]}, {"cell_type": "markdown", "id": "c24e92b1", "metadata": {}, "source": ["### 2. ZeroShotCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "601563bd", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import ZeroShotCategoryClassifierProvider\n", "zeroshot_classifier = ZeroShotCategoryClassifierProvider()"]}, {"cell_type": "markdown", "id": "ed0b6a48", "metadata": {}, "source": ["## Anonymizer Setup in PlainID"]}, {"cell_type": "markdown", "id": "4c215a0f", "metadata": {}, "source": ["Example Ruleset for `entities` template:\n", "```rego\n", "# METADATA\n", "# custom:\n", "#   plainid:\n", "#     kind: Ruleset\n", "#     name: PERSON\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"entities\"\n", "    asset[\"path\"] == \"PERSON\"\n", "    action.id in [\"MASK\"]\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "40de20d5", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDPermissionsProvider, PlainIDAnonymizer\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", "    client_id=\"your_client_id\",\n", "    client_secret=\"your_client_secret\",\n", "    base_url=\"https://platform-product.us1.plainid.io\",\n", "    plainid_entities_resource_type=\"entities\"\n", ")\n", "\n", "plainid_anonymizer = PlainIDAnonymizer(\n", "    permissions_provider=permissions_provider,\n", "    encrypt_key=\"your_encryption_key\"\n", ")\n", "\n", "query = \"What's the name of the person who is responsible for the contract?\"\n", "result = plainid_anonymizer.invoke(query)"]}, {"cell_type": "markdown", "id": "cfa9b772", "metadata": {}, "source": ["## Full Chain Example"]}, {"cell_type": "code", "execution_count": null, "id": "7cb60e73", "metadata": {}, "outputs": [], "source": ["chain = plainid_categorizer | llm | vector_store | plainid_anonymizer | output_parser"]}, {"cell_type": "markdown", "id": "d43010fa", "metadata": {}, "source": ["## Retriever Setup"]}, {"cell_type": "markdown", "id": "ea6f43ce", "metadata": {}, "source": ["Rulesets for customer template:\n", "```rego\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"customer\"\n", "    asset[\"country\"] == \"Sweden\"\n", "    asset[\"country\"] != \"Russia\"\n", "    contains(asset[\"country\"], \"we\")\n", "    startswith(asset[\"country\"], \"Sw\")\n", "}\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"customer\"\n", "    asset[\"country\"] in [\"aaa\", \"bbb\"]\n", "    asset[\"age\"] <= 11111\n", "    endswith(asset[\"country\"], \"wwww\")\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "8b3a41af", "metadata": {}, "outputs": [], "source": ["from langchain_community.vectorstores import Chroma\n", "from langchain_core.documents import Document\n", "from langchain_plainid import PlainIDRetriever\n", "\n", "documents = [\n", "    Document(\"Stockholm is the capital of Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", "    Document(\"Oslo is the capital of Norway.\", metadata={\"country\": \"Norway\", \"age\": 5}),\n", "    Document(\"Copenhagen is the capital of Denmark.\", metadata={\"country\": \"Denmark\", \"age\": 5}),\n", "    Document(\"Helsinki is the capital of Finland.\", metadata={\"country\": \"Finland\", \"age\": 5}),\n", "    Document(\"Malm\u00f6 is a city in Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", "]\n", "\n", "vector_store = Chroma.from_documents(documents, embeddings)\n", "plainid_retriever = PlainIDRetriever(vectorstore=vector_store, filter_provider=filter_provider)\n", "docs = plainid_retriever.invoke(\"What is the capital of Sweden?\")"]}, {"cell_type": "markdown", "id": "b0b3ceb8", "metadata": {}, "source": ["## Supported Vector Stores and Limitations"]}, {"cell_type": "markdown", "id": "11f1ec03", "metadata": {}, "source": ["| Vector Store | Not Supported Operators                       |\n", "|--------------|-----------------------------------------------|\n", "| FAISS        | STARTSWITH, ENDSWITH, CONTAINS                |\n", "| Chroma       | IN, NOT_IN, STARTSWITH, ENDSWITH, CONTAINS    |"]}], "metadata": {"title": "LangChain PlainID Integration"}, "nbformat": 4, "nbformat_minor": 5}

docs/docs/integrations/tools/plainid.ipynb:1

  • [nitpick] While the security note mentions not storing credentials in code, the examples still use placeholder strings that could be mistakenly used as-is. Consider using environment variable examples like os.getenv('PLAINID_CLIENT_ID') to demonstrate best practices.
{"cells": [{"cell_type": "markdown", "id": "f77a88b0", "metadata": {}, "source": ["# LangChain PlainID Integration Guide"]}, {"cell_type": "markdown", "id": "d3a825b0", "metadata": {}, "source": ["## Installation"]}, {"cell_type": "markdown", "id": "91f1382a", "metadata": {}, "source": ["Based on your environment, you can install the library using pip:"]}, {"cell_type": "code", "execution_count": null, "id": "b3aefa28", "metadata": {}, "outputs": [], "source": ["!pip install langchain_plainid"]}, {"cell_type": "markdown", "id": "d05905bd", "metadata": {}, "source": ["## Setup with PlainID"]}, {"cell_type": "markdown", "id": "63146826", "metadata": {}, "source": ["1. Retrieve your PlainID credentials to access the platform - client ID and client secret.\n", "2. Find your PlainID base URL. For production use: `https://platform-product.us1.plainid.io` (note: starts with `platform-product.`)\n", "\n", "**Security Note:** Do not store credentials in code. Use environment variables or secret managers."]}, {"cell_type": "markdown", "id": "7fbc84dc", "metadata": {}, "source": ["## Category Filtering Setup in PlainID"]}, {"cell_type": "markdown", "id": "977d6d86", "metadata": {}, "source": ["You need to configure the relevant Ruleset in PlainID. For example, for template `categories`:\n", "```rego\n", "# METADATA\n", "# custom:\n", "#   plainid:\n", "#     kind: Ruleset\n", "#     name: All\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"categories\"\n", "}\n", "```\n", "Also configure asset types like `contract`, `HR` in PlainID."]}, {"cell_type": "code", "execution_count": null, "id": "993b425f", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDCategorizer, PlainIDPermissionsProvider\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", "    client_id=\"your_client_id\",\n", "    client_secret=\"your_client_secret\",\n", "    base_url=\"https://platform-product.us1.plainid.io\",\n", "    plainid_categories_resource_type=\"categories\"\n", ")\n", "\n", "plainid_categorizer = PlainIDCategorizer(\n", "    classifier_provider=<classifier>,\n", "    permissions_provider=permissions_provider\n", ")\n", "\n", "query = \"I'd like to know the weather forecast for today\"\n", "result = plainid_categorizer.invoke(query)"]}, {"cell_type": "markdown", "id": "f45ed4fd", "metadata": {}, "source": ["## Category Classifiers"]}, {"cell_type": "markdown", "id": "f9536725", "metadata": {}, "source": ["### 1. LLMCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "a3d8a816", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import LLMCategoryClassifierProvider\n", "llm_classifier = LLMCategoryClassifierProvider(llm=OllamaLLM(model=\"llama2\"))"]}, {"cell_type": "markdown", "id": "c24e92b1", "metadata": {}, "source": ["### 2. ZeroShotCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "601563bd", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import ZeroShotCategoryClassifierProvider\n", "zeroshot_classifier = ZeroShotCategoryClassifierProvider()"]}, {"cell_type": "markdown", "id": "ed0b6a48", "metadata": {}, "source": ["## Anonymizer Setup in PlainID"]}, {"cell_type": "markdown", "id": "4c215a0f", "metadata": {}, "source": ["Example Ruleset for `entities` template:\n", "```rego\n", "# METADATA\n", "# custom:\n", "#   plainid:\n", "#     kind: Ruleset\n", "#     name: PERSON\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"entities\"\n", "    asset[\"path\"] == \"PERSON\"\n", "    action.id in [\"MASK\"]\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "40de20d5", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDPermissionsProvider, PlainIDAnonymizer\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", "    client_id=\"your_client_id\",\n", "    client_secret=\"your_client_secret\",\n", "    base_url=\"https://platform-product.us1.plainid.io\",\n", "    plainid_entities_resource_type=\"entities\"\n", ")\n", "\n", "plainid_anonymizer = PlainIDAnonymizer(\n", "    permissions_provider=permissions_provider,\n", "    encrypt_key=\"your_encryption_key\"\n", ")\n", "\n", "query = \"What's the name of the person who is responsible for the contract?\"\n", "result = plainid_anonymizer.invoke(query)"]}, {"cell_type": "markdown", "id": "cfa9b772", "metadata": {}, "source": ["## Full Chain Example"]}, {"cell_type": "code", "execution_count": null, "id": "7cb60e73", "metadata": {}, "outputs": [], "source": ["chain = plainid_categorizer | llm | vector_store | plainid_anonymizer | output_parser"]}, {"cell_type": "markdown", "id": "d43010fa", "metadata": {}, "source": ["## Retriever Setup"]}, {"cell_type": "markdown", "id": "ea6f43ce", "metadata": {}, "source": ["Rulesets for customer template:\n", "```rego\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"customer\"\n", "    asset[\"country\"] == \"Sweden\"\n", "    asset[\"country\"] != \"Russia\"\n", "    contains(asset[\"country\"], \"we\")\n", "    startswith(asset[\"country\"], \"Sw\")\n", "}\n", "ruleset(asset, identity, requestParams, action) if {\n", "    asset.template == \"customer\"\n", "    asset[\"country\"] in [\"aaa\", \"bbb\"]\n", "    asset[\"age\"] <= 11111\n", "    endswith(asset[\"country\"], \"wwww\")\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "8b3a41af", "metadata": {}, "outputs": [], "source": ["from langchain_community.vectorstores import Chroma\n", "from langchain_core.documents import Document\n", "from langchain_plainid import PlainIDRetriever\n", "\n", "documents = [\n", "    Document(\"Stockholm is the capital of Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", "    Document(\"Oslo is the capital of Norway.\", metadata={\"country\": \"Norway\", \"age\": 5}),\n", "    Document(\"Copenhagen is the capital of Denmark.\", metadata={\"country\": \"Denmark\", \"age\": 5}),\n", "    Document(\"Helsinki is the capital of Finland.\", metadata={\"country\": \"Finland\", \"age\": 5}),\n", "    Document(\"Malm\u00f6 is a city in Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", "]\n", "\n", "vector_store = Chroma.from_documents(documents, embeddings)\n", "plainid_retriever = PlainIDRetriever(vectorstore=vector_store, filter_provider=filter_provider)\n", "docs = plainid_retriever.invoke(\"What is the capital of Sweden?\")"]}, {"cell_type": "markdown", "id": "b0b3ceb8", "metadata": {}, "source": ["## Supported Vector Stores and Limitations"]}, {"cell_type": "markdown", "id": "11f1ec03", "metadata": {}, "source": ["| Vector Store | Not Supported Operators                       |\n", "|--------------|-----------------------------------------------|\n", "| FAISS        | STARTSWITH, ENDSWITH, CONTAINS                |\n", "| Chroma       | IN, NOT_IN, STARTSWITH, ENDSWITH, CONTAINS    |"]}], "metadata": {"title": "LangChain PlainID Integration"}, "nbformat": 4, "nbformat_minor": 5}

@@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": "f77a88b0", "metadata": {}, "source": ["# LangChain PlainID Integration Guide"]}, {"cell_type": "markdown", "id": "d3a825b0", "metadata": {}, "source": ["## Installation"]}, {"cell_type": "markdown", "id": "91f1382a", "metadata": {}, "source": ["Based on your environment, you can install the library using pip:"]}, {"cell_type": "code", "execution_count": null, "id": "b3aefa28", "metadata": {}, "outputs": [], "source": ["!pip install langchain_plainid"]}, {"cell_type": "markdown", "id": "d05905bd", "metadata": {}, "source": ["## Setup with PlainID"]}, {"cell_type": "markdown", "id": "63146826", "metadata": {}, "source": ["1. Retrieve your PlainID credentials to access the platform - client ID and client secret.\n", "2. Find your PlainID base URL. For production use: `https://platform-product.us1.plainid.io` (note: starts with `platform-product.`)\n", "\n", "**Security Note:** Do not store credentials in code. Use environment variables or secret managers."]}, {"cell_type": "markdown", "id": "7fbc84dc", "metadata": {}, "source": ["## Category Filtering Setup in PlainID"]}, {"cell_type": "markdown", "id": "977d6d86", "metadata": {}, "source": ["You need to configure the relevant Ruleset in PlainID. For example, for template `categories`:\n", "```rego\n", "# METADATA\n", "# custom:\n", "# plainid:\n", "# kind: Ruleset\n", "# name: All\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"categories\"\n", "}\n", "```\n", "Also configure asset types like `contract`, `HR` in PlainID."]}, {"cell_type": "code", "execution_count": null, "id": "993b425f", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDCategorizer, PlainIDPermissionsProvider\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", " client_id=\"your_client_id\",\n", " client_secret=\"your_client_secret\",\n", " base_url=\"https://platform-product.us1.plainid.io\",\n", " plainid_categories_resource_type=\"categories\"\n", ")\n", "\n", "plainid_categorizer = PlainIDCategorizer(\n", " classifier_provider=<classifier>,\n", " permissions_provider=permissions_provider\n", ")\n", "\n", "query = \"I'd like to know the weather forecast for today\"\n", "result = plainid_categorizer.invoke(query)"]}, {"cell_type": "markdown", "id": "f45ed4fd", "metadata": {}, "source": ["## Category Classifiers"]}, {"cell_type": "markdown", "id": "f9536725", "metadata": {}, "source": ["### 1. LLMCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "a3d8a816", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import LLMCategoryClassifierProvider\n", "llm_classifier = LLMCategoryClassifierProvider(llm=OllamaLLM(model=\"llama2\"))"]}, {"cell_type": "markdown", "id": "c24e92b1", "metadata": {}, "source": ["### 2. ZeroShotCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "601563bd", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import ZeroShotCategoryClassifierProvider\n", "zeroshot_classifier = ZeroShotCategoryClassifierProvider()"]}, {"cell_type": "markdown", "id": "ed0b6a48", "metadata": {}, "source": ["## Anonymizer Setup in PlainID"]}, {"cell_type": "markdown", "id": "4c215a0f", "metadata": {}, "source": ["Example Ruleset for `entities` template:\n", "```rego\n", "# METADATA\n", "# custom:\n", "# plainid:\n", "# kind: Ruleset\n", "# name: PERSON\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"entities\"\n", " asset[\"path\"] == \"PERSON\"\n", " action.id in [\"MASK\"]\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "40de20d5", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDPermissionsProvider, PlainIDAnonymizer\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", " client_id=\"your_client_id\",\n", " client_secret=\"your_client_secret\",\n", " base_url=\"https://platform-product.us1.plainid.io\",\n", " plainid_entities_resource_type=\"entities\"\n", ")\n", "\n", "plainid_anonymizer = PlainIDAnonymizer(\n", " permissions_provider=permissions_provider,\n", " encrypt_key=\"your_encryption_key\"\n", ")\n", "\n", "query = \"What's the name of the person who is responsible for the contract?\"\n", "result = plainid_anonymizer.invoke(query)"]}, {"cell_type": "markdown", "id": "cfa9b772", "metadata": {}, "source": ["## Full Chain Example"]}, {"cell_type": "code", "execution_count": null, "id": "7cb60e73", "metadata": {}, "outputs": [], "source": ["chain = plainid_categorizer | llm | vector_store | plainid_anonymizer | output_parser"]}, {"cell_type": "markdown", "id": "d43010fa", "metadata": {}, "source": ["## Retriever Setup"]}, {"cell_type": "markdown", "id": "ea6f43ce", "metadata": {}, "source": ["Rulesets for customer template:\n", "```rego\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"customer\"\n", " asset[\"country\"] == \"Sweden\"\n", " asset[\"country\"] != \"Russia\"\n", " contains(asset[\"country\"], \"we\")\n", " startswith(asset[\"country\"], \"Sw\")\n", "}\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"customer\"\n", " asset[\"country\"] in [\"aaa\", \"bbb\"]\n", " asset[\"age\"] <= 11111\n", " endswith(asset[\"country\"], \"wwww\")\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "8b3a41af", "metadata": {}, "outputs": [], "source": ["from langchain_community.vectorstores import Chroma\n", "from langchain_core.documents import Document\n", "from langchain_plainid import PlainIDRetriever\n", "\n", "documents = [\n", " Document(\"Stockholm is the capital of Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", " Document(\"Oslo is the capital of Norway.\", metadata={\"country\": \"Norway\", \"age\": 5}),\n", " Document(\"Copenhagen is the capital of Denmark.\", metadata={\"country\": \"Denmark\", \"age\": 5}),\n", " Document(\"Helsinki is the capital of Finland.\", metadata={\"country\": \"Finland\", \"age\": 5}),\n", " Document(\"Malm\u00f6 is a city in Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", "]\n", "\n", "vector_store = Chroma.from_documents(documents, embeddings)\n", "plainid_retriever = PlainIDRetriever(vectorstore=vector_store, filter_provider=filter_provider)\n", "docs = plainid_retriever.invoke(\"What is the capital of Sweden?\")"]}, {"cell_type": "markdown", "id": "b0b3ceb8", "metadata": {}, "source": ["## Supported Vector Stores and Limitations"]}, {"cell_type": "markdown", "id": "11f1ec03", "metadata": {}, "source": ["| Vector Store | Not Supported Operators |\n", "|--------------|-----------------------------------------------|\n", "| FAISS | STARTSWITH, ENDSWITH, CONTAINS |\n", "| Chroma | IN, NOT_IN, STARTSWITH, ENDSWITH, CONTAINS |"]}], "metadata": {"title": "LangChain PlainID Integration"}, "nbformat": 4, "nbformat_minor": 5}
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple undefined variables are used in this chain: 'llm', 'vector_store', and 'output_parser'. These need to be defined or imported before use.

Copilot uses AI. Check for mistakes.

@@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": "f77a88b0", "metadata": {}, "source": ["# LangChain PlainID Integration Guide"]}, {"cell_type": "markdown", "id": "d3a825b0", "metadata": {}, "source": ["## Installation"]}, {"cell_type": "markdown", "id": "91f1382a", "metadata": {}, "source": ["Based on your environment, you can install the library using pip:"]}, {"cell_type": "code", "execution_count": null, "id": "b3aefa28", "metadata": {}, "outputs": [], "source": ["!pip install langchain_plainid"]}, {"cell_type": "markdown", "id": "d05905bd", "metadata": {}, "source": ["## Setup with PlainID"]}, {"cell_type": "markdown", "id": "63146826", "metadata": {}, "source": ["1. Retrieve your PlainID credentials to access the platform - client ID and client secret.\n", "2. Find your PlainID base URL. For production use: `https://platform-product.us1.plainid.io` (note: starts with `platform-product.`)\n", "\n", "**Security Note:** Do not store credentials in code. Use environment variables or secret managers."]}, {"cell_type": "markdown", "id": "7fbc84dc", "metadata": {}, "source": ["## Category Filtering Setup in PlainID"]}, {"cell_type": "markdown", "id": "977d6d86", "metadata": {}, "source": ["You need to configure the relevant Ruleset in PlainID. For example, for template `categories`:\n", "```rego\n", "# METADATA\n", "# custom:\n", "# plainid:\n", "# kind: Ruleset\n", "# name: All\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"categories\"\n", "}\n", "```\n", "Also configure asset types like `contract`, `HR` in PlainID."]}, {"cell_type": "code", "execution_count": null, "id": "993b425f", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDCategorizer, PlainIDPermissionsProvider\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", " client_id=\"your_client_id\",\n", " client_secret=\"your_client_secret\",\n", " base_url=\"https://platform-product.us1.plainid.io\",\n", " plainid_categories_resource_type=\"categories\"\n", ")\n", "\n", "plainid_categorizer = PlainIDCategorizer(\n", " classifier_provider=<classifier>,\n", " permissions_provider=permissions_provider\n", ")\n", "\n", "query = \"I'd like to know the weather forecast for today\"\n", "result = plainid_categorizer.invoke(query)"]}, {"cell_type": "markdown", "id": "f45ed4fd", "metadata": {}, "source": ["## Category Classifiers"]}, {"cell_type": "markdown", "id": "f9536725", "metadata": {}, "source": ["### 1. LLMCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "a3d8a816", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import LLMCategoryClassifierProvider\n", "llm_classifier = LLMCategoryClassifierProvider(llm=OllamaLLM(model=\"llama2\"))"]}, {"cell_type": "markdown", "id": "c24e92b1", "metadata": {}, "source": ["### 2. ZeroShotCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "601563bd", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import ZeroShotCategoryClassifierProvider\n", "zeroshot_classifier = ZeroShotCategoryClassifierProvider()"]}, {"cell_type": "markdown", "id": "ed0b6a48", "metadata": {}, "source": ["## Anonymizer Setup in PlainID"]}, {"cell_type": "markdown", "id": "4c215a0f", "metadata": {}, "source": ["Example Ruleset for `entities` template:\n", "```rego\n", "# METADATA\n", "# custom:\n", "# plainid:\n", "# kind: Ruleset\n", "# name: PERSON\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"entities\"\n", " asset[\"path\"] == \"PERSON\"\n", " action.id in [\"MASK\"]\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "40de20d5", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDPermissionsProvider, PlainIDAnonymizer\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", " client_id=\"your_client_id\",\n", " client_secret=\"your_client_secret\",\n", " base_url=\"https://platform-product.us1.plainid.io\",\n", " plainid_entities_resource_type=\"entities\"\n", ")\n", "\n", "plainid_anonymizer = PlainIDAnonymizer(\n", " permissions_provider=permissions_provider,\n", " encrypt_key=\"your_encryption_key\"\n", ")\n", "\n", "query = \"What's the name of the person who is responsible for the contract?\"\n", "result = plainid_anonymizer.invoke(query)"]}, {"cell_type": "markdown", "id": "cfa9b772", "metadata": {}, "source": ["## Full Chain Example"]}, {"cell_type": "code", "execution_count": null, "id": "7cb60e73", "metadata": {}, "outputs": [], "source": ["chain = plainid_categorizer | llm | vector_store | plainid_anonymizer | output_parser"]}, {"cell_type": "markdown", "id": "d43010fa", "metadata": {}, "source": ["## Retriever Setup"]}, {"cell_type": "markdown", "id": "ea6f43ce", "metadata": {}, "source": ["Rulesets for customer template:\n", "```rego\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"customer\"\n", " asset[\"country\"] == \"Sweden\"\n", " asset[\"country\"] != \"Russia\"\n", " contains(asset[\"country\"], \"we\")\n", " startswith(asset[\"country\"], \"Sw\")\n", "}\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"customer\"\n", " asset[\"country\"] in [\"aaa\", \"bbb\"]\n", " asset[\"age\"] <= 11111\n", " endswith(asset[\"country\"], \"wwww\")\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "8b3a41af", "metadata": {}, "outputs": [], "source": ["from langchain_community.vectorstores import Chroma\n", "from langchain_core.documents import Document\n", "from langchain_plainid import PlainIDRetriever\n", "\n", "documents = [\n", " Document(\"Stockholm is the capital of Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", " Document(\"Oslo is the capital of Norway.\", metadata={\"country\": \"Norway\", \"age\": 5}),\n", " Document(\"Copenhagen is the capital of Denmark.\", metadata={\"country\": \"Denmark\", \"age\": 5}),\n", " Document(\"Helsinki is the capital of Finland.\", metadata={\"country\": \"Finland\", \"age\": 5}),\n", " Document(\"Malm\u00f6 is a city in Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", "]\n", "\n", "vector_store = Chroma.from_documents(documents, embeddings)\n", "plainid_retriever = PlainIDRetriever(vectorstore=vector_store, filter_provider=filter_provider)\n", "docs = plainid_retriever.invoke(\"What is the capital of Sweden?\")"]}, {"cell_type": "markdown", "id": "b0b3ceb8", "metadata": {}, "source": ["## Supported Vector Stores and Limitations"]}, {"cell_type": "markdown", "id": "11f1ec03", "metadata": {}, "source": ["| Vector Store | Not Supported Operators |\n", "|--------------|-----------------------------------------------|\n", "| FAISS | STARTSWITH, ENDSWITH, CONTAINS |\n", "| Chroma | IN, NOT_IN, STARTSWITH, ENDSWITH, CONTAINS |"]}], "metadata": {"title": "LangChain PlainID Integration"}, "nbformat": 4, "nbformat_minor": 5}
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'filter_provider' is used without being defined. This should be defined or replaced with the correct permissions_provider instance.

Copilot uses AI. Check for mistakes.

@@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": "f77a88b0", "metadata": {}, "source": ["# LangChain PlainID Integration Guide"]}, {"cell_type": "markdown", "id": "d3a825b0", "metadata": {}, "source": ["## Installation"]}, {"cell_type": "markdown", "id": "91f1382a", "metadata": {}, "source": ["Based on your environment, you can install the library using pip:"]}, {"cell_type": "code", "execution_count": null, "id": "b3aefa28", "metadata": {}, "outputs": [], "source": ["!pip install langchain_plainid"]}, {"cell_type": "markdown", "id": "d05905bd", "metadata": {}, "source": ["## Setup with PlainID"]}, {"cell_type": "markdown", "id": "63146826", "metadata": {}, "source": ["1. Retrieve your PlainID credentials to access the platform - client ID and client secret.\n", "2. Find your PlainID base URL. For production use: `https://platform-product.us1.plainid.io` (note: starts with `platform-product.`)\n", "\n", "**Security Note:** Do not store credentials in code. Use environment variables or secret managers."]}, {"cell_type": "markdown", "id": "7fbc84dc", "metadata": {}, "source": ["## Category Filtering Setup in PlainID"]}, {"cell_type": "markdown", "id": "977d6d86", "metadata": {}, "source": ["You need to configure the relevant Ruleset in PlainID. For example, for template `categories`:\n", "```rego\n", "# METADATA\n", "# custom:\n", "# plainid:\n", "# kind: Ruleset\n", "# name: All\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"categories\"\n", "}\n", "```\n", "Also configure asset types like `contract`, `HR` in PlainID."]}, {"cell_type": "code", "execution_count": null, "id": "993b425f", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDCategorizer, PlainIDPermissionsProvider\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", " client_id=\"your_client_id\",\n", " client_secret=\"your_client_secret\",\n", " base_url=\"https://platform-product.us1.plainid.io\",\n", " plainid_categories_resource_type=\"categories\"\n", ")\n", "\n", "plainid_categorizer = PlainIDCategorizer(\n", " classifier_provider=<classifier>,\n", " permissions_provider=permissions_provider\n", ")\n", "\n", "query = \"I'd like to know the weather forecast for today\"\n", "result = plainid_categorizer.invoke(query)"]}, {"cell_type": "markdown", "id": "f45ed4fd", "metadata": {}, "source": ["## Category Classifiers"]}, {"cell_type": "markdown", "id": "f9536725", "metadata": {}, "source": ["### 1. LLMCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "a3d8a816", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import LLMCategoryClassifierProvider\n", "llm_classifier = LLMCategoryClassifierProvider(llm=OllamaLLM(model=\"llama2\"))"]}, {"cell_type": "markdown", "id": "c24e92b1", "metadata": {}, "source": ["### 2. ZeroShotCategoryClassifierProvider"]}, {"cell_type": "code", "execution_count": null, "id": "601563bd", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import ZeroShotCategoryClassifierProvider\n", "zeroshot_classifier = ZeroShotCategoryClassifierProvider()"]}, {"cell_type": "markdown", "id": "ed0b6a48", "metadata": {}, "source": ["## Anonymizer Setup in PlainID"]}, {"cell_type": "markdown", "id": "4c215a0f", "metadata": {}, "source": ["Example Ruleset for `entities` template:\n", "```rego\n", "# METADATA\n", "# custom:\n", "# plainid:\n", "# kind: Ruleset\n", "# name: PERSON\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"entities\"\n", " asset[\"path\"] == \"PERSON\"\n", " action.id in [\"MASK\"]\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "40de20d5", "metadata": {}, "outputs": [], "source": ["from langchain_plainid import PlainIDPermissionsProvider, PlainIDAnonymizer\n", "\n", "permissions_provider = PlainIDPermissionsProvider(\n", " client_id=\"your_client_id\",\n", " client_secret=\"your_client_secret\",\n", " base_url=\"https://platform-product.us1.plainid.io\",\n", " plainid_entities_resource_type=\"entities\"\n", ")\n", "\n", "plainid_anonymizer = PlainIDAnonymizer(\n", " permissions_provider=permissions_provider,\n", " encrypt_key=\"your_encryption_key\"\n", ")\n", "\n", "query = \"What's the name of the person who is responsible for the contract?\"\n", "result = plainid_anonymizer.invoke(query)"]}, {"cell_type": "markdown", "id": "cfa9b772", "metadata": {}, "source": ["## Full Chain Example"]}, {"cell_type": "code", "execution_count": null, "id": "7cb60e73", "metadata": {}, "outputs": [], "source": ["chain = plainid_categorizer | llm | vector_store | plainid_anonymizer | output_parser"]}, {"cell_type": "markdown", "id": "d43010fa", "metadata": {}, "source": ["## Retriever Setup"]}, {"cell_type": "markdown", "id": "ea6f43ce", "metadata": {}, "source": ["Rulesets for customer template:\n", "```rego\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"customer\"\n", " asset[\"country\"] == \"Sweden\"\n", " asset[\"country\"] != \"Russia\"\n", " contains(asset[\"country\"], \"we\")\n", " startswith(asset[\"country\"], \"Sw\")\n", "}\n", "ruleset(asset, identity, requestParams, action) if {\n", " asset.template == \"customer\"\n", " asset[\"country\"] in [\"aaa\", \"bbb\"]\n", " asset[\"age\"] <= 11111\n", " endswith(asset[\"country\"], \"wwww\")\n", "}\n", "```"]}, {"cell_type": "code", "execution_count": null, "id": "8b3a41af", "metadata": {}, "outputs": [], "source": ["from langchain_community.vectorstores import Chroma\n", "from langchain_core.documents import Document\n", "from langchain_plainid import PlainIDRetriever\n", "\n", "documents = [\n", " Document(\"Stockholm is the capital of Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", " Document(\"Oslo is the capital of Norway.\", metadata={\"country\": \"Norway\", \"age\": 5}),\n", " Document(\"Copenhagen is the capital of Denmark.\", metadata={\"country\": \"Denmark\", \"age\": 5}),\n", " Document(\"Helsinki is the capital of Finland.\", metadata={\"country\": \"Finland\", \"age\": 5}),\n", " Document(\"Malm\u00f6 is a city in Sweden.\", metadata={\"country\": \"Sweden\", \"age\": 5}),\n", "]\n", "\n", "vector_store = Chroma.from_documents(documents, embeddings)\n", "plainid_retriever = PlainIDRetriever(vectorstore=vector_store, filter_provider=filter_provider)\n", "docs = plainid_retriever.invoke(\"What is the capital of Sweden?\")"]}, {"cell_type": "markdown", "id": "b0b3ceb8", "metadata": {}, "source": ["## Supported Vector Stores and Limitations"]}, {"cell_type": "markdown", "id": "11f1ec03", "metadata": {}, "source": ["| Vector Store | Not Supported Operators |\n", "|--------------|-----------------------------------------------|\n", "| FAISS | STARTSWITH, ENDSWITH, CONTAINS |\n", "| Chroma | IN, NOT_IN, STARTSWITH, ENDSWITH, CONTAINS |"]}], "metadata": {"title": "LangChain PlainID Integration"}, "nbformat": 4, "nbformat_minor": 5}
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'embeddings' is used without being defined or imported. An embeddings instance needs to be created first.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-integration Adding a new partner library package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants