Se você quiser saber se já existe uma classe sobre um determinado tópico fazendo uma simples pergunta em linguagem natural, isso agora é possível. Baixe e execute a aplicação https://openexchange.intersystems.com/package/langchain-iris-tool para conhecer tudo sobre as classes do seu projeto em um chat.
Instalação:
$ git clone https://github.com/yurimarx/langchain-iris-tool.git
$ docker-compose build
$ docker-compose up -d
Como usar:
1. Abra a URL http://localhost:8501
2. Verifique o botão de Configurações usado pelo agente para se conectar ao InterSystems IRIS.
3. Pergunte sobre as classes que você desenvolveu (por exemplo: Existem classes que herdam de Persistent?)

Soluções utilizadas:
- Ollama – LLM privado e ferramenta de chat com NLP
- LangChain – plataforma para construir agentes de IA
- Streamlit – framework de frontend
- InterSystems IRIS – servidor para responder às perguntas
Sobre Ollama
É uma solução de LLM gratuita e on-premises que permite executar IA Generativa com privacidade e segurança, pois seus dados são processados apenas localmente. O projeto Ollama oferece suporte a diversos modelos, incluindo Mistral, modelos da OpenAI, modelos DeepSeek, entre outros, todos rodando on-premises. Este pacote utiliza o Ollama via Docker Compose com o modelo Mistral:
ollama:
image: ollama/ollama:latest
deploy:
resources:
reservations:
devices:
- driver: nvidia
capabilities: ["gpu"]
count: all # Adjust count for the number of GPUs you want to use
ports:
- 11434:11434
volumes:
- ./model_files:/model_files
- .:/code
- ./ollama:/root/.ollama
container_name: ollama_iris
pull_policy: always
tty: true
entrypoint: ["/bin/sh", "/model_files/run_ollama.sh"] # Loading the finetuned Mistral with the GGUF file
restart: always
environment:
- OLLAMA_KEEP_ALIVE=24h
- OLLAMA_HOST=0.0.0.0
Sobre Langchain:
LangChain é um framework para construir aplicações de IA Generativa de forma simples. O LangChain possui o conceito de tool (ferramenta). As ferramentas são plug-ins (aplicações de RAG) usadas pelo LangChain para complementar o trabalho dos LLMs. Esta aplicação implementa uma ferramenta do LangChain para fazer perguntas de gerenciamento e desenvolvimento para o seu servidor IRIS:
from langchain.llms import Ollama
from langchain.chains import RetrievalQA
from langchain.document_loaders import CSVLoader
from langchain.embeddings import OllamaEmbeddings
from langchain_iris import IRISVector
def get_insights(question, csv_file, iris_conn, collection_name):
# Load and process the CSV data
loader = CSVLoader(csv_file)
documents = loader.load()
llm = Ollama(
base_url="http://ollama:11434",
model="mistral",
temperature=0,
)
# Create embeddings
embeddings = OllamaEmbeddings(model="mistral", base_url="http://ollama:11434", temperature=0)
db = IRISVector.from_documents(
embedding=embeddings,
documents=documents,
connection_string=iris_conn,
collection_name=collection_name,
pre_delete_collection=True
)
qa = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=db.as_retriever())
return qa({"query": question})
Sobre Streamlit:
O Streamlit é usada para desenvolver frontends utilizando a linguagem Python. Esta aplicação possui um chat em Streamlit para interagir com o Ollama, o LangChain e o IRIS, obtendo respostas relevantes:
import pandas as pd
import streamlit as st
from sqlalchemy import create_engine
import langchain_helper as lch
username = "_system"
password = "SYS"
hostname = "iris"
port = 51972
webport = 52773
namespace = "USER"
st.set_page_config(page_title="InterSystems IRIS Classes Demo", page_icon="📜")
st.title("Langchain IRIS Classes Chat")
with st.popover("Settings"):
with st.spinner(text="Connecting to the IRIS classes"):
engine = create_engine("iris://" + username + ":" + password + "@" + hostname + ":" + str(port) + "/" + namespace)
connection = engine.connect()
query = 'select * from %Dictionary.ClassDefinition where substring(ID,1,1) <> \'%\' and Copyright is null'
df = pd.read_sql(query, con=connection)
df.to_csv("classes.csv")
username = st.text_input("Username:", username)
password = st.text_input("Password:", password)
hostname = st.text_input("Hostname:", hostname)
port = int(st.text_input("Port:", port))
webport = int(st.text_input("Web port:", webport))
namespace = st.text_input("Namespace:", namespace)
# User query input
query = st.text_input(label="Enter your query")
# Submit button
if st.button(label="Ask IRIS Classes", type="primary"):
with st.spinner(text="Generating response"):
iris_conn_str = f"iris://{username}:{password}@{hostname}:{port}/{namespace}"
response = lch.get_insights(query, "classes.csv", iris_conn=iris_conn_str, collection_name="classes")
st.write(response['result'])
(1).jpg)
