Skip to main content

An integration package connecting Schift and LangChain

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

langchain-schift

LangChain integration for Schift -- vector store with server-side embedding and graph edges.

Installation

pip install langchain-schift

Quick Start

Schift handles embedding server-side, so no Embeddings object is needed:

from langchain_schift import SchiftVectorStore

store = SchiftVectorStore(
    api_key="sk-...",
    bucket="my-bucket",
)

# Add documents (embedded server-side)
store.add_texts(["Contract A supersedes Contract B", "Contract B dated 2024-01"])

# Search
results = store.similarity_search("which contract is newer?", k=3)

Graph-Enhanced Retrieval

Schift supports edges between documents. This is useful for legal citations, document versioning, knowledge graphs, and more:

# Add edges between documents
store.add_edges([
    {"source": "contract-a", "target": "contract-b", "relation": "supersedes"},
    {"source": "clause-1", "target": "contract-a", "relation": "has_child"},
])

# Search with graph expansion -- follows edges from top results
results = store.similarity_search(
    "contract terms",
    k=5,
    graph_expand=True,
    graph_depth=1,
    graph_relations=["supersedes", "has_child"],
)

Supported relation types: contradicts, supersedes, caused_by, is_a, related_to, has_child, follows.

Use with LangChain chains

from langchain_schift import SchiftVectorStore
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI

store = SchiftVectorStore(api_key="sk-...", bucket="legal-docs")
retriever = store.as_retriever(search_kwargs={"k": 5})

# Use in a chain
from langchain_core.runnables import RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser

prompt = ChatPromptTemplate.from_template(
    "Answer based on context:\n{context}\n\nQuestion: {question}"
)
llm = ChatOpenAI()

chain = (
    {"context": retriever, "question": RunnablePassthrough()}
    | prompt
    | llm
    | StrOutputParser()
)

answer = chain.invoke("What are the key contract terms?")

Modes

Mode Use case Embedding
Bucket (recommended) Upload files/texts, Schift handles everything Server-side
Collection Raw vector operations with your own embeddings Client-side or server-side
# Bucket mode (server-side embedding)
store = SchiftVectorStore(api_key="sk-...", bucket="my-bucket")

# Collection mode (bring your own embeddings)
from langchain_openai import OpenAIEmbeddings
store = SchiftVectorStore(
    api_key="sk-...",
    collection="my-collection",
    embedding=OpenAIEmbeddings(),
)

Environment Variables

Set SCHIFT_API_KEY to avoid passing api_key explicitly:

export SCHIFT_API_KEY=sk-...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_schift-0.2.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_schift-0.2.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file langchain_schift-0.2.1.tar.gz.

File metadata

  • Download URL: langchain_schift-0.2.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for langchain_schift-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6ca4d9f5a0a3eb157d927e4435401e8d12e6e54e2d3fc47972f8d03d48673701
MD5 72091e63dada04b47bc3f15c8b63a2a3
BLAKE2b-256 8dfab2033a8aced4d35a2a590b61614a1d816ef31a6c4e493c702a77418dc83f

See more details on using hashes here.

File details

Details for the file langchain_schift-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_schift-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b51e23659a18ebb1223e4f230efa00e4709ce710637e97d12fec5d8915d3da4
MD5 4e10289832fab20783c20bfbdacc13d8
BLAKE2b-256 3159101444832a6501fc6474c57152cd7f23a9b6fd7b0cd5aae581e01dec90f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page