Author Topic: AIChat2 - Using AI from OS/2  (Read 635 times)

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 377
  • Karma: +15/-0
AIChat2 - Using AI from OS/2
« on: June 05, 2026, 06:18:15 am »
  • gemini.google.com
  • duck.ai
both work with our browser (Otter 1.0.81, QT5) with patience and alteration of zoom factor for gemini.

  • or our own home made one locally...
based on llama3_2.c (see github) instead of llama2.c but Europeans may only the latter. Just need a bit of tweaking to the code and it will compile with OpenWatcom v2.

  • or have a front end that call models online with apikey.
Am looking at Mistral (French AI) at the moment.
Just begun this one for Classic Rexx on OS/2, and it is therefore not finished... haven't even seen the start page of it yet as it is sooo new.


//Jan-Erik
« Last Edit: June 08, 2026, 07:14:42 pm by Martin Iturbide »

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 377
  • Karma: +15/-0
Re: Programming an OS/2 App with AI
« Reply #1 on: June 07, 2026, 11:21:47 pm »
Improve as you like!

Usage:
  • Download these files, including rxMIME.cmd*
  • Rename the files downloaded and remove .txt as extension
  • Get your APIKEY by registering on their site **
  • Save the APIKEY to a file on your computer for safe keeping
  • Start aichat2.cmd
  • Open your web browser and type in the url that the script aichat2.cmd say
  • Select the AI model that your APIKEY is for and paste the APIKEY to the field in the web browser and save it ***
  • Use the AI Chat Client and improve it!

* rxMIME.cmd sample the file data and determine the MIME type to communicate with the server and/or web browser.

** Use your phone or Windblows, for example with Mistral chat.mistral.ai that is free for the tiny and small models and was used to develop this chat client. ("Codestral" for heavy coding cost money)

*** The APIKEY may disappear if you move/purge/delete/damage the script aichat2.cmd, as it is saved to the EA (Extended Attribute) of aichat2.cmd

Note!
  • The script and the acompanying files need your TLC, just as the UI (color, positioning, buttons, features).
  • Have included the bulk of possible functions to the script, but they may need to be extended/tweaked/improved/altered to work better.
  • Haven't checked code to handle attachments.
  • The script/web browser may not show code returned (see the file "log") with the JSON reply from the AI chat server and thus need your TLC.
  • The file RxConv.cmd (not included, nor written) should be written to convert diffent files to either text, pdf or a format the the AI chat server can accept.
« Last Edit: June 08, 2026, 06:40:08 am by Jan-Erik Lärka »

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5809
  • Karma: +50/-1
  • Your Friend Wil Declares...
    • Martin's Personal Blog
Re: AIChat2 - Using AI from OS/2
« Reply #2 on: June 08, 2026, 07:39:44 pm »
Sorry Jan, I screw up the slip topic.

I missed this message....

Improve as you like!

...
  • Haven't checked code to handle attachments.
  • The script/web browser may not show code returned (see the file "log") with the JSON reply from the AI chat server and thus need your TLC.
I've now tested to attach a file... and to my surprize it seem to work, but...
the html-code in the reply doesn't show up, it is only present in the log file called "log".

Do feel free to tweak the code so all kind of code can be displayesd as well.
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5809
  • Karma: +50/-1
  • Your Friend Wil Declares...
    • Martin's Personal Blog
Re: AIChat2 - Using AI from OS/2
« Reply #3 on: June 09, 2026, 04:25:39 am »
Hello Jan

I'm not sure if by downloading the files one by one, I'm breaking something.
May I be missing some library?

Can you put all the files into a .zip and upload it here?

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 377
  • Karma: +15/-0
Re: AIChat2 - Using AI from OS/2
« Reply #4 on: June 16, 2026, 08:46:27 pm »
This include the chat code as before, while the image is the version I'm working on.
formatText in the included file cause text to dissappear and should be replaced by something like this:
function formatText(text) {
  text = text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  text = text.replace(/^#\s+(.*?)\s*$/gm, '<h1>$1</h1>');
  text = text.replace(/^##\s+(.*?)\s*$/gm, '<h2>$1</h2>');
  text = text.replace(/^###\s+(.*?)\s*$/gm, '<h3>$1</h3>');
  text = text.replace(/\*\*\*(.*?)\*\*\*/g, '<strong><em>$1</em></strong>');
  text = text.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
  text = text.replace(/\*(?!\/)(.*?)(?<!\/)\*/g, '<em>$1</em>');
  text = text.replace(/~~(.*?)~~/g, '<s>$1</s>');
  text = text.replace(/```([\s\S]*?)```/g, '<pre>$1</pre>');
  text = text.replace(/^\-\s+(.*?)$/gm, '<ul><li>$1</li></ul>');
  text = text.replace(/^\d+\.\s+(.*?)$/gm, '<ol><li>$1</li></ol>');
  text = text.replace(/\n/g, '<br>');
  text = text.replace(/  /g, '&nbsp; ');
  return text;
}

Ai tools have a tendency to have strenghts and weeknesses... and when/what they forget after a while, depending on the AI-model-provider.
Mistral is good with look and feel, but haven't figured out some of the finer rexx and html features, while google gemini create awful/ugly ui and can drop everything (code, variables) without notice.
« Last Edit: June 16, 2026, 08:48:47 pm by Jan-Erik Lärka »

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5809
  • Karma: +50/-1
  • Your Friend Wil Declares...
    • Martin's Personal Blog
Re: AIChat2 - Using AI from OS/2
« Reply #5 on: June 20, 2026, 06:49:36 pm »
Hello Jan-Erik

It is not working on my side.

I get the attached error on the console. Am I missing some library?

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 377
  • Karma: +15/-0
Re: AIChat2 - Using AI from OS/2
« Reply #6 on: June 27, 2026, 08:26:34 am »
Apparently this *nix server ruin crlf line endings and the file get transaferred interpreted as a *nix text file.

Use mkmsg to "compile" the file cai_en.txt to cai_en.msg
while you're at it, you may just as well create a version of the text file for your language and have a message file tailored for you.

I'm using gemini.google.com and mistral to write a dll to run curl to handle Server-Sent Events (SSE), since at is now one may not get the full reply from the server as there should be more. Another problem to overcome is the 1024 character parameter limitation in OS/2 that many *nix applications these days use extensively.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 377
  • Karma: +15/-0
Re: AIChat2 - Using AI from OS/2
« Reply #7 on: June 27, 2026, 07:01:29 pm »
Now one can use it to chat!

It show code with syntax highlightning with CodeMirror 5.65.13 (though firefox 45.9 complain...)
I've also included a version to support syntax highlightning for rexx (based on vbscript).

Copy and paste code you want to ask about.

But you'll find issues that I really hope you can help me to solve/improve.

1. Non complete replies?! Enormously annoying!!!
2. Set how the AI chat should reply, such as "be polite", "summarize", "provide brief answers" etc.
3. Attach file data
4. Other improvements
« Last Edit: July 04, 2026, 09:52:39 pm by Jan-Erik Lärka »

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5809
  • Karma: +50/-1
  • Your Friend Wil Declares...
    • Martin's Personal Blog
Re: AIChat2 - Using AI from OS/2
« Reply #8 on: June 27, 2026, 09:56:29 pm »
Thanks Jan-Erik

It worked now for me.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5972
  • Karma: +163/-1
Re: AIChat2 - Using AI from OS/2
« Reply #9 on: June 28, 2026, 05:52:30 am »
It seems to be working well here. Did have to use Dooble-Qt5 as SeaMonkey had problems and only tested mistral-small.
Good work

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 377
  • Karma: +15/-0
Re: AIChat2 - Using AI from OS/2
« Reply #10 on: June 28, 2026, 11:45:31 am »
The script have my credentials... so register your own with Mistral.

But also do try to fix all the shortcomings that yet exist.

Am trying to add file attachments, but the different ways between browsers and ... Gahh!

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5972
  • Karma: +163/-1
Re: AIChat2 - Using AI from OS/2
« Reply #11 on: June 28, 2026, 06:28:16 pm »
The script have my credentials... so register your own with Mistral.

OK, didn't realize that.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5809
  • Karma: +50/-1
  • Your Friend Wil Declares...
    • Martin's Personal Blog
Re: AIChat2 - Using AI from OS/2
« Reply #12 on: June 28, 2026, 08:45:54 pm »
Hello Jan-Erik

Do you think you can write a small readme on how to use it and how to change the credentials, so we can share your files at Hobbes. I found it useful for us.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 377
  • Karma: +15/-0
AIChat2 v1.1 - Using AI from OS/2
« Reply #13 on: July 04, 2026, 09:44:08 pm »
Hello!

Here's the new version of aichat2 v1.1

see help.html for information!

The text below was copied as seen in the screenshot.

# Summary of Features

## Overview
This is a client-server application that provides an AI chat interface with a local web server running on OS/2. The server is written in REXX and supports various AI models from different providers.

## Main Components

### 1. REXX Server (aichat2.cmd)
- **Purpose**: Provides a local HTTP server that interfaces with AI APIs
- **Features**:
  - HTTP server functionality using RXSOCK and RXULS libraries
  - Supports multiple AI model providers (Mistral, OpenAI, Google, Anthropic, Meta, etc.)
  - Handles POST/GET requests with streaming responses
  - Manages chat history and conversation state
  - File attachment handling
  - Multi-language support via message files
  - Debug mode for troubleshooting

### 2. HTML Client (index.html)
- **Purpose**: Provides a feature-rich web interface for chatting with AI models
- **Features**:
  - Modern, responsive UI with CodeMirror integration for code highlighting
  - Multiple AI model selection (30+ models from different providers)
  - Role-based conversation management (customizable AI personalities)
  - File attachment support (images, PDF, TXT, CSV, JSON, XML, MD)
  - Code block formatting with preview functionality
  - Conversation history management
  - Token counter and conversation statistics
  - Export functionality to save conversations
  - Search in chat
  - Print support
  - Multi-language markup support

## Key Functional Features

### AI Model Integration
- Supports models from multiple providers:
  - EU-based: Mistral
  - US-based: OpenAI, Google, Anthropic, Meta
  - China-based: Baidu, Alibaba, Zhipu, DeepSeek
- Model-specific URLs and jurisdictions
- API key management with persistent storage

### Conversation Management
- Role-based interactions with customizable AI personalities
- Conversation history with timestamping
- Token usage tracking
- Multi-message conversations with streaming responses

### Interface Features
- Real-time message streaming with CodeMirror integration
- Code syntax highlighting for 30+ programming languages
- HTML/XML preview functionality
- Rich text formatting options
- File attachment display and management
- Edit/Delete functionality for messages
- Copy functionality for messages or code blocks

### User Experience
- Responsive design with modern UI elements
- Keyboard shortcuts (Enter to send, Shift
« Last Edit: July 04, 2026, 09:48:06 pm by Jan-Erik Lärka »

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 377
  • Karma: +15/-0
Re: AIChat2 - Using AI from OS/2
« Reply #14 on: July 05, 2026, 12:11:37 pm »
An update (v1.1.1) is on the way... just need to fix things first.