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
Built Distribution
File details
Details for the file langchain_iris-0.1.2b1.tar.gz
.
File metadata
- Download URL: langchain_iris-0.1.2b1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85b4c52edefeb79f52fd572e1aec79cb7a59e689c365a1ff5cd68702689ea97d |
|
MD5 | 419b294a51dbdd2982de5b9d5c70ebe1 |
|
BLAKE2b-256 | c02b2459b49a22aac4fed0cec9c886d9bcfb87cf4ff7b1ed3f4f5ee29b8c3e41 |
File details
Details for the file langchain_iris-0.1.2b1-py3-none-any.whl
.
File metadata
- Download URL: langchain_iris-0.1.2b1-py3-none-any.whl
- Upload date:
- Size: 7.0 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 | e8f086366edf9322d436a82409824e97f3329096d600671e31f329ddfa2ef743 |
|
MD5 | b45df74bfb51c8cb3730a10fdebc2604 |
|
BLAKE2b-256 | 04c0126ddece9705f71feac9e60e9865c1714814757543eb32db32b20ed69c7d |