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.2.2.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_iris-0.2.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain_iris-0.2.2.tar.gz.

File metadata

  • Download URL: langchain_iris-0.2.2.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_iris-0.2.2.tar.gz
Algorithm Hash digest
SHA256 687223c810e38dc8846bff9ad39d802343a0d10c70c8bf9ee0ecf849bdd9a737
MD5 4a8f57cb965ca9b0afba2f9ed631618e
BLAKE2b-256 19b79f293ef16a22268411969714c2b5ca1d0634c5dc08f41355791663554e19

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_iris-0.2.2.tar.gz:

Publisher: main.yml on caretdev/langchain-iris

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_iris-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: langchain_iris-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_iris-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 25f2d58d2af66072d1bc5eff16dcc6b8ae813f5791d5dc0f6e6efacd26240f67
MD5 b8ca5679374ef95e7126fde08a5aa805
BLAKE2b-256 da8d55b01e82af298c159dfdb5cb39237e845c9d0a86763b758064674e77ffe6

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_iris-0.2.2-py3-none-any.whl:

Publisher: main.yml on caretdev/langchain-iris

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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