Skip to main content

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


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.3b2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

langchain_iris-0.1.3b2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_iris-0.1.3b2.tar.gz.

File metadata

  • Download URL: langchain_iris-0.1.3b2.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

Hashes for langchain_iris-0.1.3b2.tar.gz
Algorithm Hash digest
SHA256 37d0b5ce573ce3890c493cd7f5a26465d16c86a6bf230ea0f634815b4b42a873
MD5 e4073706be53de5814b679558dda1a7d
BLAKE2b-256 843a31505688f9dae62906f4bc54a074cbb67864afa2b7a6fc295a3445f5d4f7

See more details on using hashes here.

File details

Details for the file langchain_iris-0.1.3b2-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_iris-0.1.3b2-py3-none-any.whl
Algorithm Hash digest
SHA256 905abef151c2dc6f417b6a18f9f237f533ffb7e38e9ba4a464460c8122c37031
MD5 836d760e0a123bb6e48a3ac3324909cf
BLAKE2b-256 6c07a36ce544601e8a292992f8e28c0cd6b7e5ec6dd5acd32a417f7b9b0db351

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page