Home Applications langchain-iris

langchain-iris

This application is not supported by InterSystems Corporation. Please be notified that you use it at your own risk.
0
0 reviews
0
Awards
117
Views
0
IPM installs
1
0
Details
Releases
Reviews
Issues
Support for IRIS for Langchain

What's new in this version

Initial Release

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)

Donate
Made with
Version
0.1.216 Apr, 2024
Python package
langchain-iris
Category
Frameworks
Works with
InterSystems IRISInterSystems IRIS for Health
First published
16 Apr, 2024