Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi guys, gentlemen and other binaries, hexanal, decimal and other TW5 fans!
Jumped here from TW Google Group, some long time was away from lovely TW5 :)

Well my idea it a very simple idea - turning TW5 into an LLM agent. Cuz all these so called LLM Agents are JSON array messages hanglers and no more.

What do you thing of this idea? Could be such tool will will spark big interest in TW5 :)

So I am starting with that simple proxy where I am going to push REST directly from TW5 tiddler aiming to http://localhost:3000/api/

For example http://localhost:3000/api/models

// deno run --allow-net --cert C:\certs\mycorpsert-ca.pem native_proxy.ts

// native_proxy.ts
import { serve } from "https://deno.land/std@0.200.0/http/server.ts";

const TARGET = "https://gateway-ai.mycorp.com";
const PORT = 3000;

serve(
  async (req) => {
    const url = new URL(req.url);

    // do route just for /api/*
    if (url.pathname.startsWith("/api")) {
      const targetUrl = TARGET + url.pathname.replace("/api", "") + url.search;

      // Clone headers, delete host
      const headers = new Headers(req.headers);
      headers.delete("host");

      try {
        const response = await fetch(targetUrl, {
          method: req.method,
          headers,
          body: req.body,
        });

        // response handle
        return new Response(response.body, {
          status: response.status,
          statusText: response.statusText,
          headers: response.headers,
        });
      } catch (error) {
        return new Response(`Proxy error: ${error.message}`, { status: 502 });
      }
    }

    return new Response("Not found", { status: 404 });
  },
  { port: PORT },
);

console.log(`Proxy listening on http://localhost:${PORT}`);

Then I started to google existing JSON handling plugins for TW5 and https://joshuafontany.github.io/TW5-JsonMangler/ from Joshua Fontany looks promising. But,
I stumbled upon a JSON kind of error in vanilla TW5 but found out that this is a feature not an error :)

<$transclude tiddler=myJsonTiddler index=myindex /> works perfectly in TW5-JsonMangler
and doesn't work in vanilla TW5 5.3.8
because $tw.wiki.extractTiddlerDataItem happened to be a bit patched by Joshua

described all it here #3075

So my second question - is it a usual and normal way to create a TW5 fork with patching modules like $wiki.js and so on ?
I mean it could be good to save compatibility with future TW5 versions 🤔🤷‍♂️

And could you please advice what me better to do if I need TW5-JsonMangler (it's seems dated by 2018) behavior but want to be alined with 5.3.8 and future vanilla TW5 ?

Thank you!

You must be logged in to vote

Replies: 3 comments · 5 replies

Comment options

There are 3 threads at Talk that I could find. That may not be exactly what you want, but may be interesting.

You may find even more there.

You must be logged in to vote
1 reply
@luchezarno
Comment options

Thank you very much! Going to exam it

Comment options

<$transclude tiddler=myJsonTiddler index=myindex /> works perfectly in TW5-JsonMangler
and doesn't work in vanilla TW5 5.3.8

It seems to work for me. I tried this at https://TiddlyWiki.com (v5.3.8):

  • create a new tiddler containing:
<$button>click me<$action-setfield $tiddler="myJsonTiddler" $index="myindex" $value="test this"/></$button>
<$transclude tiddler=myJsonTiddler index=myindex />
  • press the "click me" button to create "myJsonTiddler" with myindex="test this"
  • note that the $transclude DOES show the "test this" value
You must be logged in to vote
4 replies
@luchezarno
Comment options

Excuse me, but no. It does not work with JSON tiddlers like this

{"mydata":[{"id":"large","object":"model","created":1677610602,"owned_by":"openai"},{"id":"base","object":"model","created":1677610602,"owned_by":"openai"}]}

While in JsonMangler this <$transclude tiddler=testJson index=mydata />
works fine

[[for some reason I am not able attach any picture here 😬 don't know why ]]

In stock 5.3.8 - not

@ericshulman
Comment options

Have you tried using the TWCore json filter operators (jsonget, jsonset, jsonextract, jsonstringify) instead of JsonMangler?

For example

{{{ [{testJson}jsonextract[mydata]] }}}
@luchezarno
Comment options

@ericshulman Ohh!! Great! Magic :)) This works like a charm!! Thank you, Eric!
I think this is more than enough for my purpose :) Now I am able to continue my experiments with LLM messages handling 😊

@luchezarno
Comment options

For example

{{{ [{testJson}jsonextract[mydata]] }}}

Sometimes it’s confusing when there are many ways to do the same thing 😬 I freeze up

Comment options

Do you use agents frequently? I ask Because my daily usage will produce 20~ 40 M token input, this means its message history will be 40M words, we can guess it will take up nearly 40MB of space.

So, chat history should not be saved to the Wiki. Only use the Wiki as input context and not as storage for the output.

About the agent input and how it should be automatically collected, you can discuss that in the #9378

I'm not sure why many people try to discuss and create plugins for the LLM and basic chat experience, but few try to solve problems for the agent area. It is already not the basic LLM chat era, it ends in 2025 Q2. Now it is Agent era, even VSCode copilot delete the "edit mode", and use "Agent mode" by default.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.