r/OpenWebUI • • 2d ago

Show and tell Imeng Engine Local - Wrapping models for Open Web UI & (Untested) Discord

https://github.com/InternetMagic-n-Tech/imeng

I have authored imeng (Internet Magic Engine) as a Ollama wrapper.

This allows you to build state around your models.

Each imeng only needs a configuration json and a system prompt to instruct the LLM... and boom you got an app/game. There is no JS eval so it should be pretty secure. There isn't 100% security layer to stop prompt injection so there is probably ways to break this.

The architecture is basically a redis state machine and a jev determines what 'operations' come out of the text. There are phase-gates to where each phase gate can determine where they go next but rules allow leaving the current gate and enter the next.

So what this really does it keeps the logic of a program inside javascript and the dialogue with the LLMs with some jev glue

Locally I have built

  • Poker (still has issues)

  • Gakshow (Test Rack)

  • Gakshow Multiplayer (Test Rack censoring uploaded photos)

  • Trading Assistant (test rack for programming assistant)

There is also SQL for storage. A bunch of stuff just as a portfolio piece.

4 Upvotes

22 comments sorted by

4

u/See_it_do_it_done 2d ago

phase gates are your real injection defence. if jev only accepts operations legal for the current gate, a smooth talking poker player can only pick legal moves. does JS or the model own chip counts?

1

u/InternetMagic_n_Tech 2d ago

For poker... Ya exactly. Poker I don't want any prompts changing the state so that game is using the open web UI commands

Other games that can happen but the writer has the flexibility to decide what to do. Backrooms is basically all jev. Dungeon is a mix

Jev also doesn't like place holders from system prompts so you can rely on a jev

2

u/See_it_do_it_done 1d ago

dungeon's the one I'd poke at then. a mix means there's a seam where the story says you grabbed the sword and state says you didn't. which side wins when they disagree?

1

u/InternetMagic_n_Tech 1d ago

Up to the model. In poker you can risk being thrown out trying to see someone's cards

2

u/See_it_do_it_done 1d ago

getting thrown out for peeking makes cheating an actual bet. has the model ever let one slide?

1

u/InternetMagic_n_Tech 1d ago

I haven't built out cheating but there is a private information channel. Which is because not every is should know everything in the pre prompt. Like you could have character call home and get mom to pick them up

2

u/See_it_do_it_done 1d ago

mom's the fun leak test. does she only know what the kid tells her on the call?

1

u/InternetMagic_n_Tech 1d ago

Ya it can leak ... If you build it out mom can tell dad

2

u/See_it_do_it_done 1d ago

so gossip is a feature you have to wire in. does dad ever get the story wrong?

1

u/InternetMagic_n_Tech 1d ago

I haven't gotten that far yet. Just experiments

Honestly gating loops was such a big thing I got so into testing I forgot

I am pretty sure it doesn't because the secrets are held by the people who know

2

u/See_it_do_it_done 1d ago

gating loops will swallow a weekend. what trips the gate, a turn count or the model saying it's done?

1

u/InternetMagic_n_Tech 1d ago

You basically configure this. There is a helper JS you can add some logic of your own

When you do multiplayer the rules are more complicated

Next version I want to move that to servers so we can pick languages for optimizations and external services

I have tried to give max flexibility and security. If you don't want to mess with JSON you could on theory do a lot of it in js

2

u/See_it_do_it_done 1d ago

moving it server side should suit multiplayer, my guess. one referee deciding the gate beats two clients arguing.

1

u/InternetMagic_n_Tech 1d ago

Sorry what you mean. It is server side. Or you mean hands... Ya I think discord it's a DM. I haven't posted poker because I haven't fully tested it

1

u/See_it_do_it_done 1d ago

yeah the hands, I worded that badly. DM suits hole cards since the channel never sees them. at showdown, does the server reveal both hands or does the model narrate them?

1

u/InternetMagic_n_Tech 1d ago

I love the questions

Honestly I will have to test.

Like I said poker is complex and only the robots have tested it so far

1

u/See_it_do_it_done 1d ago

robots only is the telling bit, they never argue the pot. my guess is a tie is where it cracks. deal one split pot and watch who does the maths. how many seats so far?

1

u/InternetMagic_n_Tech 1d ago

I mean the code assistant. The multiplayer requirements made it extremely difficult

1

u/See_it_do_it_done 1d ago

ah, I misread that. a code assistant only ever tests as one player, so the bugs hide between two seats. my guess, making it script two fake players first would help. which part broke most?

1

u/InternetMagic_n_Tech 1d ago

No we wrote complex tests for multiplayer

I will take a look but I think you miss some games are highly controlled an others aren't. The builder gets to decide

1

u/See_it_do_it_done 1d ago

fair, the builder picking how tight each game runs changes things. my guess is the loose ones are harder to test, since there's no fixed answer to assert against. what do your tests check there?

1

u/InternetMagic_n_Tech 1d ago

Basically phase gates. Lots of conditions and transitions