Artificial intelligence in TW - This is how, basically!

OK, I’ve been holding off on posting this because it would be more fun if I first investigated things properly and could post an actual how-to. But at this time, this is too big so I’m limiting the value of this post to merely informing that it can be done and providing pieces for how to do it:

Yes, you really can integrate AI into your TW and have it do all kinds of stuff.
Basically:

  1. You will use Google Sheets (i.e the “Excel” in google docs) as a back-end to store your tiddler data.
  2. Google Sheets now features integration with ChatGPT.

Thus, ChatGPT can use your tiddlers and intelligently manipulate their data to e.g output new tiddlers or modify existing ones.

Using ChatGPT in Sheets

…and here’s what I guess you’re most curious about: How to connect Sheets to TiddlyWiki! Well, first off, this has been done previously (by fellow @Mark_S and me), namely the SheetsIN plugin, which is a part in the greater TiddlyGoo project! Unfortunately, Google changed their mechanisms so SheetsIN no longer works. If you do get things to work via any of the following solutions, then the TiddlyGoo project should still provide many useful further tools. Just sayin.

…BUT the SheetsIN plugin was originally based on bits in fellow @Siniy-Kit solutions - and AFAIK, @Siniy-Kit still successfully uses google sheets as a TW storage for his TW shops! So he has a working solution for connecting Google Sheets with TW. Here is one example:

Now, I’ve also found these articles from @philwonski that additionally use AWS Labmda. The articles are step-by-step instructsions to set it up:

…and me thinks maybe this one is useful too, without AWS Lambda:

So, I think these things could be set up to, for example, look at the text in a tiddler and extract information in an intelligent way and present this refined information in another tiddler (@NickB ,ref).

Or, it can save you from constructing your own difficult filters, at least regex filters (if you, presumably, can specify what you want).

Going further upstream, I would think that something like the TiddlyWiki Newletter or any other blog presented in TW can be totally automated. @jeremyruston

BTW, I read the other day that Obsidian now features AI capabilities… so the pressure is on :grinning_face_with_smiling_eyes:

5 Likes

They have at least one plugin. It can attach directly to APT Chat API. This is possible when you have an executable program running on a local machine. In theory something similar should be possible in node. But we don’t have much (any?) guidance on how to build tools that use external resources on node.

2 Likes

Thanks @twMat, what I want is the antithesis of a system connecting to an AI service but it’s interesting nonetheless!

That, in technical terms, is referred to as “Paper and Pencil”.

I have done some experiments with calling the OpenAI GPT3 API (which predates ChatGPT). It’s a pretty straightforward JSON REST API, and crucially it is CORS enabled so it can be used from single file wikis.

4 Likes

Logseq has this kind of plugin too. GitHub - briansunter/logseq-plugin-gpt3-openai: A plugin for GPT-3 AI assisted note taking in Logseq

To do such thing in tw, how command palette get selection from text editor is a problem, because we have multiple command paltte and multiple editor implementation…

1 Like

I’m planning to embed python environment with TidGi, and run model within it. So it will be local first, not OpenAI required.

2 Likes

Hi Jeremy, do you have a shareable plugin for it? I can’t imagine how generation will fit into current editor design.


See gifs in links below for inspiration.

Widgets in tw is not async, so maybe an AI widget will write results to a state or temp tiddler, and we use ViewTemplate or EditTemplate to show that result below the tiddler. And use a button to use listops to insert text after the editor cursor? (We might need a state tiddler to indicate the cursor position in the editor…)

I have yet to address the editor integration. I was focussed on a slightly different use case: working with a library of templated prompts, displaying the output in a separate tiddler, and using copy and paste to get the results where they are needed.

An approach for integration with the editor might be that when the toolbar button is clicked, record the text before the cursor as the “prefix” and the text after the cursor as the “suffix”, along with the title of the draft tiddler into which the results should be inserted. Then when the API call returns one would attempt to match the prefix and suffix to determine where to insert the results. If no match is found, one would just append the results to the end of the tiddler.

Now that Open AI release their low-cost API, maybe you can create a server to wrap them, and create a paid plugin, with login and monthly subscription, and support alipay so Chinese can pay too. This is a good chance to raise TiddlyWiki to the same level as logseq and notion in AI competition. And also gather money for TiddlyWiki or for yourself.

And this can be a core plugin, I think a community plugin can’t bear the importance this plugin should have. This also means some deep integration with all aspects of tw.

3 Likes