Nova postagem

查找

Artigo
· Abr. 1 7min de leitura

Iris-AgenticAI: Enterprise Automation Powered by OpenAI’s Agentic SDK for Intelligent Multi-Agent Workflows

Hi Community,

In this article, I will introduce my application iris-AgenticAI .

The rise of agentic AI marks a transformative leap in how artificial intelligence interacts with the world—moving beyond static responses to dynamic, goal-driven problem-solving. Powered by OpenAI’s Agentic SDK , The OpenAI Agents SDK enables you to build agentic AI apps in a lightweight, easy-to-use package with very few abstractions. It's a production-ready upgrade of our previous experimentation for agents, Swarm.
This application showcases the next generation of autonomous AI systems capable of reasoning, collaborating, and executing complex tasks with human-like adaptability.

Application Features

  • Agent Loop 🔄 A built-in loop that autonomously manages tool execution, sends results back to the LLM, and iterates until task completion.
  • Python-First 🐍 Leverage native Python syntax (decorators, generators, etc.) to orchestrate and chain agents without external DSLs.
  • Handoffs 🤝 Seamlessly coordinate multi-agent workflows by delegating tasks between specialized agents.
  • Function Tools ⚒️ Decorate any Python function with @tool to instantly integrate it into the agent’s toolkit.
  • Vector Search (RAG) 🧠 Native integration of vector store (IRIS) for RAG retrieval.
  • Tracing 🔍 Built-in tracing to visualize, debug, and monitor agent workflows in real time (think LangSmith alternatives).
  • MCP Servers 🌐 Support for Model Context Protocol (MCP) via stdio and HTTP, enabling cross-process agent communication.
  • Chainlit UI 🖥️ Integrated Chainlit framework for building interactive chat interfaces with minimal code.
  • Stateful Memory 🧠 Preserve chat history, context, and agent state across sessions for continuity and long-running tasks.

Agent

Agents are the core building block in your apps. An agent is a large language model (LLM), configured with instructions and tools. Basic configuration The most common properties of an agent you'll configure are:

Instructions: also known as a developer message or system prompt.
model: which LLM to use, and optional model_settings to configure model tuning parameters like temperature, top_p, etc.
tools: Tools that the agent can use to achieve its tasks.

from agents import Agent, ModelSettings, function_tool

@function_tool
def get_weather(city: str) -> str:
    return f"The weather in {city} is sunny"
agent = Agent(
    name="Haiku agent",
    instructions="Always respond in haiku form",
    model="o3-mini",
    tools=[get_weather],
)

Running agents

You can run agents via the Runner class. You have 3 options:

  1. Runner.run(), which runs async and returns a RunResult.
  2. Runner.run_sync(), which is a sync method and just runs .run() under the hood.
  3. Runner.run_streamed(), which runs async and returns a RunResultStreaming. It calls the LLM in streaming mode, and streams those events to you as they are received.
from agents import Agent, Runner

async def main():
    agent = Agent(name="Assistant", instructions="You are a helpful assistant")

    result = await Runner.run(agent, "Write a haiku about recursion in programming.")
    print(result.final_output)
    # Code within the code,
    # Functions calling themselves,
    # Infinite loop's dance.


Agent Architecture

The application comprises 7 specialized agents:

  1. Triage Agent 🤖
    • Role: Primary router that receives user input and delegates tasks via handoffs
    • Example: Routes "Show production errors" → IRIS Production Agent  
  2. Vector Search Agent 🤖
    • Role: Provide IRIS 2025.1 Release notes details (RAG Functionality)
    • Example: Routes "Provide me summary of Release Notes" → Vector Search Agent  
  3. IRIS Dashboard Agent 🤖
    • Function: Provides real-time management portal metrics: plaintext Copy
      ApplicationErrors, CSPSessions, CacheEfficiency, DatabaseSpace, DiskReads,  
      DiskWrites, ECPAppServer, ECPDataServer, GloRefs, JournalStatus,  
      LicenseCurrent, LockTable, Processes, SystemUpTime, WriteDaemon, [...]
  4. IRIS Running Process Agent 🤖
    • Function: Monitors active processes with details:
      • Process ID | Namespace | Routine | State | PidExternal
  5. IRIS Production Agent 🤖
    • Role: Provide production details along with the functionality to start and stop the production.
  6. WebSearch Agent 🤖
    • Capability: Performs contextual web searches via API integrations
  7. Order Agent 🤖
    • Function: Retrieves order status using an order ID


Handoffs

Handoffs allow an agent to delegate tasks to another agent. This is particularly useful in scenarios where different agents specialize in distinct areas. For example, a customer support app might have agents that each specifically handle tasks like order status, refunds, FAQs, etc.

The triage agent is our main agent, which delegates tasks to another agent based on user input

    #TRIAGE AGENT, Main agent receives user input and delegates to other agent by using handoffs
    triage_agent = Agent(
        name="Triage agent",
        instructions=(
            "Handoff to appropriate agent based on user query."
            "if they ask about Release Notes, handoff to the vector_search_agent."
            "If they ask about production, handoff to the production agent."
            "If they ask about dashboard, handoff to the dashboard agent."
            "If they ask about process, handoff to the processes agent."
            "use the WebSearchAgent tool to find information related to the user's query and do not use this agent is query is about Release Notes."
            "If they ask about order, handoff to the order_agent."
        ),
        handoffs=[vector_search_agent,production_agent,dashboard_agent,processes_agent,order_agent,web_search_agent]
    )


Tracing

The Agents SDK includes built-in tracing, collecting a comprehensive record of events during an agent run: LLM generations, tool calls, handoffs, guardrails, and even custom events that occur. Using the Traces dashboard, you can debug, visualize, and monitor your workflows during development and in production.
https://platform.openai.com/logs

image

 


Application Interface

Application Workflow Process

Vector Search Agent

Vector Search Agent automatically ingests New in InterSystems IRIS 2025.1 text information into IRIS Vector Store only once if the data doesn't already exist.  


Use the query below to retrieve the data

SELECT
id, embedding, document, metadata
FROM SQLUser.AgenticAIRAG

The Triage Agent receives user input, routing the question to the Vector Search Agent.

IRIS Dashboard Agent

The Triage Agent receives user input, routing the question to the IRIS Dashboard Agent.


IRIS Processes Agent

 

The Triage Agent receives user input, routing the question to the IRIS Processes Agent.


IRIS Production Agent

Start and Stop the Production by using Production Agent.


Get Production Details by using Production Agent.

Local Agent

The Triage Agent receives user input, routing the question to the Local Order Agent.


WebSearch Agent

Here, the triage Agent receives two questions, routing both to the WebSearcg Agent.

MCP Server application

MCP Server is running at https://localhost:8000/sse

image

Below is the code to start the MCP server:

import os
import shutil
import subprocess
import time
from typing import Any
from dotenv import load_dotenv

load_dotenv()

#Get OPENAI Key, if not fond in .env then get the GEIMINI API KEY
#IF Both defined then take OPENAI Key 
openai_api_key = os.getenv("OPENAI_API_KEY")
if not openai_api_key:
   raise ValueError("OPENAI_API_KEY is not set. Please ensure to defined in .env file.")


if __name__ == "__main__":
    # Let's make sure the user has uv installed
    if not shutil.which("uv"):
        raise RuntimeError(
            "uv is not installed. Please install it: https://docs.astral.sh/uv/getting-started/installation/"
        )

    # We'll run the SSE server in a subprocess. Usually this would be a remote server, but for this
    # demo, we'll run it locally at http://localhost:8000/sse
    process: subprocess.Popen[Any] | None = None
    try:
        this_dir = os.path.dirname(os.path.abspath(__file__))
        server_file = os.path.join(this_dir, "MCPserver.py")

        print("Starting SSE server at http://localhost:8000/sse ...")

        # Run `uv run server.py` to start the SSE server
        process = subprocess.Popen(["uv", "run", server_file])
        # Give it 3 seconds to start
        time.sleep(3)

        print("SSE server started. Running example...\n\n")
    except Exception as e:
        print(f"Error starting SSE server: {e}")
        exit(1)

 

The MCP Server is equipped with the following tools:

  • Provide IRIS 2025.1 Release notes details (Vector Search)
  • IRIS Info tool
  • Check Weather tool
  • Find secret word tool (Local function)
  • Addition Tool (Local function)

MCP application is running at  http://localhost:8001


 

MCP Server Vector Search (RAG) functionality

The MCP Server is equipped with InterSystems IRIS vector search ingestion capabilities and Retrieval-Augmented Generation (RAG) functionality.


MCP Server other functionality

The MCP Server dynamically delegates tasks to the appropriate tool based on user input.


For more details, please visit iris-AgenticAI open exchange application page.

Thanks

Discussão (0)1
Entre ou crie uma conta para continuar
Resumo
· Abr. 1

Resumo do InterSystems Developer Community, Março 2025

Olá e bem-vindo ao boletim informativo da comunidade de desenvolvedores Março 2025.
Estatísticas gerais
21 novas postages publicadas em Março:
 9 novos artigos
 10 novos anúncios
 2 novas perguntas
5 novos membros ingressaram em Março
1,328 postagens publicadas ao todo
624 membros ingressaram ao todo
Principais publicações
Principais autores do mês
Artigos
#InterSystems IRIS
 
#IRIS contest
 
#InterSystems IRIS for Health
 
Anúncios
#InterSystems IRIS
 
#InterSystems Oficial
 
#Outro
 
#Developer Community Oficial
Aviso de manutenção planejada
Por Anastasia Dyubaylo
 
#Portal de Aprendizagem
 
Perguntas
#InterSystems IRIS
 
Março, 2025Month at a GlanceInterSystems Developer Community
Anúncio
· Abr. 1

Developer Community Recap, March 2025

Hello and welcome to the March 2025 Developer Community Recap.
General Stats
150 new posts published in March:
 30 new articles
 46 new announcements
 70 new questions
 4 new discussions
337 new members joined in March
14,726 posts published all time
15,711 members joined all time
Top posts
Top authors of the month
Articles
#InterSystems IRIS
Leveraging InterSystems IRIS for Health Data Analytics with Explainable AI and Vector Search
By Rahul Singhal
IRIS Vector Search for Matching Companies and Climate Action
By Alice Heiman
Multi-Layered Security Architecture for IRIS Deployments on AWS with InterSystems IAM
By Roy Leonov
SQLAchemy-iris with the latest version Python driver
By Dmitry Maslennikov
Parallel Query Processing - (System-wide and Query-based)
By Parani.K
IRIS Vector Search for Climate Matching: Introducing BAS
By Suze van Adrichem
Salesforce Integration with InterSystems IRIS
By Yuri Marx
How to set up an IRIS Sharding cluster in less than a minute
By Jose-Tomas Salvador
SQL Query Stopped Working After Changing %String Property to Wrapper Types
By Joe Fu
Embedded Python VS ObjectScript - Performance Testing Parsing XML
By Luis Angel Pérez Ramos
Having trouble connecting your Visual Studio Code to your IRIS instance via WebGateway? Here are some tips!
By Luis Angel Pérez Ramos
Ollama AI with IRIS
By Rodolfo Pscheidt
InterSystems IRIS data platform: Architecture
By Developer Community Admin
Workaround for scikit-learn 1.6.0 Incompatibility in IRIS 2024.3 AutoML
By Thomas Dyar
Create business processes with custom Python code: a quick guide
By Adam Coppola
2025.1 Modernizing Interoperability User Experience
By Aya Heshmat
How to write a message to the console log
By Hiroshi Sato
Reviews on Open Exchange - #50
By Robert Cemper
AI-Powered System Management with IRIS Agent
By Georgii Tatevosian
OMOP Odyssey - Vanna AI ( The Underworld )
By Ron Sweeney
Ask your IRIS server using an AI Chat
By Yuri Marx
Operate the database through dialogue
By lando miller
 
#InterSystems IRIS for Health
 
#IRIS contest
 
#Documentation
 
#Summit
 
Announcements
#InterSystems IRIS
Developing with InterSystems Objects and SQL – In Person (Boston, MA) March 24-28, 2025 / Registration space available
By Larry Finlayson
Deprecation of MultiValue in InterSystems IRIS 2025.1
By Daniel Palevski
Principal Architect and Integration Engineer
By varsha Vijay
[Video] Customizing the InterSystems FHIR Transformation Service
By Anastasia Dyubaylo
Using OpenEHR with InterSystems IRIS
By Jeff Fried
Early Access Program for new Table Partitioning feature
By Benjamin De Boe
[Video] A better way of buidling index for IRIS
By Anastasia Dyubaylo
InterSystems UK & Ireland Data Summit 2025
By Anastasia Dyubaylo
Reminder: Beta Testers Needed for Our Upcoming InterSystems IRIS Developer Professional Certification Exam
By Celeste Canzano
Open Call for User Insights Interviews
By Michelle Spisak
Managing InterSystems Servers – In-Person April 14-18, 2025 / Registration space available
By Larry Finlayson
Developer Meetup in Cambridge - GenAI & AI Agents [April 23 2025]
By Liubov Zelenskaia
General Availability of InterSystems IRIS, InterSystems IRIS for Health, and HealthShare Health Connect 2025.1
By Daniel Palevski
[Video] Quick wins with InterSystems IRIS Vector DB
By Anastasia Dyubaylo
[Video] Rapidly Create and Deploy Secure REST Services on InterSystems IRIS
By Anastasia Dyubaylo
 
#Developer Community Official
 
#Open Exchange
 
#IRIS contest
 
#Other
 
#Learning Portal
 
#InterSystems IRIS for Health
 
#Job Wanted
 
#InterSystems Ideas Portal
InterSystems Ideas News #20
By Irène Mykhailova
 
#Summit
 
Questions
#InterSystems IRIS
download files
By john.smith4237
PROTECT Error on POST request to FHIR server
By Riccardo Villa
Using Lists and ListFind within BPL
By Scott Roth
Debugging embedded python library
By Eduard Lebedyuk
Enable/Disable a scheduler task
By Krishnaveni Kapu
Running app outside container Linux
By john.smith4237
Dynamic SQL Queries with a ROUTINE (CODE) database mounted in read-only mode: ERROR #5002: ObjectScript error: ShowPlan+6^%apiSQL *sqlOrig
By Sylvain Guilbaud
EnsLib.JavaGateway.Service to remote JavaGateway
By Igor Pak
Request for Ensemble HL7 Project Guide with Certification
By Harshitha Balakrishna
git-source-control questions
By Fiona Griffiths
Docker IRIS_Community Mount
By Matthias Thon
Convert HTML to PDF
By john.smith4237
SQL Inbound Service write to internal Cache Table
By Scott Roth
SQL Query not transforming into class structure correctly
By Scott Roth
How do I get the name of the OS user used by the IRIS superserver?
By Evan Gabhart
2 [Utility.Event] ISCLOG: WebSocket [SendAsyncMessage]
By Lucas Galdino
Question about varstrings
By Alan Decourtray
How to use class property ot type %Persistent in non persistent class (page)
By PagerianDevelper
SLF4J error
By john.smith4237
Prometheus + Iris 2022.1
By Guilherme Silva
Starting & stopping Java Server programmatically
By john.smith4237
comparison library with renderers in IRIS, similar to Python's difflib ("Helpers for computing deltas")
By Mauricio Sthandier
Java Server timing out
By john.smith4237
"garbled text" due to incorrect character encoding or decoding.
By Fahima Ansari
Transforms in COS over DTL
By Paul Hula
VSCode - trying to use tag to call SELECT statement
By Scott Roth
AWS Files
By Touggourt
Distinct strings in MDX
By Dmitrij Vladimirov
How to tokenize a text using SentenceTransformer?
By Kurro Lopez
"Bad value for type long" on select from PostgreSQL via EnsLib.SQL.OutboundAdapter
By Andrew Sklyarov
irisowner getting in the way of irisusr when using $ZF(-100)
By Mauricio Aguirre
count(*) from a sql dynamic query
By Krishnaveni Kapu
%NOCHECK for Objects
By Matthew Giesmann
How to convert UTF8 special characters to the actual character
By Padmaja Konduru
Task scheduler
By Nezla
Object mapping between Pydantic and %RegisteredObject
By Timothy Leavitt
 
#Global Masters
 
#Caché
 
#InterSystems IRIS for Health
IO-Redirect package on Linux
By Phillip Wu
How to send the HL7 Batch messages over a SOAP webservice which takes 3 credentials(Username, Password, Org.ID) using IRIS Management Portal
By Lokesh Parakh
: Unable to import required dependencies: numpy: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy so
By Shashvati Dash
NodeJS Iris Package - Work on node Windows?
By John McBride
SDA3 to HL7 transform
By Sheetal Kairawala
%Net.SSH.Session - how to sudo
By Dmitrii Baranov
How do you use .NET SDK for setting an object to a list (IRISLIST?
By John McBride
ERROR #5911: Character Set 'iso-8859-4' not installed, unable to perform character set translation (EnsLib.HL7.Operation.HTTPOperation)
By Will
trying to convert SDA to FHIR get an error
By Bing Chen
Recover PROD to STAGING using .cbk
By Dmitrii Baranov
Calling iris merge from Ansible
By Tom Elmer
Expanding 1 HL7 segment into multiple based on interger value from a lookup table mapping
By Darin Kurth
HL7 OBX 5 modification resolved
By Gary M Lusso
Want to get text from the next line
By Fahima Ansari
Anyone experience hurdles when using the Production Validator toolkit?
By Andre Ribera
File with JSON records
By Michael Wood
HL7 CR/LF to create a blank space between segment -- resolved
By Gary M Lusso
get ClassMethod
By Krishnaveni Kapu
Working with multiple git repositories
By Dmitrii Baranov
 
#Ensemble
 
#HealthShare
 
#Health Connect
 
#Other
MSM FOR WINDOWS
By JASON PARKER
 
Discussions
#InterSystems IRIS
 
#Global Masters
 
#Learning Portal
 
March, 2025Month at a GlanceInterSystems Developer Community
Discussão (0)1
Entre ou crie uma conta para continuar
Resumo
· Abr. 1

InterSystems Developer Community Digest, March 2025

Hello and welcome to the March 2025 Developer Community Newsletter.
General Stats
150 new posts published in March:
 30 new articles
 46 new announcements
 70 new questions
 4 new discussions
337 new members joined in March
14,726 posts published all time
15,711 members joined all time
Top posts
Top authors of the month
Articles
#InterSystems IRIS
Leveraging InterSystems IRIS for Health Data Analytics with Explainable AI and Vector Search
By Rahul Singhal
IRIS Vector Search for Matching Companies and Climate Action
By Alice Heiman
Multi-Layered Security Architecture for IRIS Deployments on AWS with InterSystems IAM
By Roy Leonov
SQLAchemy-iris with the latest version Python driver
By Dmitry Maslennikov
Parallel Query Processing - (System-wide and Query-based)
By Parani.K
IRIS Vector Search for Climate Matching: Introducing BAS
By Suze van Adrichem
Salesforce Integration with InterSystems IRIS
By Yuri Marx
How to set up an IRIS Sharding cluster in less than a minute
By Jose-Tomas Salvador
SQL Query Stopped Working After Changing %String Property to Wrapper Types
By Joe Fu
Embedded Python VS ObjectScript - Performance Testing Parsing XML
By Luis Angel Pérez Ramos
Having trouble connecting your Visual Studio Code to your IRIS instance via WebGateway? Here are some tips!
By Luis Angel Pérez Ramos
Ollama AI with IRIS
By Rodolfo Pscheidt
InterSystems IRIS data platform: Architecture
By Developer Community Admin
Workaround for scikit-learn 1.6.0 Incompatibility in IRIS 2024.3 AutoML
By Thomas Dyar
Create business processes with custom Python code: a quick guide
By Adam Coppola
2025.1 Modernizing Interoperability User Experience
By Aya Heshmat
How to write a message to the console log
By Hiroshi Sato
Reviews on Open Exchange - #50
By Robert Cemper
AI-Powered System Management with IRIS Agent
By Georgii Tatevosian
OMOP Odyssey - Vanna AI ( The Underworld )
By Ron Sweeney
Ask your IRIS server using an AI Chat
By Yuri Marx
Operate the database through dialogue
By lando miller
#InterSystems IRIS for Health
#IRIS contest
#Documentation
#Summit
Announcements
#InterSystems IRIS
Developing with InterSystems Objects and SQL – In Person (Boston, MA) March 24-28, 2025 / Registration space available
By Larry Finlayson
Deprecation of MultiValue in InterSystems IRIS 2025.1
By Daniel Palevski
Principal Architect and Integration Engineer
By varsha Vijay
[Video] Customizing the InterSystems FHIR Transformation Service
By Anastasia Dyubaylo
Using OpenEHR with InterSystems IRIS
By Jeff Fried
Early Access Program for new Table Partitioning feature
By Benjamin De Boe
[Video] A better way of buidling index for IRIS
By Anastasia Dyubaylo
InterSystems UK & Ireland Data Summit 2025
By Anastasia Dyubaylo
Reminder: Beta Testers Needed for Our Upcoming InterSystems IRIS Developer Professional Certification Exam
By Celeste Canzano
Open Call for User Insights Interviews
By Michelle Spisak
Managing InterSystems Servers – In-Person April 14-18, 2025 / Registration space available
By Larry Finlayson
Developer Meetup in Cambridge - GenAI & AI Agents [April 23 2025]
By Liubov Zelenskaia
General Availability of InterSystems IRIS, InterSystems IRIS for Health, and HealthShare Health Connect 2025.1
By Daniel Palevski
[Video] Quick wins with InterSystems IRIS Vector DB
By Anastasia Dyubaylo
[Video] Rapidly Create and Deploy Secure REST Services on InterSystems IRIS
By Anastasia Dyubaylo
#Developer Community Official
#Open Exchange
#IRIS contest
#Other
#Learning Portal
#InterSystems IRIS for Health
#Job Wanted
#InterSystems Ideas Portal
InterSystems Ideas News #20
By Irène Mykhailova
#Summit
Questions
#InterSystems IRIS
download files
By john.smith4237
PROTECT Error on POST request to FHIR server
By Riccardo Villa
Using Lists and ListFind within BPL
By Scott Roth
Debugging embedded python library
By Eduard Lebedyuk
Enable/Disable a scheduler task
By Krishnaveni Kapu
Running app outside container Linux
By john.smith4237
Dynamic SQL Queries with a ROUTINE (CODE) database mounted in read-only mode: ERROR #5002: ObjectScript error: ShowPlan+6^%apiSQL *sqlOrig
By Sylvain Guilbaud
EnsLib.JavaGateway.Service to remote JavaGateway
By Igor Pak
Request for Ensemble HL7 Project Guide with Certification
By Harshitha Balakrishna
git-source-control questions
By Fiona Griffiths
Docker IRIS_Community Mount
By Matthias Thon
Convert HTML to PDF
By john.smith4237
SQL Inbound Service write to internal Cache Table
By Scott Roth
SQL Query not transforming into class structure correctly
By Scott Roth
How do I get the name of the OS user used by the IRIS superserver?
By Evan Gabhart
2 [Utility.Event] ISCLOG: WebSocket [SendAsyncMessage]
By Lucas Galdino
Question about varstrings
By Alan Decourtray
How to use class property ot type %Persistent in non persistent class (page)
By PagerianDevelper
SLF4J error
By john.smith4237
Prometheus + Iris 2022.1
By Guilherme Silva
Starting & stopping Java Server programmatically
By john.smith4237
comparison library with renderers in IRIS, similar to Python's difflib ("Helpers for computing deltas")
By Mauricio Sthandier
Java Server timing out
By john.smith4237
"garbled text" due to incorrect character encoding or decoding.
By Fahima Ansari
Transforms in COS over DTL
By Paul Hula
VSCode - trying to use tag to call SELECT statement
By Scott Roth
AWS Files
By Touggourt
Distinct strings in MDX
By Dmitrij Vladimirov
How to tokenize a text using SentenceTransformer?
By Kurro Lopez
"Bad value for type long" on select from PostgreSQL via EnsLib.SQL.OutboundAdapter
By Andrew Sklyarov
irisowner getting in the way of irisusr when using $ZF(-100)
By Mauricio Aguirre
count(*) from a sql dynamic query
By Krishnaveni Kapu
%NOCHECK for Objects
By Matthew Giesmann
How to convert UTF8 special characters to the actual character
By Padmaja Konduru
Task scheduler
By Nezla
Object mapping between Pydantic and %RegisteredObject
By Timothy Leavitt
#Global Masters
#Caché
#InterSystems IRIS for Health
IO-Redirect package on Linux
By Phillip Wu
How to send the HL7 Batch messages over a SOAP webservice which takes 3 credentials(Username, Password, Org.ID) using IRIS Management Portal
By Lokesh Parakh
: Unable to import required dependencies: numpy: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy so
By Shashvati Dash
NodeJS Iris Package - Work on node Windows?
By John McBride
SDA3 to HL7 transform
By Sheetal Kairawala
%Net.SSH.Session - how to sudo
By Dmitrii Baranov
How do you use .NET SDK for setting an object to a list (IRISLIST?
By John McBride
ERROR #5911: Character Set 'iso-8859-4' not installed, unable to perform character set translation (EnsLib.HL7.Operation.HTTPOperation)
By Will
trying to convert SDA to FHIR get an error
By Bing Chen
Recover PROD to STAGING using .cbk
By Dmitrii Baranov
Calling iris merge from Ansible
By Tom Elmer
Expanding 1 HL7 segment into multiple based on interger value from a lookup table mapping
By Darin Kurth
HL7 OBX 5 modification resolved
By Gary M Lusso
Want to get text from the next line
By Fahima Ansari
Anyone experience hurdles when using the Production Validator toolkit?
By Andre Ribera
File with JSON records
By Michael Wood
HL7 CR/LF to create a blank space between segment -- resolved
By Gary M Lusso
get ClassMethod
By Krishnaveni Kapu
Working with multiple git repositories
By Dmitrii Baranov
#Ensemble
#HealthShare
#Health Connect
#Other
MSM FOR WINDOWS
By JASON PARKER
Discussions
March, 2025Month at a GlanceInterSystems Developer Community
Artigo
· Abr. 1 4min de leitura

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'])
Discussão (0)1
Entre ou crie uma conta para continuar