Skip to main content

Indexify Langchain

PyPI version

This package contains our LangChain Retriever component, which leverages LLMs to fetch data with langchain. In order to use this retriever you must have Indexify, to read more about getting started with indexify you can read our getting started documentation.

Requirements

Indexify Retriever RAG Example

Below is an example on how you can use our indexify client and langchain retriever with OpenAI in a basic RAG example.

from indexify_langchain import IndexifyRetriever

# Initialize Indexify client
client = IndexifyClient.create_namespace("test-langchain")
client.add_extraction_policy(
    "tensorlake/minilm-l6",
    "minilml6",
)

# Add Documents
client.add_documents("Lucas is from Atlanta Georgia")

# Initialize retriever
params = {"name": "minilml6.embedding", "top_k": 9}
retriever = IndexifyRetriever(client=client, params=params)

# Setup Chat Prompt Template
from langchain.prompts import ChatPromptTemplate

template = """You are an assistant for question-answering tasks. 
Use the following pieces of retrieved context to answer the question. 
If you don't know the answer, just say that you don't know. 
Use three sentences maximum and keep the answer concise.
Question: {question} 
Context: {context} 
Answer:
"""
prompt = ChatPromptTemplate.from_template(template)

# Ask llm question with retriever context
from langchain_openai import ChatOpenAI
from langchain.schema.runnable import RunnablePassthrough
from langchain.schema.output_parser import StrOutputParser

llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0)

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

# Ask LLM Question
query = "Where is Lucas from?"
print(rag_chain.invoke(query))

Release files for indexify-langchain 0.0.36

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

Source distribution (sdist)

Source distribution for indexify-langchain 0.0.36
File Size Uploaded
indexify_langchain-0.0.36.tar.gz 2.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for indexify-langchain 0.0.36
File Interpreter ABI Platform
indexify_langchain-0.0.36-py3-none-any.whl Python 3 none any Details

Total release size: 5.5 kB

Release files / indexify_langchain-0.0.36.tar.gz

Download URL indexify_langchain-0.0.36.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
815d15126698adaed0b873747d4b6352e214b28779d10ee1769e646c24e59ff4
BLAKE2b-256 checksum
How to use checksums
e6b9192ffba58136642b23045ba9eddb6bab796f89e01c6e897953ae3fc6322a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / indexify_langchain-0.0.36-py3-none-any.whl

Download URL indexify_langchain-0.0.36-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73db1c43d5699e4a5a87c3315babfc6fa29a5cf42736a89918f4757c19958587
BLAKE2b-256 checksum
How to use checksums
e4c11e4fdc1089adf2c72f8bb7c573e4006db0ba245cc9b8fb15bb311da23c78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.0.36 This release

2 release files

0.0.32

2 release files

0.0.28

2 release files

0.0.22

2 release files

0.0.19

2 release files

0.0.17

2 release files

0.0.15

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

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