Introduction
This article describes the building of a Python library to interact with the REST API of IBM Content Manager OnDemand (CMOD). The library in GitHub is shared as-is on request. The article also illustrates how the Python library can help in better integrating CMOD in Generative AI and Agentic AI use cases.
IBM Content Manager OnDemand (CMOD) provides a centralized repository for storing and retrieving electronic documents. It is optimized for capturing reports, statements, and other business-critical content that is internally generated and shared both internally and with clients. Key entities from the document, like client number, date etc. can be automatically extracted during the load process.
For accessing the stored digital documents, users can leverage an out-of-the-box web application, IBM Content Navigator, that allows searching, retrieving, viewing or annotating documents. Access to documents stored in CMOD is also frequently implemented as part of a business application or client portal. For this purpose, CMOD has included a comprehensive Java API (aka ODWEK) for many years.
In recent years, a REST API has been made available as an additional programming interface option for CMOD, to provide a better integration into modern custom applications. It has a similar functional scope to the Java API and is documented in the IBM Documentation. The REST API for CMOD provides more flexibility with regards to the programming language. While REST calls can be used in Java, they can also be made from JavaScript, Python or other languages.
In recent years, Python has seen a widespread adoption as a programming language, also driven through its popularity among Data Scientists and AI Engineers. Python is a high-level, interpreted programming language with a rather simple syntax and a versatile nature. With its large developer community and extensive libraries, Python provides a fast development environment, allowing developers to quickly build and deploy applications which is ideal for prototyping.
Python Library for IBM Content Manager OnDemand (CMOD)
This article describes a Python library (which is shared as-is) that allows working with a CMOD system in a very simple way, with just a few lines of programming code. The goal of the library is to make documents stored in CMOD more consumable for Python developers. The library was developed in Visual Studio Code with a Jupyter notebook extension to allow interactive programming.
There are two main files:
- cmod.py
- cmod-samples.ipynb
The cmod.py file is the main (library) file. It includes the definition of an object class for a CMOD repository and related methods. Each method corresponds to a REST call as defined in the IBM documentation. Let us have a look at the folder list API that returns an array of folders defined in CMOD. Each folder contains the name and description of the folder. The details of the http request are described in the documentation as follows:

The CMODFolderList method in cmod.py implements this http request as depicted below. In just a few lines, the method sets the header and URL and makes the http request. A JSON with the list of folders is the return value.

Now let us look how easy it becomes using this CMOD method in a Python application. The cmod-samples.ipynb Jupyter notebook provides examples that illustrate how to use the defined (function) methods.
- At the beginning, both the CMOD server information and credentials are set (the screenshot shows dummy values).
- In the next step, the cmod.py file (the library with the class and method definitions) and the json library (for manipulating JSON objects) are imported.
- Finally, the CMOD object is instantiated as variable tmp, representing a CMOD server. After these basic steps, any CMOD operation (based on the REST API) can be made in the Jupyter notebook.

Getting the list of folders requires just a single line of code. The result variable holds the JSON response of the call and can be used for subsequent operations. In this example, the result is simply printed out.

In a similar way, typical CMOD tasks like searching for documents, retrieving a document etc. are implemented as simple methods, some requiring input parameters. In the case of a search, for example, both the folder name of the search as well as the search criteria need to be specified when calling the CMOD method.

The intent of the library is to keep the number of input parameters as low as possible. Since the output of the calls is JSON, standard JSON libraries in Python allow us to extract information like the unique document identification (docID) and use it in later program steps.
watsonx.ai Generative AI Use Cases
As mentioned earlier, Python is extremely popular in the Generative AI and Agentic AI area. IBM watsonx™ is IBM’s offering in this space and used in this article for illustrating how easy combining CMOD and watsonx can become thanks to the provided Python library. In watsonx.ai, the Prompt Lab is the place to experiment and test generative AI prompts with the different large language models (LLMs). watsonx.ai also comes with a Python library so that the prompts and LLMs can be used programmatically. You will find here a video that shows a simple Python program that retrieves a PDF document from CMOD, then extracts the document text and prompts the user to ask any question related to this document. The question, together with the text from the document, is passed as prompt to watsonx.ai. The Granite-20b-multilingual model is used as the LLM in the recording. The questions can be generic in nature (like “what is this document about?”), but also very specific (like “where is the branch office located?” or “what is the current account balance?”). In this way, a person can respond to questions without even opening or reading a document, thus saving significant time. The above approach can be extended to a RAG (retrieval augmented generation) scenario where the response is based on more than one document, e.g., a search result list from CMOD.

The CMOD Python library can also help in moving to Agentic AI whose additional value is reasoning and autonomous task processing, based on a series of pre-defined tools. Instead of a predefined solution path (like searching in a specific CMOD folder to find a certain document), Agentic AI frameworks assess the available tools to reach an answer and then determines iteratively the correct path. Obviously, a search in a CMOD folder could be one tool, and it is good to know that many Agentic AI frameworks make use of Python for their tool definition.
Many other AI use cases could be easily evaluated in Python based prototypes with the provided library, for example an automatic entity extraction, automatic addition of new meta data etc. Your ideas for other scenarios where this CMOD Python library would prove helpful are welcome as well as any other feedback you would like to share! Please reach out to me (r_engelbrecht@at.ibm.com) with your GitHub userID if you want to get access to the Python library for CMOD.
#Spotlight
#Highlights-home
#Highlights