LLM Client, AI Assist Screen, Moqui Sim Mode, etc (llm-client branches)

There are two new branches called ‘llm-client’, in moqui-framework and moqui-runtime:

These contain a proposed architecture and implementation of an LlmClient class in the framework that handles talking to an external LLM, and it handles tool calling, agent loop, logging, etc. The initial tools include artifact info browsing, skill lookup, skill leaning in a simulation overlay, and calling screen transitions, services, etc using the current user’s authz.

The tooling architecture and skill learning are designed in a particular way to help mitigate issues with AI automation in business systems. The primary mode is “skill-first” where the agent looks for a relevant skill, and if it does not find one it spawns a sub-agent in a simulated environment to experiment and find a solution, then document it in a skill.

The simulation environment uses a number of existing context and production isolation mechanisms in the framework, and adds a new one that I’ve been thinking of doing for a long time: TransactionCacheDb. This uses H2 as an in-memory database to overlay the external database and act as a multi-transaction read-through cache where writes stay in the cache DB until flushed to the external DB, or as in the case of the sim application, thrown away.

Built on top of these is the Assist screen. This is a new screen in the tools component available to all users. It has a LLM chat on the left, and a screen canvas on the right. It supports two render modes for the LLM: a simple JSON form spec output, and a Vue Single-File Component output. The overall workflow is ask the LLM to do something, it figures out how to and creates a form for it, even if the form is just descriptive text and a submit button. The user always maintains control, changes only made when buttons are clicked.

With this in place, and once it is all cleaned up and production-worthy, the game changes for what is most important to build and maintain. Creating screens is more about the structure and data+logic encapsulation that they offer than the output they produce. The XML REST API becomes a far more viable approach for internal as well as external data access and logic. Ideally, only very few screens are ever made again, focusing on those with more complex interactions and requirements, and that will be used frequently or for a very particular important purpose.

For general notes see the ReleaseNotes.md file (in the branch):

For an overview of the skill learning and TransactionCacheDb stuff, see the new LlmSkillLearning.md plan:

1 Like

A note on status for llm-client: this was all slapped together quickly with AI assistance. It has automated tests, and has been tested end-to-end including skill learning and use, but it has NOT been evaluated for performance, reasonable resource usage in production settings, or ensuring that the sim environment is sufficiently isolated.

In other words, this should definitely still be considered experimental and NOT used in production. It’s great for local use with an LLM running in LM Studio or vLLM or whatever, and that has been the only real test case so far.

If anyone would like to help with testing, using it on a staging server with a clone of a production DB is a test that needs to be done a bunch sooner or later, but any testing and review would be helpful. I made sure a few things were done in very particular ways, but there could still be a bunch of stuff in there that I haven’t caught… because I have not yet read/scanned all of the code, not tested from various angles to catch things that I’d probably miss in a code read anyway.

You’ve been warned. That said, have fun! I am. :slight_smile: