New post

Find

Question
· Apr 21

My AI use case - need help with Ollama and / or Langchain

I am brand new to using AI. I downloaded some medical visit progress notes from my Patient Portal. I extracted text from PDF files. I found a YouTube video that showed how to extract metadata using an OpenAI query / prompt such as this one:

ollama-ai-iris/data/prompts/medical_progress_notes_prompt.txt at main · oliverwilms/ollama-ai-iris
 

I combined @Rodolfo Pscheidt https://github.com/RodolfoPscheidtJr/ollama-ai-iris with some files from @Guillaume Rongier https://openexchange.intersystems.com/package/iris-rag-demo.

I attempted to run

python3 query_data.py
Traceback (most recent call last):
  File "/irisdev/app/query_data.py", line 39, in <module>
    response = query_engine.query(prompt_data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py", line 322, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/base/base_query_engine.py", line 52, in query
    query_result = self._query(str_or_query_bundle)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py", line 322, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/query_engine/retriever_query_engine.py", line 179, in _query
    response = self._response_synthesizer.synthesize(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py", line 322, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/response_synthesizers/base.py", line 241, in synthesize
    response_str = self.get_response(
                   ^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py", line 322, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/response_synthesizers/compact_and_refine.py", line 43, in get_response
    return super().get_response(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py", line 322, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/response_synthesizers/refine.py", line 179, in get_response
    response = self._give_response_single(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/response_synthesizers/refine.py", line 241, in _give_response_single
    program(
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py", line 322, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/response_synthesizers/refine.py", line 85, in __call__
    answer = self._llm.predict(
             ^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py", line 322, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/llms/llm.py", line 605, in predict
    chat_response = self.chat(messages)
                    ^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py", line 322, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/core/llms/callbacks.py", line 173, in wrapped_llm_chat
    f_return_val = f(_self, messages, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/llama_index/llms/ollama/base.py", line 322, in chat
    response = self.client.chat(
               ^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/ollama/_client.py", line 333, in chat
    return self._request(
           ^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/ollama/_client.py", line 178, in _request
    return cls(**self._request_raw(*args, **kwargs).json())
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/irisowner/.local/lib/python3.12/site-packages/ollama/_client.py", line 124, in _request_raw
    raise ConnectionError(CONNECTION_ERROR_MESSAGE) from None
ConnectionError: Failed to connect to Ollama. Please check that Ollama is downloaded, running and accessible. https://ollama.com/download


 

Discussion (0)1
Log in or sign up to continue
Announcement
· Apr 21

HealthShare Unified Care Record Overview - Virtual May 15-16, 2025 - Registration space available

  • HealthShare Unified Care Record Overview – Virtual May 15-16, 2025
    • The HealthShare Unified Care Record Overview course is a great way for anyone to become familiar with Unified Care Record, but especially those who need to understand its capabilities but not how to configure HealthShare Unified Care Record.
    • This is a non-technical, instructor-led in person training course providing a comprehensive introduction to HealthShare Unified Care Record.
    • This course is for anyone who needs to know about the functionality and architecture of HealthShare Unified Care Record.  (If you need information on configuring and troubleshooting Unified Care Record, consider the HealthShare Unified Care Record Fundamentals class.)
    • No prior knowledge or experience is required for the Overview class and any InterSystems employee may enroll.
  • Self-Register Here
Discussion (0)1
Log in or sign up to continue
Digest
· Apr 21

Publicações Desenvolvedores InterSystems, Abril 14 - 20, 2025, Resumo

Artigos
#InterSystems IRIS
#InterSystems IRIS for Health
Anúncios
#InterSystems IRIS
#InterSystems IRIS for Health
#Portal de Aprendizagem
Discussões
#InterSystems IRIS
Abril 14 - 20, 2025Week at a GlanceInterSystems Developer Community
Digest
· Apr 21

InterSystems Developers Publications, Week April 14 - 20, 2025, Digest

Articles
Announcements
Questions
#InterSystems IRIS
#InterSystems IRIS for Health
#HealthShare
#Caché
Discussions
#InterSystems IRIS
April 14 - 20, 2025Week at a GlanceInterSystems Developer Community
Article
· Apr 21 3m read

Considerations when Migrating from Oracle, MSSQL etc to IRIS

Migrating from Oracle, MSSQL, or other purely relational database systems to a multimodel InterSystems IRIS is a strategic decision that requires careful planning and execution. While this transition offers significant benefits, including enhanced performance, scalability, and support for modern architectures, it also comes with challenges. In this article I will highlight some of the considerations connected to coding to ensure a successful migration. I will leave everything connected to an actual migration of structures and data outside the scope of this article.


First, when you're considering migrating to a different database system, you need to understand your business logic, whether it's on the side of the application (application server) or the database server. Basically, where do you have your SQL statements that you will need to potentially rewrite

When your application logic heavily relies on SQL executed directly within the application code (rather than within stored procedures or triggers in the database), migrating from relational DB to InterSystems IRIS requires a careful examination of your SQL statements. Let's look at some of the most important factors you need to think about.

  1. SQL dialect differences. IRIS SQL supports SQL-92 standard. It doesn't mean that some more modern features are not implemented. It just means that you need to check beforehand. For example, the window functions appeared in SQL:2003, but you still can write them in IRIS:
--window function
select id, rating
  from (select a.id, 
               r.rating, 
               avg(r.rating) over () as avg_rating 
          from SQLUSER.Actor a join SQLUser.Review r on a.id = r.Reviews) as sub 
 where rating > avg_rating

At the same time, new complex datatypes, like XML, JSON, Arrays, and Geographic datatypes, are not supported. So the following query

SELECT a.id, 
       a.firstname, 
       ARRAY_AGG(r.rating) AS ratings 
  FROM SQLUSER.Actor a LEFT JOIN SQLUser.Review r ON a.id = r.Reviews 
GROUP BY  a.firstname

will return an error: ERROR #5540: SQLCODE: -359 Message: User defined SQL function 'SQLUSER.ARRAY_AGG' does not exist

But it's not the end of the world. There are a lot of built-in functions that will allow you to rewrite the queries so that you get the expected result.

2. Built-in functions. Different DBMSs have different built-in functions. Thus, you need to understand how they correspond to the ones available in IRIS. Here are several examples of what I'm talking about, functions used in Oracle and their equivalents in IRIS:

Oracle IRIS
NVL ISNULL(field, default_value)
substr $extract(field, start_pos, end_pos)
instr $find(field, text_to_find)
concat {fn CONCAT(string1,string2)}

When your primary SQL logic resides within a database (e.g., stored procedures, triggers, views), migrating to InterSystems IRIS requires a different approach. Here are some of the considerations:

  1. Database Object Migration
    1. All the Stored Procedures have to be rewritten using ObjectScript. This may also be a good time to change to the object model as you will get a table anyway when you create a class. However, working with classes will allow you to write methods (that can be called as stored procedures) and use the full power of the object-oriented paradigm. 
    2. Triggers, Indexes, and Views are all supported by IRIS. You can even leave your Views as they are if the table columns remain the same if they don't use any of the unsupported functions/syntax (see the previous point). 
  2. Migration of Definitions is also significant and may pose some challenges. First, you must carefully match the data types from your previous DB to IRIS, especially if you're using new complex types. Also, having more flexibility with indexes, you may want to redefine them differently.

Here are some things you need to consider when deciding to migrate to InterSystems IRIS from a different relational database. It is a strategic decision that can unlock significant benefits, including improved scalability, performance, and efficiency. However, careful planning is crucial to ensure a seamless transition and to address compatibility, data transformation, and application refactoring needs.

Discussion (0)2
Log in or sign up to continue