My developer colleague, Fabio di Paola, has done some experimenting with ChatGPT and he successfully used it with LotusScript.
He published an article, in Italian, on our blog, here.
To save you the hassle of translating, here it is in English:
OpenAI.com’s ChatGpt is kind of the main topic of the last few months, we’ve all tried to use it and we’re thinking about how to use it in real cases. Precisely in the light of these considerations, the first question we asked ourselves was “but will I be able to use it within a Domino application?”
The answer is Yes , it can be done : we are investigating it these days and the first results are positive ; It’s true that sometimes, from theory to practice, surprises are always discovered and therefore the last word is never said, but here I feel optimistic. LotusScript can query ChatGpt and receive its response.
OpenAi has released APIs to connect to ChatGpt but, at least for now, they are limited to Python and node.js . In addition several communities have already published code libraries to connect to ChatGpt from other languages. It’s hard to think that something like this will ever be done for LotusScript .
But going to see how the calls are made and trying to experiment on the ChatGpt playground you can understand the mechanisms that underlie the calls to ChatGpt.
The first thing needed, regardless of the code used, is the API key for authentication: this is obtained by registering on the site and then going to the details of your account under ApiKeys It is a string of 51 characters which must then be passed to every call.
At this point I started building a first prototype in LotusScript, the main parts are two:
The NotesHTTPRequest class to send the request and get the response
The construction of the Json to be sent and then the parsing of the return Json
For the NotesHttpRequest there is little to say, just remember that the API key must be managed as a header of the request.
For the Json part there are obviously various possibilities to build it and then to parse it, obviously the important thing is to follow the ChatGpt rules: here too, using the playground you can easily understand how to build it, which parameters to pass and how.
At the end of all what I got is a form in which to enter the question with a button that sends it, parses the answer and writes the answer itself in a field below, all using only LotusScript :
I add a curiosity: among the questions I asked ChatGpt I asked if he knows LotusScript (with an affirmative answer) and then I asked if he could write me the LotusScript code to send requests to ChatGpt. Again the answer was yes but the code he gave me had several errors.
I replied pointing out the various errors and corrections were proposed to me which were equally incorrect. As far as I understand at the moment ChatGpt doesn’t “learn” from its mistakes, so it’s possible that asking it the same questions again will result in the same errors.
Today I discovered that my Prometheus container kept crashing, and in the logs I found lines like these:
corrupted block 01GQT2R33ASC29W57NF4WEZKP3: open data/01GQT2R33ASC29W57NF4WEZKP3/chunks: no such file or directory; corrupted block 01GQW0HNMW76WDHNY6T8CMEVQ0: open data/01GQW0HNMW76WDHNY6T8CMEVQ0/chunks: no such file or directory; corrupted block 01GQGDRDRKSS062T1762WACX5H: open data/01GQGDRDRKSS062T1762WACX5H/chunks: no such file or directory; corrupted block 01GQJBHXKJW38754FR7CZGTWZN: open data/01GQJBHXKJW38754FR7CZGTWZN/chunks: no such file or directory; corrupted block 01GQM9BGT78HDQXM2EZ2BP5P8S: open data/01GQM9BGT78HDQXM2EZ2BP5P8S/chunks: no such file or directory; corrupted block 01GQP75073Q7FRW2MEGE1T5869: open data/01GQP75073Q7FRW2MEGE1T5869/chunks: no such file or directory; corrupted block 01GQR4YKN8XJS7FY30VYR24VTG: open data/01GQR4YKN8XJS7FY30VYR24VTG/chunks: no such file or directory"
In fact looking at the directory structure under /tmp/prometheus, the default directory where Prometheus store files I found this: