Skip to main content

langchain-objectbox

About

This package contains the ObjectBox integrations for LangChain.

Getting Started

Install the langchain-objectbox package from PyPI via pip.

pip install langchain-objectbox

In Python import the ObjectBox vector store which is available under fully qualified class path langchain_objectbox.vectorstores.ObjectBox, e.g.:

from langchain_objectbox.vectorstores import ObjectBox

Create an ObjectBox VectorStore using e.g. one of the from_ class methods e.g. from_texts class method.

NOTE: Ensure to set argument embedding_dimensions along with the dimensions used in your embeddings model.

obx_vectorstore = ObjectBox.from_texts(texts, embeddings, embedding_dimensions=768)

Example 1: A very simple example using DeterministicFakeEmbedding

from langchain_core.embeddings.fake import DeterministicFakeEmbedding
from langchain_objectbox.vectorstores import ObjectBox

texts = ["foo", "bar", "baz"]
obx_vectorstore = ObjectBox.from_texts(
    texts, 
    DeterministicFakeEmbedding(size=10),
    embedding_dimensions=10,
)
result = obx_vectorstore.similarity_search("foo",k=1)
print(result)

Example 2: A more complex example using web retrieval chain.

Prerequisites:

from langchain_objectbox.vectorstores import ObjectBox

from langchain_community.llms import Ollama
llm = Ollama(model="llama2")

from langchain_community.document_loaders import WebBaseLoader
loader = WebBaseLoader("https://docs.smith.langchain.com/user_guide")

docs = loader.load()

from langchain_community.embeddings import OllamaEmbeddings

embeddings = OllamaEmbeddings()

from langchain.chains.combine_documents import create_stuff_documents_chain
from langchain_core.prompts.chat import ChatPromptTemplate

prompt = ChatPromptTemplate.from_template("""Answer the following question based only on the provided context:

<context>
{context}
</context>

Question: {input}""")

from langchain_text_splitters import RecursiveCharacterTextSplitter

text_splitter = RecursiveCharacterTextSplitter()
documents = text_splitter.split_documents(docs)

vector = ObjectBox.from_documents(documents, embeddings, embedding_dimensions=768)
document_chain = create_stuff_documents_chain(llm, prompt)
from langchain_core.documents import Document
from langchain.chains import create_retrieval_chain

retriever = vector.as_retriever()
retrieval_chain = create_retrieval_chain(retriever, document_chain)

response = retrieval_chain.invoke({"input": "how can langsmith help with testing?"})
print(response["answer"])

LICENSE

MIT License

Copyright (c) 2024 ObjectBox, Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Metadata

Release files for langchain-objectbox 0.1.0

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-objectbox 0.1.0
File Size Uploaded Provenance
langchain_objectbox-0.1.0.tar.gz 5.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-objectbox 0.1.0
File Interpreter ABI Platform
langchain_objectbox-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.8 kB

Release files / langchain_objectbox-0.1.0.tar.gz

Download URL langchain_objectbox-0.1.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
672d2457d51e73b5714ac583e65f6450de5ccff793a6583fec55119d628bc382
BLAKE2b-256 checksum
How to use checksums
157c7b10fd550bc193d4cec715fcc93ae44675ea2af847dad8da084b880af7fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-10036-tuxedo

Release files / langchain_objectbox-0.1.0-py3-none-any.whl

Download URL langchain_objectbox-0.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e516a007a6f6e07c747138d40eac3237fa776a178d93d084445531f212258759
BLAKE2b-256 checksum
How to use checksums
2d27fb79470372e8f23d079e9fa6b1c362835ad33ebb454b6a0e24a879747f0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-10036-tuxedo

Security for langchain-objectbox 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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