Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed Apr 16, 2024
1 parent 9846b21 commit d766737
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
# Langchain with InterSystems IRIS

[Langchain](https://github.com/langchain-ai/langchain) with support for InterSystems IRIS
[Langchain](https://github.com/langchain-ai/langchain) with support for InterSystems IRIS


## Install

```shell
pip install langchain-iris
```

## Example

```python
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)
```
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
include=["langchain_iris", "langchain_iris.*"]
),
install_requires=[
"langchain==0.0.348",
"langchain>=0.0.348",
"sqlalchemy-iris>=0.13.0",
],
python_requires=">3.7,<3.12",
python_requires=">3.7",
)

0 comments on commit d766737

Please sign in to comment.