新しい投稿

検索

記事
· 2025年4月1日 4m read

Ask your IRIS classes with Ollama, IRIS VectorDB and Langchain

If you want to know if a class about a topic already exists asking a simple natural language question, it is possible now. Download and run the application https://openexchange.intersystems.com/package/langchain-iris-tool to know all about your project classes in a Chat.

Installation:

$ git clone https://github.com/yurimarx/langchain-iris-tool.git
$ docker-compose build
$ docker-compose up -d

Using:

1. Open the URL http://localhost:8501

2. Check out the Settings button used to the Agent connect the InterSystems IRIS

3. Ask about your developed classes (e.g.: Are there classes that inherit from Persistent?)

UI 4

Solutions used:

  1. Ollama - private LLM and NLP Chat tool
  2. Lanchain - plataform to build AI agents
  3. Streamlit - Frontend framework
  4. InterSystems IRIS as a server to answer the questions about it

About Ollama

It is a free and on-premises LLM solution to be able running Generative AI with privacy and security because your data will be processed on-premises only. The project Ollama supports many models including mistral, Open AI models, Deepseek models and others running on-premises. This package used Ollama via docker compose with the model 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

About Langchain:

Langchain it is a framework to build GenAI applications easily. The Langchain has the concept of tool. Tools are plug-ins (RAG applications) used by Langchain to complement the work of the LLMs. This application implemented a langchain tool to ask management and development questions for your IRIS server:

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})

About Streamlit:

The streamlit solution it is used to develop frontends using python language. This application has a streamlit chat application to interact with the Ollama, Langchain and IRIS and get relevant responses:

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'])
ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
お知らせ
· 2025年4月1日

Récapitulation de la communauté des développeurs, mars 2025

Bonjour et bienvenue à la récapitulation de la Communauté des Développeurs mars 2025.
Statistiques générales
✓ Nouvelles publications 20 publiées le mars :
 9 nouveaux articles
 9 nouvelles annonces
 2 nouvelles questions
✓ Nouveaux membres 4 ayant rejoint le mars
✓ Publications 1,133 publiées depuis le début
✓ Membres 166 ayant rejoint depuis le début
Meilleures publications
Les meilleurs auteurs du mois
Articles
#InterSystems IRIS
 
#InterSystems IRIS for Health
 
Annonces
#InterSystems IRIS
 
#Communauté des développeurs officielle
 
Questions
Mars, 2025Month at a GlanceInterSystems Developer Community
ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
質問
· 2025年4月1日

GENERATE JWT / OAUTH2.0 SIGNATURE

 JSON Web Token (JWT) Authentication

Hi Everyone,

I would like to share the code and step-by-step instructions/or guideline for generating a JWT (JSON Web Token) signature, as well as how to test it using Postman / HealthConnect.

JWT is an open standard (RFC 7519) that defines a compact, URL-safe method for securely transmitting information between parties in the form of a JSON object.

Structure of a JWT:

A JWT consists of three parts, separated by dots (.):

Header

.

Payload

.

Signature

 

  1. Header: The header contains about the token, specifying its type and the signing algorithm used. It typically includes the following fields:
  • alg (Algorithm): Defines the signing algorithm (e.g., HMAC SHA256, RSA, etc.).
  • typ (Type): Specifies the token type, which is always JWT.
  • kid (Key ID): Identifies the key used for signature verification.

Example:

{

  "alg": "HS256",  

  "typ": "JWT",

   “kid”: “my-key”

}

 

  1. Payload: The payload contains the claims. It typically includes the following fields:
  • iss  -(Issuer) – Issuer of the token.
  • Sub - (Subject) – Subject of the JWT (user identifier).
  • Aud - (Audience) – Intended recipient of the token (JWT).
  • Exp - (Expiration time) – Token expiry timestamp.
  • jti – (Unique) - Token identifier.
  • iat  - (Issued At) – When the token was created.
  • etc

Example:

{

  "iss": "your issuer",

   "sub": "your subject",

   "aud": “your audience”,

   “jti”: “your jti”,

  “exp”: “your expiry time”

}

  1. Signature: it is created by encoding the header and payload, then signing them using a private or secret key. It ensures the integrity and authenticity of the token.

Signature= header + payload and a private or secret key

Example:

{

 HMACSHA256( base64UrlEncode(header) +

"."

+  base64UrlEncode(payload),

secret key)

}

Example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJVadQssw5c

PROCESS

Step 1: Generate Public and Private Keys

To generate a public-private key pair, you can use either OpenSSL or an online JSON Web Key (JWK) generator like mkjwk.

Using mkjwk (JSON Web Key Generator): mkjwk - JSON Web Key Generator

  • Open the mkjwk tool.
  • Set the following parameters:
    • Key Size: Based on your requirements (e.g., 4096 bits).
    • Key Use: Signature.
    • Algorithm: Select the desired algorithm (e.g., RS512).
    • Key ID (kid): Choose a name for the key identifier (this key value is required for code, see screenshot -1, below.).
    • Show X.509 Certificate: Enable this option to generate an X.509 certificate if needed (e.g. “Yes”)
  • This will generate both a public key and a private key for signing and verification.

 

Step 2: Generate and Sign a JWT Using Cache Object Script

The code implementation for this process is provided in Screenshot 1 below.

Screenshot 1: Cache Object Script Code

 

Step 3: Execute the Method – see screenshot 2 below.

Screenshot 2 – Method Execution.

 

Step 4: After executing the method in Step 3, copy the Base64-encoded output from the result displayed in Screenshot 2.

Step 5: Test in Postman - Follow these steps to send a request using Postman:

  1. Open Postman (if you don’t have it, just download and install it)
  2. Select the “POST” method and enter the appropriate “URL”.
  3. Navigate to the “Body” section, then add the required key-value pairs (needed to set up the key and value)
  4. In the "client_assertion" field, paste the Base64-encoded data from Step 4.
  5. Then “Send” to submit the request.

You should receive a response containing the access_token, expiration time, and other details based on - setup.

Screenshot 3: Postman Output

 

I hope this guide helps you. Once you have successfully generated and tested the JWT, you can proceed with configuring it in the HealthConnect Management Portal based on your requirements.

Thank you.

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
記事
· 2025年4月1日 19m read

Virtualização de grandes bancos de dados - Planejamento de capacidade de CPU VMware

Frequentemente, clientes, fornecedores ou equipes internas me pedem para explicar o planejamento de capacidade de CPU para para grandes bancos de dados de produção rodando no VMware vSphere.

Em resumo, existem algumas práticas recomendadas simples a seguir para dimensionar a CPU para grandes bancos de dados de produção:

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
お知らせ
· 2025年4月1日

¡El jueves tenemos webinar! "Conectando sensores con InterSystems IRIS"

Hola a todos... ¡Aún con la resaca del Meetup? 

Os esperamos en el webinar gratuito que tenemos el jueves a las 16.00 CEST. Jairo nos hará una demostración práctica de algo que conecta InterSystems con deporte y con datos en tiempo real... ¡Preparaos para flipar!

 

Webinar dirigido a Desarrolladores, analistas de integración y todos aquellos interesados en las posibilidades de la tecnología InterSystems :)

¡Os esperamos!

🗣 Ponente: , Jairo Ruiz Sales Engineer en InterSystems Colombia

➡️ Registro >>

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください