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.1b1.tar.gz
(9.0 kB
view hashes)
Built Distribution
Close
Hashes for langchain_iris-0.2.1b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e8f412760c338f83aaa9f1c70c43abb359632003d1360044e96b5d3805f64a6 |
|
MD5 | 766eb252cdfddf4e9cb3451fb9471d2d |
|
BLAKE2b-256 | a5cd258d85482f7a83618077996246a78a81c57b98ba9716730cad690de2f1f8 |