The InterSystems IRIS adoption for Langchain
Project description
Langchain with InterSystems IRIS
Langchain with support for InterSystems IRIS
Install
pip install langchain-iris
Example
import os
from dotenv import load_dotenv
from langchain.docstore.document import Document
from langchain.document_loaders import TextLoader
from langchain.text_splitter import CharacterTextSplitter
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.embeddings.fastembed import FastEmbedEmbeddings
from langchain_iris import IRISVector
loader = TextLoader("state_of_the_union.txt")
documents = loader.load()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)
CONNECTION_STRING = 'iris://_SYSTEM:SYS@localhost:1972/USER'
load_dotenv(override=True)
embeddings = OpenAIEmbeddings()
COLLECTION_NAME = "state_of_the_union_test"
db = IRISVector.from_documents(
embedding=embeddings,
documents=docs,
collection_name=COLLECTION_NAME,
connection_string=CONNECTION_STRING,
)
query = "What did the president say about Ketanji Brown Jackson"
docs_with_score = db.similarity_search_with_score(query)
for doc, score in docs_with_score:
print("-" * 80)
print("Score: ", score)
print(doc.page_content)
print("-" * 80)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
langchain_iris-0.2.0.tar.gz
(9.0 kB
view details)
Built Distribution
File details
Details for the file langchain_iris-0.2.0.tar.gz
.
File metadata
- Download URL: langchain_iris-0.2.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97f3da101a0d30704286d60371813a6d548266cb957cf8fedfcb674986e4291a |
|
MD5 | 2333606a5492d46a7c665a44de935dec |
|
BLAKE2b-256 | 130d11669bc8bad2fa1f1e7629cdb4b87b3bfd20da11ff5aad798c3f8f034c6c |
File details
Details for the file langchain_iris-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: langchain_iris-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 020dfb15500f2983d41fd32c6a99a60f2e5417450e65fc36fe7544a021d65d81 |
|
MD5 | eb6c0fd45bc5633b6d3255ecad697e3d |
|
BLAKE2b-256 | c32947ba53e26dd3fa045c254d2bae0daa0cd1142c1c4bf764c215cd5d3832d4 |