WikiSage -- Your Tiddlywiki AI Companion

I’m listening, say more. Right now the agent can create tiddlers and those are treated the same as normal tiddlers

I’m in so deep with the streams outliner, lol (you should be able to expect a working version soon :wink: )

Even better if you do this with streams than with sections.

Hi just wanted to say I’m really excited to see the community is making progress towards adding support for interacting with AI services. Is it possible with this plugin to use the Perplexity API? It looks like at this point OpenAI does not support web search via API.

I can look into it :slight_smile: I’ve never used perplexity, but we search would be quite excellent, I’m interested.

Just updated my model list with the new 3.7 Sonnet:

To use, just update the model list file with claude-3-7-sonnet-20250219

I recently found that instead of chatting directly with AI, having AI comment on your notes is more interesting. For example, we can use a field ai-comments to save a JSON formatted list of data, which contains comments from various intelligent agents with different personalities and backgrounds on your note.

The question I am currently thinking about is how to make the best use of core functions to allow AI to randomly call the API during idle time on the computer to comment on a random note, and to keep it as brief as possible, rather than lengthy, to avoid taking up too much storage space. I know there is a plugin called its about time that can provide a certain degree of random timing functionality, which might be useful.

I am not doing these things right now because the AI features and time functions in the core of TiddlyWiki have not been released. I am afraid that writing something now will make the plugin ecosystem a bit chaotic, such as the management of agents, where each plugin would maintain its own set of the management of prompts, as well as the management of APIs and keys (Like I want to use Deepseek R1, but how to provide it to all AI plugins at once?), would also lead to many redundant wheels in the ecosystem.

Yes, I agree that chatting directly is not often the most useful way of engaging. With WikiSage, I currently have prompt such as “Process this article into Source and Idea tiddlers and open for review by the user” which I just transclude along with text contents – and, elsewhere, I have described how I use AI to convert my reading notes into Tiddlers.

The “next release,” of WikiSage, when that occurs, will include more of these sorts of features.

In terms of what you’re discussing, I have been mapping out how an AI Daemon would work, which would run checks on what the user is doing with a small (and/or local model) and report, when appropriate, to a larger model for taking action (such as commenting, as you mention).

1 Like

I tried to use GitHub - bpmnServer/bpmn-server: BPMN 2.0 server for Node.js , providing modeling, execution, persistence and monitoring for Workflow. along with sample UI. Intended to be developers workbench for BPMN 2.0 to create something like https://www.coze.com/ , but later I find this kind of workflow engine is too big (1MB+) and most of features are useless.

A combination of set-timeout action widget (from its about time plugin) and some action tiddler (tagged with $:/tags/Actions) may be enough for auto commenting task.
This kind of workflow requires knowledge of wikitext widget usage, not as easy as visual workflow, but it is for developers so it is fine. End users will only use “AI comment pal” plugin without touching workflow under the hood.

Please note that It's About Time! — TiddlyTools: "Small Tools for Big Ideas!" (tm) is OBSOLETE and has not been updated since September of 2022. Instead, ALL TiddlyTools add-ons (including the $action-timeout custom widget) are hosted directly on https://tiddlytools.com, which should be referenced as the definitive source for the most up-to-date versions.

-e

Interesting, I’ll check it out. Size efficiency is a big concern for me, but my thinking - - and this is true of my thoughts about how innovation in AI ultimately takes place generally - - revolves around coming up with clever and efficient applications of the tool, rather than piling on more and more features.

FYI 10 个月,5 万 DAU,我们可能找到了 AI 陪伴的另一种可能 - 王登科-DK博客 (you can use https://immersivetranslate.com/ to read it)

1 Like

Sorry I was wrong, core AI plugin draft already have this standard, just following it will be fine

with tags: $:/tags/AI/CompletionServer and \procedure json-prompt() and \procedure completion-callback()

And there is already a core comment plugin Why is comment plugin not mentioned in the official documentation site , so I think making a AI comment plugin is pretty easy now, based on core plugins.

I’m pushing this forward by
AI tools more server by linonetwo · Pull Request #8966 · TiddlyWiki/TiddlyWiki5 · GitHub
and
[IDEA] SetTimeout / SetInterval / SetAlarmClock widget · Issue #8967 · TiddlyWiki/TiddlyWiki5 · GitHub

Hi @well-noted , is this possible in WikiSage?

It would be cool to use a temp-tiddler that is not saved to store the API-Key…
BTW I am working on a tiny plugin to encrypt the apikey so that only the owner of the wiki can use it.

Hmm… I don’t know if that will work, @JanJo I’ve never tried to transclude that way. Why don’t you try and let me know? It’s a good idea :slight_smile:

1 Like

@JanJo, PS I have a hacky solution for integrating Gemini now :slight_smile:

If you’d like to give it a try (preview before the repackage), replace the contents of the widget.js with $__plugins_NoteStreams_WikiSage_widget.js.tid (130.4 KB) and then make sure you have your API key in $:/plugins/NoteStreams/WikiSage/gemini-api-key

Add the model you want to use to the list and it should work :slight_smile: The model I have working is gemini-2.5-flash-preview-04-17

Currently only supports chat, no tool use, but I will implement that in the actual release if possible. I don’t currently know if Gemini will allow tool use, though I do see that function-calling is allowed, so that should work.

1 Like

See TiddlyTools/Filters/encrypt.js which defines encrypt[key] and decrypt[key] filter operators.

To take user input and encrypt it, you could get both an APIKey value as well as an encryption key value that you would use as a “password” and then use the encrypt[...] filter to generate a JSON object that encodes the APIKey in encrypted form that can be stored in a tiddler (e.g. “MyAPIKey”).

Later on, you could then use that stored JSON object plus the same “password” value with the decrypt[...] filter to retrieve the unencrypted APIKey value and then reference {{$:/temp/APIKey!!key}} to access your OpenAI account.

Something like this:

APIKey: <$edit-text tiddler="$:/temp/APIKey" field="key"/>
Password: <$edit-text tiddler="$:/temp/APIKey" field="password"/>
<$button> save key
   <$action-setfield $tiddler="MyAPIKey"
      text={{{ [{$:/temp/APIKey!!key}encrypt{$:/temp/APIKey!!password}] }}}/>
</$button>
<$button> get key
   <$action-setfield $tiddler="$:/temp/APIKey"
      key={{{ [{MyAPIKey}decrypt{$:/temp/APIKey!!password}] }}}/>
</$button>

Note that by default $:/temp tiddlers are automatically discarded when the file is saved, so only the resulting “MyAPIKey” tiddler containing the encrypted JSON object is saved in your TiddlyWiki file.

Note also that for added security, you could use a <$password> widget for entering the encryption key, like this:

APIKey: <$edit-text tiddler="$:/temp/APIKey" field="key"/>
Password: <$password name="OpenAPIpassword"/>
<$button> save key
   <$action-setfield $tiddler="MyAPIKey"
      text={{{ [{$:/temp/APIKey!!key}encrypt:password[OpenAPIpassword]] }}}/>
</$button>
<$button> get key
   <$action-setfield $tiddler="$:/temp/APIKey"
      key={{{ [{MyAPIKey}decrypt:password[OpenAPIpassword]] }}}/>
</$button>

In this way, the password you enter is NEVER stored in a tiddler (not even a $:/temp tiddler), but is instead stored directly in your browser’s LocalStorage, which is used as the TiddlyWiki “Password Vault”.

enjoy,
-e

2 Likes

I also was working on a way to use the browserstorage to encrypt the tiddler. I guess @EricShulman’s solution is better.

I think the best way would be to directly store all APIKeys in temporary tiddlers and use @EricShulman’s mechanism to set it to the TIddler…
The password could be the same for all APIKeys I guess.

Addendum:

When using TiddlyTools decrypt[...] filter, if the “password” you provide is incorrect the filter returns the text:

CORRUPT: ccm: tag doesn't match

(this is the value returned from the underlying Javascript sjcl.decrypt() library function)

So, when fetching the saved key from the encrypted JSON, if that text is returned, you will want to set the $:/temp/APIKey!!key value to blank, like this:

<$button> get key
   <$action-setfield $tiddler="$:/temp/APIKey"
      key={{{ [{MyAPIKey}decrypt{$:/temp/APIKey!!password}!match[CORRUPT: ccm: tag doesn't match]] }}}/>
</$button>

-e