Skip to main content

langchain-superlinked

Integration package that exposes Superlinked retrieval capabilities via the standard LangChain retriever interface. It lets you plug a Superlinked-powered retriever into LangChain RAG pipelines while keeping your vector storage and schema choices flexible.

Install

pip install -U langchain-superlinked superlinked

Quickstart

import superlinked.framework as sl
from langchain_superlinked import SuperlinkedRetriever

class DocumentSchema(sl.Schema):
    id: sl.IdField
    content: sl.String

doc_schema = DocumentSchema()
text_space = sl.TextSimilaritySpace(text=doc_schema.content, model="sentence-transformers/all-MiniLM-L6-v2")
index = sl.Index([text_space])
query = (
    sl.Query(index)
    .find(doc_schema)
    .similar(text_space.text, sl.Param("query_text"))
    .select([doc_schema.content])
)

source = sl.InMemorySource(schema=doc_schema)
executor = sl.InMemoryExecutor(sources=[source], indices=[index])
app = executor.run()
source.put([
    {"id": "1", "content": "Machine learning processes data efficiently."},
    {"id": "2", "content": "NLP understands human language."},
])

retriever = SuperlinkedRetriever(sl_client=app, sl_query=query, page_content_field="content")
docs = retriever.invoke("artificial intelligence", k=2)

See more end-to-end examples in docs/.


Local development

Prerequisites: Python 3.10–3.13, uv installed.

  • Setup: uv sync --all-extras --dev && uv run pre-commit install
  • Lint & type-check: uv run ruff check . && uv run ruff format --check . && uv run mypy langchain_superlinked
  • Unit tests: make test
  • Integration tests: make integration_tests (skips if langchain_tests isn’t installed)
  • Smoke test: make smoke
  • Run examples: uv run python docs/quickstart_examples.py

CI/CD overview

On push/PR to main, GitHub Actions runs (matrix: 3.10/3.11/3.12):

  • Lint: ruff check . and ruff format --check .
  • Type-check: mypy langchain_superlinked
  • Tests: unit (network disabled) and integration (skips if standard tests unavailable)
  • Smoke test: imports the package and symbols
  • Build: python -m build to produce sdist and wheel (no publish)

Workflow file: .github/workflows/ci.yml.


Releasing

  • Preferred: tag-based OIDC publish
    • Ensure PyPI Trusted Publisher is configured for this repo.
    • Bump version in pyproject.toml using semantic versioning.
    • Tag and push: git tag vX.Y.Z && git push origin vX.Y.Z
    • CI will build and publish automatically.
  • Manual (fallback):
    • Build artifacts: make dist
    • Validate: uv run twine check dist/*
    • Publish to PyPI: uv run twine upload -r pypi dist/*

After publish, open/refresh the docs PR in the LangChain monorepo to reference the new version if needed. See LangChain’s integration guide for the process: How to contribute an integration.


Implementation overview

  • Primary entrypoint: langchain_superlinked/retrievers.py exposes SuperlinkedRetriever, a BaseRetriever.
  • Construction:
    • sl_client: Superlinked App (e.g., from InMemoryExecutor.run()).
    • sl_query: Superlinked QueryDescriptor built via sl.Query(...).find(...).similar(...).select(...).
    • page_content_field: field from Superlinked results mapped to Document.page_content.
    • Optional metadata_fields: copied into Document.metadata in addition to the always-present id.
  • Behavior:
    • Accepts runtime parameters (e.g., k, weights, filters) and forwards them to the Superlinked query.
    • Handles missing fields gracefully; returns an empty list on upstream exceptions.

Scope and non-goals

This package aims to be the minimal, well-typed LangChain integration layer for Superlinked retrievers. It intentionally does not include:

  • Dynamic schema inference or auto-generation for arbitrary datasets. Rationale: datasets vary widely; a robust solution requires additional assumptions (typing, transforms, index strategy), which goes beyond the minimal integration. We recommend implementing this in a separate helper package or cookbook code layered on top (e.g., “schema builders” that emit Superlinked schemas and indices for your domain). The examples in docs/ illustrate patterns for composing spaces (text, categorical, numeric, recency) that such builders could automate.
  • Non-retriever integrations (custom LLMs, embeddings, caches, loaders). These can live in separate packages if needed.

If you have concrete requirements for dynamic schema construction, please open an issue with sample data and desired retrieval behavior so we can discuss an extensible approach that stays decoupled from the core integration.


License

MIT (see LICENSE)

Metadata

Release files for langchain-superlinked 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-superlinked 0.1.1
File Size Uploaded
langchain_superlinked-0.1.1.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-superlinked 0.1.1
File Interpreter ABI Platform
langchain_superlinked-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.4 kB

Release files / langchain_superlinked-0.1.1.tar.gz

Download URL langchain_superlinked-0.1.1.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4ca3f4a0dd2772a2d73369117ac5ae1d67b130e4609584f1b87f12ef98ebfb01
BLAKE2b-256 checksum
How to use checksums
6be74c794fae18f41fa8ed04c8041c7a65b3816c726a98019c97114f896a0d58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2025.

Transparency log

Release files / langchain_superlinked-0.1.1-py3-none-any.whl

Download URL langchain_superlinked-0.1.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5e78bfaf7f38cfcb5aa4ab92af827ee37289a0d8cab75ae8328ad36a0c46ae3
BLAKE2b-256 checksum
How to use checksums
f4caa97f52ffa3de77b46fd8bcd0f5bfcd35b0293b1d2448fa3f2ebc54b3673b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page