Using ChatGPT with and or about TiddlyWiki

Another example of ChatGPT, where I created a bookmarklet for setting the window name of a tab Bookmarklets, Just in Time install, Windows work flow and Timimi - #8 by TW_Tones

Wow

I returned to ChatGPT4 and asked this; The answer possibly stolen from one of our members, but I created it and it worked.

There is a standard way to write the javascript for filter functions in tiddlywiki, can you help me write one?

Certainly! In TiddlyWiki, a filter is a sequence of steps that select a set of tiddlers from the entire wiki. Each step in a filter can transform the current set of titles by adding to it, removing from it, or otherwise changing it.

To write a filter function in TiddlyWiki using JavaScript, you would typically create a JavaScript macro or a plugin that defines a new filter operator.

Here’s a basic outline of steps to create a custom filter function in TiddlyWiki:

  1. Define a JavaScript Macro or Plugin: Create a new tiddler with a type of application/javascript.
  2. Create a Filter Function: Define a function that will act as your filter. The function should accept an operand (if your filter operator requires one), an array of titles to filter, and an optional callback function for a run prefix.
  3. Register the Filter Operator: Use the $tw global object to register your filter function as a new filter operator.
  4. Use the Filter: Once the operator is registered, you can use your new filter in filter expressions anywhere in your TiddlyWiki.

Here’s a simple example of a filter operator that filters tiddlers by checking if their title includes a certain string:

/*\
title: $:/plugins/myusername/myfilteroperator.js
type: application/javascript
module-type: filteroperator

\*/

(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Export our filter function
*/
exports.myfilter = function(source, operator, options) {
    // operator.operand is the text that the filter operator is being applied with
    var text = operator.operand.toLowerCase();
    // operator.prefix determines if it's a negation
    var invert = operator.prefix === "!";
    // source is the list of tiddler titles being filtered
    var results = [];
    source(function(tiddler,title) {
        if(title && title.toLowerCase().indexOf(text) !== -1 !== invert) {
            results.push(title);
        }
    });
    return results;
};

})();

This code defines a filter operator named myfilter that includes tiddlers if their title includes the given operand text.

To use this new filter, you’d add your operand in a filter run like this:

[myfilter[searchText]]

Or to use the negation:

[!myfilter[searchText]]

Make sure to replace searchText with the actual text you want to filter by.

Please note that you should be comfortable with JavaScript and familiar with the TiddlyWiki development environment before attempting to create custom filters. Also, ensure to test your filters carefully to ensure they work as expected within your TiddlyWiki environment.

now to test if it can modify this to perform more sophisticated functions

Just an update, I made a number of filters that worked quickly and easily,

  • total fieldname given a fieldname will sum all input tiddler titles fieldname field
  • totalcost, which if given two fieldnames will multiply one by the other an sum them all

This can off course be achieved with regular filters and or functions but they are useful for simplication purposes.

What is an operator you would like to see?

I think we need a thread with curated one-liners.

Maybe AI could help us write TiddlyWiki documentation that is lacking?

There has been new releases of the LLM used for ChatGPT that can be provided documents to ingest and provide feedback and information on.

If one were to build one of these LLM and feed it individual tiddlers from TiddlyWiki.com, it would likely be able to provide accurate information and list areas that could use further elaboration and suggest areas that require further documentation.

I was just watching a YT video regarding this yesterday, I believe a new version was just released that functions very well. Edit: a YT video just on llm’s sadly no one has begun making a tiddlywiki specific gpt model :pensive:

I saw this thread yesterday ChatGPT - Tutor TiddlyWiki
I did not try it though

I just loaded empty.html into ChatGPT and started asking questions (TiddlyWiki.com is too big).

Other questions are giving bag answers.

what standards can you determine for each of the modual-types?

In TiddlyWiki, module types are an integral part of its modular architecture, each serving specific purposes and adhering to certain standards. Here’s an overview of the common module types and their standards:

1. Widget Modules

  • Purpose: Widgets are the building blocks of TiddlyWiki’s user interface. They provide interactive components like buttons, links, lists, etc.
  • Standards:
    • Defined in JavaScript.
    • Must export a widget class extending from the base widget class.
    • Typically interact with the DOM and handle user input.

2. Macro Modules

  • Purpose: Macros are reusable code blocks for generating content. They can be invoked in Tiddlers to perform specific tasks.
  • Standards:
    • Can be defined in WikiText or JavaScript.
    • JavaScript macros should export a function that returns a string representing the HTML content.
    • Often used for text processing and dynamic content generation.

3. Filter Operator Modules

  • Purpose: Filter operators are functions used in TiddlyWiki’s powerful filtering system to select and manipulate Tiddlers.
  • Standards:
    • Written in JavaScript.
    • Export a function that defines the filter operation.
    • Should handle an array of titles and return an array based on the filter logic.

4. Parser Modules

  • Purpose: Parsers interpret and convert content in various formats (like Markdown, WikiText) into HTML.
  • Standards:
    • Implemented in JavaScript.
    • Must export a parser class with methods for parsing text.
    • Should be efficient in converting text to HTML elements.

5. Startup Modules

  • Purpose: Executed when TiddlyWiki starts, these modules initialize various aspects of the application.
  • Standards:
    • Typically JavaScript modules.
    • Must export a startup function.
    • Often used for setting up global state, registering event listeners, or initializing services.

6. Stylesheet Modules

  • Purpose: Define CSS styles used throughout the wiki.
  • Standards:
    • Can be written as CSS tiddlers or embedded within Tiddlers.
    • Automatically applied to the wiki’s global style.
    • Useful for theming and customizing the appearance.

7. Saver Modules

  • Purpose: Handle the saving of TiddlyWiki data to different locations or formats.
  • Standards:
    • Written in JavaScript.
    • Should export functions to manage the save process.
    • Often interacts with external systems or local storage.

8. Server Modules

  • Purpose: Used for running TiddlyWiki in a Node.js environment, handling server-side operations.
  • Standards:
    • JavaScript modules.
    • Include functionality for handling HTTP requests, serving files, and managing server-side tiddler storage.

Best Practices for Developing Modules

  • Follow the TiddlyWiki documentation for specific guidelines and API usage.
  • Ensure compatibility with different environments (e.g., browsers, Node.js).
  • Maintain performance and security, especially for modules that interact with external systems or modify core functionality.
  • Test extensively to ensure reliability and compatibility with other TiddlyWiki components.

Understanding these module types and their standards is crucial for extending and customizing TiddlyWiki effectively. Each module type has a specific role and follows conventions that align with TiddlyWiki’s flexible and modular design philosophy.

Another update on my Journey to leverage ChatGPT for tiddlywiki.

Just now I created an SVG image to see if I could then use parameters to populate its labels, thus one could use it as an element in a presentation or provide links to corosponding lists or tiddlers.

I have started building a custom ChatGPT for tiddlywiki as a result of seeing someone elses attempt https://chat.openai.com/g/g-sHnokUbgB-tiddlywiki-guide.

  • Still it is not yet able to write complete JavaScript modules for me yet, although it has a go.
  • If you give it a modual you can get good advice to add something to it.
2 Likes

Over here Organizing computer data files and matching to TiddlyWiki - #16 by TW_Tones we are clasifying and naming images with GatGPT. The resulting text can be placed with the image to aid search

1 Like

I recently started playing around with Faraday.dev, I find it rather slow and buggy, but I think that’s mainly due to the fact I am running it on a Late 2014 Mac mini. There’s also Poe and you.com I have been using. I think some of the terms with ChatGPT are rather confusing to understand, so I really suggest starting with Faraday, as that might be a better way if you are interested in training the model with your own data. However that approach is rather slow so that’s where it might be worth it to pay for a subscription.

Today I wanted to edit the tiddlywiki Home icon to contain a H inside the house.

So I gave ChatGPT the current Home image svg and asked it to place a letter inside it. After I worked out the size of the text needed to be larger, even if the button as a whole is smaller, I go a working image.

Snag_32a19edd

As a result I created this button, which opens the tiddler named in a config tiddler, rather than close all and default tiddlers. Defaults to Home

It is easy to edit the image and use another letter if you want.

home-tiddler.json (2.3 KB)

3 Likes