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.1.2.tar.gz
(8.3 kB
view details)
Built Distribution
File details
Details for the file langchain_iris-0.1.2.tar.gz
.
File metadata
- Download URL: langchain_iris-0.1.2.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8b0c7e8ccb577525653940f6dbbd2617e6393809f1591dfa53e5325a0fc689e |
|
MD5 | f30a4d0111dd5983bc7b546a7102044f |
|
BLAKE2b-256 | 8b7fa2e71941241bc80bf8bbe1684bb12801a69bf84e700bf318661c6a6bb5b9 |
File details
Details for the file langchain_iris-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: langchain_iris-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.8 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 | c829f6acb2778117fa4fcde2ffb584e4c91ef47b9cd8fa3ff999816525c1a237 |
|
MD5 | 14a502805953f5f2c81c406c20fb0724 |
|
BLAKE2b-256 | 40d22568837bc3027501b74cf9247ffa45a74bd51001955e8a89d07abad93e17 |