+\end importer
+
+<%if [type[application/json]] %>
+ <$let json={{{ [get[text]] }}} >
+ <%if [jsontype[]match[array]] %>
+ <$let
+ numberOfConversations={{{ [jsonindexes[]count[]] }}}
+ json={{{ [jsonextract[0]] }}}
+ >
+ <%if [jsontype[]match[object]] %>
+ <%if
+ [jsontype[title]match[string]]
+ :and[jsontype[create_time]match[number]]
+ :and[jsontype[update_time]match[number]]
+ :and[jsontype[mapping]match[object]]
+ :and[jsontype[id]match[string]]
+ %>
+ <>
+ <%endif%>
+ <%endif%>
+ $let>
+ <%endif%>
+ $let>
+<%endif%>
+
From a92103456179322d1629802cf238ac94c417d7c4 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Sun, 14 Jul 2024 21:27:52 +0100
Subject: [PATCH 06/25] Improved spinner colours
---
plugins/tiddlywiki/ai-tools/styles.tid | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/styles.tid b/plugins/tiddlywiki/ai-tools/styles.tid
index 7caea5f0e..e65012b7e 100644
--- a/plugins/tiddlywiki/ai-tools/styles.tid
+++ b/plugins/tiddlywiki/ai-tools/styles.tid
@@ -156,15 +156,15 @@ tags: [[$:/tags/Stylesheet]]
.ai-request-spinner:before {
animation: ai-request-spinner-animation-ball1 1s infinite;
- background-color: #ddffdd;
- box-shadow: 30px 0 0 #90a690;
+ background-color: #9c9ab0;
+ box-shadow: 30px 0 0 #fefdff;
margin-bottom: 10px;
}
.ai-request-spinner:after {
animation: ai-request-spinner-animation-ball2 1s infinite;
- background-color: #90a690;
- box-shadow: 30px 0 0 #ddffdd;
+ background-color: #fefdff;
+ box-shadow: 30px 0 0 #9c9ab0;
}
@keyframes ai-request-spinner-animation-rotate {
@@ -175,30 +175,30 @@ tags: [[$:/tags/Stylesheet]]
@keyframes ai-request-spinner-animation-ball1 {
0% {
- box-shadow: 30px 0 0 #90a690;
+ box-shadow: 30px 0 0 #fefdff;
}
50% {
- box-shadow: 0 0 0 #90a690;
+ box-shadow: 0 0 0 #fefdff;
margin-bottom: 0;
transform: translate(15px, 15px);
}
100% {
- box-shadow: 30px 0 0 #90a690;
+ box-shadow: 30px 0 0 #fefdff;
margin-bottom: 10px;
}
}
@keyframes ai-request-spinner-animation-ball2 {
0% {
- box-shadow: 30px 0 0 #ddffdd;
+ box-shadow: 30px 0 0 #9c9ab0;
}
50% {
- box-shadow: 0 0 0 #ddffdd;
+ box-shadow: 0 0 0 #9c9ab0;
margin-top: -20px;
transform: translate(15px, 15px);
}
100% {
- box-shadow: 30px 0 0 #ddffdd;
+ box-shadow: 30px 0 0 #9c9ab0;
margin-top: 0;
}
}
\ No newline at end of file
From a1782b1e4eb43b4c83b95c46adedbe8bee38a262 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Tue, 16 Jul 2024 19:41:44 +0100
Subject: [PATCH 07/25] Palette fixes
---
plugins/tiddlywiki/ai-tools/styles.tid | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/plugins/tiddlywiki/ai-tools/styles.tid b/plugins/tiddlywiki/ai-tools/styles.tid
index e65012b7e..5163d1593 100644
--- a/plugins/tiddlywiki/ai-tools/styles.tid
+++ b/plugins/tiddlywiki/ai-tools/styles.tid
@@ -100,6 +100,11 @@ tags: [[$:/tags/Stylesheet]]
gap: 1em;
}
+.ai-conversation .ai-user-prompt-text textarea {
+ color: #000;
+ background: #fff;
+}
+
.ai-conversation .ai-user-prompt button.ai-user-prompt-send {
background-color: initial;
background-image: linear-gradient(-180deg, #e0c3ce, #963057);
@@ -137,6 +142,11 @@ tags: [[$:/tags/Stylesheet]]
margin: 0;
}
+.ai-conversation .ai-user-prompt .ai-user-prompt-image button {
+ color: #000;
+ fill: #000;
+}
+
.ai-request-spinner {
animation: ai-request-spinner-animation-rotate 1s infinite;
height: 50px;
From 837374b5ab08b6a7aa5629add4b8782a8f8c78b0 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Thu, 18 Jul 2024 08:39:03 +0100
Subject: [PATCH 08/25] Don't try to parse plugins as conversations
---
plugins/tiddlywiki/ai-tools/tools.tid | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/tiddlywiki/ai-tools/tools.tid b/plugins/tiddlywiki/ai-tools/tools.tid
index c91a1de8f..0512ea218 100644
--- a/plugins/tiddlywiki/ai-tools/tools.tid
+++ b/plugins/tiddlywiki/ai-tools/tools.tid
@@ -4,7 +4,7 @@ title: $:/plugins/tiddlywiki/ai-tools/tools
Any tiddlers containing ~ChatGPT exported `conversation.json` files will be shown here for import.
-<$list filter="[all[tiddlers+shadows]type[application/json]sort[title]]" template="$:/plugins/tiddlywiki/ai-tools/view-templates/imported-conversations-json"/>
+<$list filter="[all[tiddlers+shadows]type[application/json]!has[plugin-type]sort[title]]" template="$:/plugins/tiddlywiki/ai-tools/view-templates/imported-conversations-json"/>
! Loaded Conversations
From a2cff69feef233f62446a3a3aa2d52ed4dba187f Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Thu, 18 Jul 2024 09:24:37 +0100
Subject: [PATCH 09/25] Update docs
---
plugins/tiddlywiki/ai-tools/docs.tid | 25 ++++++++++++++++++++++++
plugins/tiddlywiki/ai-tools/readme.tid | 7 -------
plugins/tiddlywiki/ai-tools/settings.tid | 13 ++++++++++--
3 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/docs.tid b/plugins/tiddlywiki/ai-tools/docs.tid
index 103c1e92a..9ae9ec7a7 100644
--- a/plugins/tiddlywiki/ai-tools/docs.tid
+++ b/plugins/tiddlywiki/ai-tools/docs.tid
@@ -1,2 +1,27 @@
title: $:/plugins/tiddlywiki/ai-tools/docs
+!! Setting Up
+
+See the ''settings'' tab for set up instructions.
+
+!! Live AI Conversations in ~TiddlyWiki
+
+# Click the {{||$:/plugins/tiddlywiki/ai-tools/page-menu}} icon in the sidebar to open a new conversation
+# Choose the server from the dropdown:
+#* ''Locally running Llamafile server'' - LLlamafile is an open source project that lets you distribute and run LLMs as a single file. The files are large, typically 4+ gigabytes but offer reasonable performance on modern hardware, and total privacy
+#* ''~OpenAI Service'' - ~OpenAI is a commercial service that offers paid APIs for accessing some of the most sophisticated LLMs that are available. ~OpenAI requires tokens to be purchased for API usage (this is entirely separate from ~ChatGPT subscriptions)
+# Type a prompt for the LLM in the text box
+#* If using ~OpenAI it is possible to attach a single image to a prompt
+# Click "Send" and wait for the output of the LLM
+
+!! Import ~ChatGPT Conversation Archives
+
+# [[Follow the instructions|https://help.openai.com/en/articles/7260999-how-do-i-export-my-chatgpt-history-and-data]] to request an export of your ~ChatGPT data
+# You will receive a link to download your data as a ZIP file
+# Download and unzip the file
+# Locate the file `conversations.json` within the archive and import it into your TiddlyWiki
+# Visit the ''tools'' tab and locate your `conversations.json` tiddler
+# Click the associated ''import'' button
+# See the imported conversations listed in the ''tools'' tab
+# The imported tiddler `conversations.json` is no longer required and can be deleted
+
diff --git a/plugins/tiddlywiki/ai-tools/readme.tid b/plugins/tiddlywiki/ai-tools/readme.tid
index d29b75ea9..edaa1d844 100644
--- a/plugins/tiddlywiki/ai-tools/readme.tid
+++ b/plugins/tiddlywiki/ai-tools/readme.tid
@@ -4,10 +4,3 @@ title: $:/plugins/tiddlywiki/ai-tools/readme
This plugin adds integrated LLM conversations to the TiddlyWiki platform.
-# Click the {{||$:/plugins/tiddlywiki/ai-tools/page-menu}} icon in the sidebar to open a new conversation
-# Choose the server from the dropdown:
-#* ''Locally running Llamafile server'' - LLlamafile is an open source project that lets you distribute and run LLMs as a single file. The files are large, typically 4+ gigabytes but offer reasonable performance on modern hardware, and total privacy
-#* ''~OpenAI Service'' - ~OpenAI is a commercial service that offers paid APIs for accessing some of the most sophisticated LLMs that are available. ~OpenAI requires tokens to be purchased for API usage (this is entirely separate from ~ChatGPT subscriptions)
-# Type a prompt for the LLM in the text box
-#* If using ~OpenAI it is possible to attach a single image to a prompt
-# Click "Send" and wait for the output of the LLM
diff --git a/plugins/tiddlywiki/ai-tools/settings.tid b/plugins/tiddlywiki/ai-tools/settings.tid
index ce35c72cb..fa18296c9 100644
--- a/plugins/tiddlywiki/ai-tools/settings.tid
+++ b/plugins/tiddlywiki/ai-tools/settings.tid
@@ -2,10 +2,10 @@ title: $:/plugins/tiddlywiki/ai-tools/settings
! AI Tools Settings
-This plugin runs entirely in the browser, with no backend server component. A consequence of this design is that the API keys required to access external services must be obtained by the end user. These keys are stored in the browser and so only need to be set up once.
-
!! ~OpenAI API key
+This plugin runs entirely in the browser, with no backend server component. A consequence of this design is that the API keys required to access external services must be obtained by the end user. These keys are stored in the browser and so only need to be set up once.
+
# Register for an account at https://platform.openai.com/
#* Newly registered accounts can claim a small amount of credit, thereafter payment is needed
#* Note that ~OpenAI run completely different payment systems for ~ChatGPT and the API platform. Even if you are already a subscriber to ~ChatGPT you will still need to pay for API usage after the initial free service
@@ -14,3 +14,12 @@ This plugin runs entirely in the browser, with no backend server component. A co
~OpenAI Secret API Key: <$password name="openai-secret-key"/>
+!! Llamafile Setup
+
+[[Llamafile|https://github.com/Mozilla-Ocho/llamafile]] lets you download and run LLMs as a single file. See the [[announcment blog post|https://hacks.mozilla.org/2023/11/introducing-llamafile/]] for background.
+
+1. Download and run Llamafile as [[described in the QuickStart guide|https://github.com/Mozilla-Ocho/llamafile?tab=readme-ov-file#quickstart]]
+2. Visit http://127.0.0.1:8080 in a browser and verify that you can see the Llamafile interface. You can also try it out here
+3. Return to AI Tools and start a conversation, specifying Llamafile as the server
+
+
From d56958331b2b3d3f495e689ef48712f6f694eb63 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Thu, 18 Jul 2024 09:49:33 +0100
Subject: [PATCH 10/25] Docs tweaks
---
plugins/tiddlywiki/ai-tools/docs.tid | 4 ++--
plugins/tiddlywiki/ai-tools/readme.tid | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/docs.tid b/plugins/tiddlywiki/ai-tools/docs.tid
index 9ae9ec7a7..3f3e3bbcf 100644
--- a/plugins/tiddlywiki/ai-tools/docs.tid
+++ b/plugins/tiddlywiki/ai-tools/docs.tid
@@ -8,8 +8,8 @@ See the ''settings'' tab for set up instructions.
# Click the {{||$:/plugins/tiddlywiki/ai-tools/page-menu}} icon in the sidebar to open a new conversation
# Choose the server from the dropdown:
-#* ''Locally running Llamafile server'' - LLlamafile is an open source project that lets you distribute and run LLMs as a single file. The files are large, typically 4+ gigabytes but offer reasonable performance on modern hardware, and total privacy
-#* ''~OpenAI Service'' - ~OpenAI is a commercial service that offers paid APIs for accessing some of the most sophisticated LLMs that are available. ~OpenAI requires tokens to be purchased for API usage (this is entirely separate from ~ChatGPT subscriptions)
+#* ''Locally running Llamafile server''
+#* ''~OpenAI Service'' (requires API key to be specified in ''settings'')
# Type a prompt for the LLM in the text box
#* If using ~OpenAI it is possible to attach a single image to a prompt
# Click "Send" and wait for the output of the LLM
diff --git a/plugins/tiddlywiki/ai-tools/readme.tid b/plugins/tiddlywiki/ai-tools/readme.tid
index edaa1d844..747d03a6d 100644
--- a/plugins/tiddlywiki/ai-tools/readme.tid
+++ b/plugins/tiddlywiki/ai-tools/readme.tid
@@ -4,3 +4,9 @@ title: $:/plugins/tiddlywiki/ai-tools/readme
This plugin adds integrated LLM conversations to the TiddlyWiki platform.
+The plugin allows live conversations within TiddlyWiki and also importing ~ChatGPT conversation archives.
+
+The plugin supports two options for the LLM server:
+
+* ''Locally running Llamafile server'' - LLlamafile is an open source project that lets you distribute and run LLMs as a single file. The files are large, typically 4+ gigabytes but offer reasonable performance on modern hardware, and total privacy
+* ''~OpenAI Service'' - ~OpenAI is a commercial service that offers paid APIs for accessing some of the most sophisticated LLMs that are available. ~OpenAI requires tokens to be purchased for API usage (this is entirely separate from ~ChatGPT subscriptions)
From 638bd78059fc245013aa5eb3fdd92a9eb4fb3af9 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Thu, 18 Jul 2024 09:52:24 +0100
Subject: [PATCH 11/25] Formatting typo
---
plugins/tiddlywiki/ai-tools/settings.tid | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/settings.tid b/plugins/tiddlywiki/ai-tools/settings.tid
index fa18296c9..8f2567560 100644
--- a/plugins/tiddlywiki/ai-tools/settings.tid
+++ b/plugins/tiddlywiki/ai-tools/settings.tid
@@ -18,8 +18,6 @@ This plugin runs entirely in the browser, with no backend server component. A co
[[Llamafile|https://github.com/Mozilla-Ocho/llamafile]] lets you download and run LLMs as a single file. See the [[announcment blog post|https://hacks.mozilla.org/2023/11/introducing-llamafile/]] for background.
-1. Download and run Llamafile as [[described in the QuickStart guide|https://github.com/Mozilla-Ocho/llamafile?tab=readme-ov-file#quickstart]]
-2. Visit http://127.0.0.1:8080 in a browser and verify that you can see the Llamafile interface. You can also try it out here
-3. Return to AI Tools and start a conversation, specifying Llamafile as the server
-
-
+# Download and run Llamafile as [[described in the QuickStart guide|https://github.com/Mozilla-Ocho/llamafile?tab=readme-ov-file#quickstart]]
+# Visit http://127.0.0.1:8080 in a browser and verify that you can see the Llamafile interface. You can also try it out here
+# Return to AI Tools and start a conversation, specifying Llamafile as the server
From 0e5955397b40c9d320daa327a260c74f30a9b899 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Fri, 19 Jul 2024 14:51:18 +0100
Subject: [PATCH 12/25] Give conversation tiddlers a dummy text field
To avoid triggering a docs template
---
.../ai-tools/modules/conversations-archive-importer.js | 3 ++-
plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/plugins/tiddlywiki/ai-tools/modules/conversations-archive-importer.js b/plugins/tiddlywiki/ai-tools/modules/conversations-archive-importer.js
index 22b2cb1bd..72dd879d2 100644
--- a/plugins/tiddlywiki/ai-tools/modules/conversations-archive-importer.js
+++ b/plugins/tiddlywiki/ai-tools/modules/conversations-archive-importer.js
@@ -27,7 +27,8 @@ ConversationsArchiveImporter.prototype.import = function(widget,conversationsTit
title: conversationTitle,
tags: $tw.utils.stringifyList(["$:/tags/AI/Conversation"]),
created: conversationCreated,
- modified: conversationModified
+ modified: conversationModified,
+ text: "."
};
tiddlers.push(conversationFields);
var messageIndex = 1;
diff --git a/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid b/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
index 1c0738039..c58bcced7 100644
--- a/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
+++ b/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
@@ -7,6 +7,7 @@ tags: $:/tags/AI/PageMenu
tags="$:/tags/AI/Conversation"
system-prompt="You are a helpful assistant."
current-response-text="Please list the 10 most important mechanical inventions of the Twentieth Century"
+ text="."
>
<$action-navigate $to=<>/>
$action-createtiddler>
From 0037935af59026d67054cd71e89d362d3ae5f344 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Sun, 21 Jul 2024 15:48:33 +0100
Subject: [PATCH 13/25] Revert "Give conversation tiddlers a dummy text field"
This reverts commit 0e5955397b40c9d320daa327a260c74f30a9b899.
---
.../ai-tools/modules/conversations-archive-importer.js | 3 +--
plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid | 1 -
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/modules/conversations-archive-importer.js b/plugins/tiddlywiki/ai-tools/modules/conversations-archive-importer.js
index 72dd879d2..22b2cb1bd 100644
--- a/plugins/tiddlywiki/ai-tools/modules/conversations-archive-importer.js
+++ b/plugins/tiddlywiki/ai-tools/modules/conversations-archive-importer.js
@@ -27,8 +27,7 @@ ConversationsArchiveImporter.prototype.import = function(widget,conversationsTit
title: conversationTitle,
tags: $tw.utils.stringifyList(["$:/tags/AI/Conversation"]),
created: conversationCreated,
- modified: conversationModified,
- text: "."
+ modified: conversationModified
};
tiddlers.push(conversationFields);
var messageIndex = 1;
diff --git a/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid b/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
index c58bcced7..1c0738039 100644
--- a/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
+++ b/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
@@ -7,7 +7,6 @@ tags: $:/tags/AI/PageMenu
tags="$:/tags/AI/Conversation"
system-prompt="You are a helpful assistant."
current-response-text="Please list the 10 most important mechanical inventions of the Twentieth Century"
- text="."
>
<$action-navigate $to=<>/>
$action-createtiddler>
From 3bdd449b3e4ab70eb7f02f9ae9cb5dab09b4b5c7 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Sun, 21 Jul 2024 16:11:46 +0100
Subject: [PATCH 14/25] Don't hardcode the API route
---
plugins/tiddlywiki/ai-tools/globals.tid | 2 +-
plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid | 2 +-
plugins/tiddlywiki/ai-tools/servers/openai.tid | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/globals.tid b/plugins/tiddlywiki/ai-tools/globals.tid
index b3d2fc550..87f18cfbc 100644
--- a/plugins/tiddlywiki/ai-tools/globals.tid
+++ b/plugins/tiddlywiki/ai-tools/globals.tid
@@ -47,7 +47,7 @@ completionServer - Optional URL of server
<$action-log/>
<$action-sendmessage
$message="tm-http-request"
- url={{{ [get[url]addsuffix[/v1/chat/completions]] }}}
+ url={{{ [get[url]] }}}
body=<>
header-content-type="application/json"
bearer-auth-token-from-store="openai-secret-key"
diff --git a/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid b/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
index 4348507d6..7ab2b11fb 100644
--- a/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
+++ b/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
@@ -1,6 +1,6 @@
title: $:/plugins/tiddlywiki/ai-tools/servers/local-llamafile
tags: $:/tags/AI/CompletionServer
-url: http://127.0.0.1:8080
+url: http://127.0.0.1:8080/v1/chat/completions
caption: Locally running Llamafile server
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline html conditional commentblock commentinline
diff --git a/plugins/tiddlywiki/ai-tools/servers/openai.tid b/plugins/tiddlywiki/ai-tools/servers/openai.tid
index ae9c19a03..c1bef5a7d 100644
--- a/plugins/tiddlywiki/ai-tools/servers/openai.tid
+++ b/plugins/tiddlywiki/ai-tools/servers/openai.tid
@@ -1,6 +1,6 @@
title: $:/plugins/tiddlywiki/ai-tools/servers/openai
tags: $:/tags/AI/CompletionServer
-url: https://api.openai.com
+url: https://api.openai.com/v1/chat/completions
caption: OpenAI Service
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline html conditional commentblock commentinline
From fb641d340c3b1ebdb3791a61023d94c75deb3e41 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Sun, 21 Jul 2024 16:50:55 +0100
Subject: [PATCH 15/25] Fix an annoying little bug that prevents
importvariables being used inside action-createtiddler in action strings
The root cause was that action-createtiddler widget was calling refreshChildren() with no argument.
A secondary factor was that importvariables widget was not defensive in handling a missing changedTiddlers parameter
---
core/modules/widgets/action-createtiddler.js | 2 +-
core/modules/widgets/importvariables.js | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/core/modules/widgets/action-createtiddler.js b/core/modules/widgets/action-createtiddler.js
index b49eaad20..4b883d0c3 100644
--- a/core/modules/widgets/action-createtiddler.js
+++ b/core/modules/widgets/action-createtiddler.js
@@ -104,7 +104,7 @@ CreateTiddlerWidget.prototype.invokeAction = function(triggeringWidget,event) {
}
this.setVariable("createTiddler-title",title);
this.setVariable("createTiddler-draftTitle",draftTitle);
- this.refreshChildren();
+ this.refreshChildren([]);
return true; // Action was invoked
};
diff --git a/core/modules/widgets/importvariables.js b/core/modules/widgets/importvariables.js
index 3e1ac3fc6..e394853a8 100644
--- a/core/modules/widgets/importvariables.js
+++ b/core/modules/widgets/importvariables.js
@@ -107,6 +107,7 @@ ImportVariablesWidget.prototype.execute = function(tiddlerList) {
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/
ImportVariablesWidget.prototype.refresh = function(changedTiddlers) {
+ changedTiddlers = changedTiddlers || {};
// Recompute our attributes and the filter list
var changedAttributes = this.computeAttributes(),
tiddlerList = this.wiki.filterTiddlers(this.getAttribute("filter"),this);
From 370ff3057ee859318c7fc6f688e9c94d68d535d7 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Sun, 21 Jul 2024 16:51:19 +0100
Subject: [PATCH 16/25] Refactor completion servers so that they handle their
own response
---
plugins/tiddlywiki/ai-tools/globals.tid | 59 ++++++-------------
.../ai-tools/servers/local-llamafile.tid | 32 +++++++++-
.../tiddlywiki/ai-tools/servers/openai.tid | 32 +++++++++-
3 files changed, 80 insertions(+), 43 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/globals.tid b/plugins/tiddlywiki/ai-tools/globals.tid
index 87f18cfbc..85fa33b4d 100644
--- a/plugins/tiddlywiki/ai-tools/globals.tid
+++ b/plugins/tiddlywiki/ai-tools/globals.tid
@@ -14,49 +14,26 @@ statusTitle - Optional title of a tiddler to which the status of the request wil
completionServer - Optional URL of server
-->
\procedure get-llm-completion(conversationTitle,resultTitlePrefix,resultTags,statusTitle,completionServer)
-
- \procedure get-llm-completion-callback()
- <%if [compare:number:gteq[200]compare:number:lteq[299]] %>
-
- <$action-createtiddler
- $basetitle=<>
- tags=<>
- type="text/markdown"
- role={{{ [jsonget[choices],[0],[message],[role]] }}}
- text={{{ [jsonget[choices],[0],[message],[content]] }}}
- />
- <%else%>
-
- <$action-createtiddler
- $basetitle=<>
- tags=<>
- type="text/markdown"
- role="error"
- text={{{ [[Error:]] [] [jsonget[error],[message]] +[join[]] }}}
- />
- <%endif%>
- \end get-llm-completion-callback
-
<$let
completionServer={{{ [!is[blank]else] }}}
>
- <$wikify name="json" text={{{ [get[text]] }}}>
- <$action-log message="get-llm-completion"/>
- <$action-log/>
- <$action-sendmessage
- $message="tm-http-request"
- url={{{ [get[url]] }}}
- body=<>
- header-content-type="application/json"
- bearer-auth-token-from-store="openai-secret-key"
- method="POST"
- oncompletion=<>
- bind-status=<>
- var-resultTitlePrefix=<>
- var-resultTags=<>
- />
- $wikify>
+ <$importvariables filter="[]">
+ <$wikify name="json" text=<>>
+ <$action-log message="get-llm-completion"/>
+ <$action-log/>
+ <$action-sendmessage
+ $message="tm-http-request"
+ url={{{ [get[url]] }}}
+ body=<>
+ header-content-type="application/json"
+ bearer-auth-token-from-store="openai-secret-key"
+ method="POST"
+ oncompletion=<>
+ bind-status=<>
+ var-resultTitlePrefix=<>
+ var-resultTags=<>
+ />
+ $wikify>
+ $importvariables>
$let>
\end get-llm-completion
diff --git a/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid b/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
index 7ab2b11fb..15ba04e92 100644
--- a/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
+++ b/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
@@ -3,6 +3,10 @@ tags: $:/tags/AI/CompletionServer
url: http://127.0.0.1:8080/v1/chat/completions
caption: Locally running Llamafile server
+
+\procedure json-prompt()
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline html conditional commentblock commentinline
{
"model": "gpt-4o",
@@ -21,4 +25,30 @@ caption: Locally running Llamafile server
}
$list>
]
-}
\ No newline at end of file
+}
+\end json-prompt
+
+
+\procedure completion-callback()
+ <%if [compare:number:gteq[200]compare:number:lteq[299]] %>
+
+ <$action-createtiddler
+ $basetitle=<>
+ tags=<>
+ type="text/markdown"
+ role={{{ [jsonget[choices],[0],[message],[role]] }}}
+ text={{{ [jsonget[choices],[0],[message],[content]] }}}
+ />
+ <%else%>
+
+ <$action-createtiddler
+ $basetitle=<>
+ tags=<>
+ type="text/markdown"
+ role="error"
+ text={{{ [[Error:]] [] [jsonget[error],[message]] +[join[]] }}}
+ />
+ <%endif%>
+\end completion-callback
diff --git a/plugins/tiddlywiki/ai-tools/servers/openai.tid b/plugins/tiddlywiki/ai-tools/servers/openai.tid
index c1bef5a7d..65ee9429a 100644
--- a/plugins/tiddlywiki/ai-tools/servers/openai.tid
+++ b/plugins/tiddlywiki/ai-tools/servers/openai.tid
@@ -3,6 +3,10 @@ tags: $:/tags/AI/CompletionServer
url: https://api.openai.com/v1/chat/completions
caption: OpenAI Service
+
+\procedure json-prompt()
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline html conditional commentblock commentinline
{
"model": "gpt-4o",
@@ -36,4 +40,30 @@ caption: OpenAI Service
}
$list>
]
-}
\ No newline at end of file
+}
+\end json-prompt
+
+
+\procedure completion-callback()
+ <%if [compare:number:gteq[200]compare:number:lteq[299]] %>
+
+ <$action-createtiddler
+ $basetitle=<>
+ tags=<>
+ type="text/markdown"
+ role={{{ [jsonget[choices],[0],[message],[role]] }}}
+ text={{{ [jsonget[choices],[0],[message],[content]] }}}
+ />
+ <%else%>
+
+ <$action-createtiddler
+ $basetitle=<>
+ tags=<>
+ type="text/markdown"
+ role="error"
+ text={{{ [[Error:]] [] [jsonget[error],[message]] +[join[]] }}}
+ />
+ <%endif%>
+\end completion-callback
From 4a79af9eea9d88ef9cb9b40a58055baca5e0288d Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Sun, 21 Jul 2024 19:34:25 +0100
Subject: [PATCH 17/25] Revise default system prompt
---
plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid b/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
index 1c0738039..18420f119 100644
--- a/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
+++ b/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
@@ -5,7 +5,7 @@ tags: $:/tags/AI/PageMenu
<$action-createtiddler
$basetitle="AI Conversation"
tags="$:/tags/AI/Conversation"
- system-prompt="You are a helpful assistant."
+ system-prompt="Transcript of a never ending dialog, where the User interacts with an Assistant. The Assistant is helpful, kind, honest, good at writing, and never fails to answer the User's requests immediately and with precision."
current-response-text="Please list the 10 most important mechanical inventions of the Twentieth Century"
>
<$action-navigate $to=<>/>
From 80fdaae6dee6ce60c31132e0b2e838cf3100300a Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Sun, 21 Jul 2024 21:08:42 +0100
Subject: [PATCH 18/25] Llamafile use native /completion API endpoint
So that we can do image analysis
---
.../ai-tools/servers/local-llamafile.tid | 67 ++++++++++++++-----
1 file changed, 49 insertions(+), 18 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid b/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
index 15ba04e92..1a6f78b93 100644
--- a/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
+++ b/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
@@ -1,6 +1,6 @@
title: $:/plugins/tiddlywiki/ai-tools/servers/local-llamafile
tags: $:/tags/AI/CompletionServer
-url: http://127.0.0.1:8080/v1/chat/completions
+url: http://127.0.0.1:8080/completion
caption: Locally running Llamafile server
- <$list filter="[all[shadows+tiddlers]tag!is[draft]sort[created]]">
- ,
- {
-
- "role": "<$text text={{{ [get[role]jsonstringify[]] }}}/>",
- "content": "<$text text={{{ [get[text]jsonstringify[]] }}}/>"
- }
+ "image_data": [
+ <$list filter="[all[shadows+tiddlers]tag!is[draft]sort[created]]" counter="counter">
+ <%if [has[image]] %>
+ <%if [!match[yes]] %>,<%endif%>
+ {
+ "id": <$text text=<>/>,
+ "data": "<$text text={{{ [get[image]get[text]jsonstringify[]] +[join[]] }}}/>"
+ }
+ <%endif%>
$list>
- ]
+ ],
+ "prompt": "<>",
+ "cache_prompt": false,
+ "frequency_penalty": 0,
+ "grammar": "",
+ "mirostat_eta": 0.1,
+ "mirostat_tau": 5,
+ "mirostat": 0,
+ "n_predict": 400,
+ "n_probs": 0,
+ "presence_penalty": 0,
+ "repeat_last_n": 256,
+ "repeat_penalty": 1.18,
+ "slot_id": -1,
+ "stop": ["", "Llama:", "User:"],
+ "stream" : false,
+ "temperature": 0.7,
+ "tfs_z": 1,
+ "top_k": 40,
+ "top_p": 0.5,
+ "typical_p": 1
}
\end json-prompt
+\procedure json-prompt-text()
+\whitespace trim
+\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline html conditional commentblock commentinline
+<$text text={{{ [get[system-prompt]jsonstringify[]] }}}/>
+\n
+<$list filter="[all[shadows+tiddlers]tag!is[draft]sort[created]]" counter="counter">
+\n
+<$text text={{{ [get[role]else[user]match[user]then[User:]else[Llama:]] }}}/>
+<%if [has[image]] %>
+[img-<$text text=<>/>]
+<%endif%>
+<$text text={{{ [get[text]jsonstringify[]] }}}/>
+$list>
+\nLlama:
+\end json-prompt-text
+
@@ -38,8 +69,8 @@ Callback for the HTTP response from the LLM
$basetitle=<>
tags=<>
type="text/markdown"
- role={{{ [jsonget[choices],[0],[message],[role]] }}}
- text={{{ [jsonget[choices],[0],[message],[content]] }}}
+ role="assistant"
+ text={{{ [jsonget[content]] }}}
/>
<%else%>
From cd58622c06d66e336428eac150b4fe0db34e6d8c Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Wed, 24 Jul 2024 22:28:30 +0100
Subject: [PATCH 19/25] Clarify that the Llamafile prompt is for Llava models
---
.../servers/{local-llamafile.tid => llamafile-llava.tid} | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
rename plugins/tiddlywiki/ai-tools/servers/{local-llamafile.tid => llamafile-llava.tid} (95%)
diff --git a/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid b/plugins/tiddlywiki/ai-tools/servers/llamafile-llava.tid
similarity index 95%
rename from plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
rename to plugins/tiddlywiki/ai-tools/servers/llamafile-llava.tid
index 1a6f78b93..1334bea86 100644
--- a/plugins/tiddlywiki/ai-tools/servers/local-llamafile.tid
+++ b/plugins/tiddlywiki/ai-tools/servers/llamafile-llava.tid
@@ -1,7 +1,7 @@
-title: $:/plugins/tiddlywiki/ai-tools/servers/local-llamafile
+title: $:/plugins/tiddlywiki/ai-tools/servers/llamafile-llava
tags: $:/tags/AI/CompletionServer
url: http://127.0.0.1:8080/completion
-caption: Locally running Llamafile server
+caption: Local Llamafile server running LLaVA models
-\procedure get-llm-completion(conversationTitle,resultTitlePrefix,resultTags,statusTitle,completionServer)
+\procedure ai-tools-get-llm-completion(conversationTitle,resultTitlePrefix,resultTags,ai-tools-status-title,completionServer)
<$let
- completionServer={{{ [!is[blank]else] }}}
+ completionServer={{{ [!is[blank]else] }}}
>
<$importvariables filter="[]">
<$wikify name="json" text=<>>
- <$action-log message="get-llm-completion"/>
+ <$action-log message="ai-tools-get-llm-completion"/>
<$action-log/>
<$action-sendmessage
$message="tm-http-request"
@@ -29,11 +29,176 @@ completionServer - Optional URL of server
bearer-auth-token-from-store="openai-secret-key"
method="POST"
oncompletion=<>
- bind-status=<>
+ bind-status=<>
var-resultTitlePrefix=<>
var-resultTags=<>
/>
$wikify>
$importvariables>
$let>
-\end get-llm-completion
+\end ai-tools-get-llm-completion
+
+
+\function ai-tools-status-title()
+[addprefix[$:/temp/ai-tools/status/]]
+\end ai-tools-status-title
+
+
+\procedure ai-tools-message(tiddler,field,role,makeLink:"yes")
+<$qualify
+ name="state"
+ title={{{ [[$:/state/ai-tools-message-state/]addsuffix] }}}
+>
+ <$let
+ editStateTiddler={{{ [addsuffix[-edit-state]] }}}
+ editState={{{ [get[text]else[view]] }}}
+ >
+
-
+<$transclude
+ $variable="ai-tools-conversation"
+ $mode="block"
+ conversationTitle=<>
+/>
<%endif%>
From 422df108414ce4e92c802868def0cbf624bbce6f Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Mon, 5 Aug 2024 16:33:07 +0100
Subject: [PATCH 22/25] Fix ChatGPT import
---
plugins/tiddlywiki/ai-tools/globals.tid | 17 ++++++++-
.../ai-tools/page-menu/import-chatgpt.tid | 6 ++++
.../ai-tools/page-menu/new-conversation.tid | 13 +------
plugins/tiddlywiki/ai-tools/styles.tid | 11 ++++++
plugins/tiddlywiki/ai-tools/tools.tid | 35 +++++++++++++++----
5 files changed, 63 insertions(+), 19 deletions(-)
create mode 100644 plugins/tiddlywiki/ai-tools/page-menu/import-chatgpt.tid
diff --git a/plugins/tiddlywiki/ai-tools/globals.tid b/plugins/tiddlywiki/ai-tools/globals.tid
index 87d3b5b46..e6436913d 100644
--- a/plugins/tiddlywiki/ai-tools/globals.tid
+++ b/plugins/tiddlywiki/ai-tools/globals.tid
@@ -201,4 +201,19 @@ Action procedure to get the next response from the LLM
$let>
-\end ai-tools-conversation
\ No newline at end of file
+\end ai-tools-conversation
+
+\procedure ai-tools-new-conversation()
+<$action-createtiddler
+ $basetitle="AI Conversation"
+ tags="$:/tags/AI/Conversation"
+ system-prompt="Transcript of a never ending dialog, where the User interacts with an Assistant. The Assistant is helpful, kind, honest, good at writing, and never fails to answer the User's requests immediately and with precision."
+ current-response-text="Please list the 10 most important mechanical inventions of the Twentieth Century"
+>
+<$action-navigate $to=<>/>
+$action-createtiddler>
+\end ai-tools-new-conversation
+
+\procedure ai-tools-import-conversations()
+<$action-navigate $to="$:/plugins/tiddlywiki/ai-tools/tools"/>
+\end ai-tools-import-conversations
diff --git a/plugins/tiddlywiki/ai-tools/page-menu/import-chatgpt.tid b/plugins/tiddlywiki/ai-tools/page-menu/import-chatgpt.tid
new file mode 100644
index 000000000..fbbea8a01
--- /dev/null
+++ b/plugins/tiddlywiki/ai-tools/page-menu/import-chatgpt.tid
@@ -0,0 +1,6 @@
+title: $:/plugins/tiddlywiki/ai-tools/page-menu/import-chatgpt
+tags: $:/tags/AI/PageMenu
+
+<$button actions=<> class="tc-btn-invisible">
+{{$:/core/images/input-button}} Import Conversations from ~ChatGPT
+$button>
diff --git a/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid b/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
index 18420f119..5e7f31173 100644
--- a/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
+++ b/plugins/tiddlywiki/ai-tools/page-menu/new-conversation.tid
@@ -1,17 +1,6 @@
title: $:/plugins/tiddlywiki/ai-tools/page-menu/new-conversation
tags: $:/tags/AI/PageMenu
-\define actions()
-<$action-createtiddler
- $basetitle="AI Conversation"
- tags="$:/tags/AI/Conversation"
- system-prompt="Transcript of a never ending dialog, where the User interacts with an Assistant. The Assistant is helpful, kind, honest, good at writing, and never fails to answer the User's requests immediately and with precision."
- current-response-text="Please list the 10 most important mechanical inventions of the Twentieth Century"
->
-<$action-navigate $to=<>/>
-$action-createtiddler>
-\end actions
-
-<$button actions=<> class="tc-btn-invisible">
+<$button actions=<> class="tc-btn-invisible">
{{$:/core/images/new-button}} New Conversation
$button>
diff --git a/plugins/tiddlywiki/ai-tools/styles.tid b/plugins/tiddlywiki/ai-tools/styles.tid
index 3ef7579c5..a477c4fb1 100644
--- a/plugins/tiddlywiki/ai-tools/styles.tid
+++ b/plugins/tiddlywiki/ai-tools/styles.tid
@@ -211,4 +211,15 @@ tags: [[$:/tags/Stylesheet]]
box-shadow: 30px 0 0 #9c9ab0;
margin-top: 0;
}
+}
+
+.tc-ai-tools-dropzone {
+ background: yellow;
+ text-align: center;
+ width: 100%;
+ height: 4em;
+}
+
+.tc-ai-tools-dropzone.tc-dragover {
+ background: red;
}
\ No newline at end of file
diff --git a/plugins/tiddlywiki/ai-tools/tools.tid b/plugins/tiddlywiki/ai-tools/tools.tid
index 0512ea218..f1bd9ee49 100644
--- a/plugins/tiddlywiki/ai-tools/tools.tid
+++ b/plugins/tiddlywiki/ai-tools/tools.tid
@@ -2,18 +2,41 @@ title: $:/plugins/tiddlywiki/ai-tools/tools
! Import ~ChatGPT Export Archive
+These instructions allow you to import the conversations from a ~ChatGPT export archive.
+
+!! 1- Request your archive
+
+Visit the ~ChatGPT site to request your achive. You will be sent an email with a link to a ZIP file. Download the file and locate the file `conversations.json` within it.
+
+!! 2 - Import `conversations.json` as a tiddler
+
+It is not possible to use the normal import process to import the `conversations.json` file because TiddlyWiki will erroneously recognise it as a JSON file of tiddlers.
+
+Instead, drag the `conversations.json` file to the dropzone below. Then click the "Import" button to complete the import:
+
+<$dropzone deserializer="text/plain" autoOpenOnImport="yes" filesOnly="yes" class="tc-ai-tools-dropzone">
+Drop your file here
+$dropzone>
+
+!! 3 - Import the conversations within it
+
Any tiddlers containing ~ChatGPT exported `conversation.json` files will be shown here for import.
<$list filter="[all[tiddlers+shadows]type[application/json]!has[plugin-type]sort[title]]" template="$:/plugins/tiddlywiki/ai-tools/view-templates/imported-conversations-json"/>
-! Loaded Conversations
+!! 4 - Review Loaded Conversations
+ <$list-empty>
+ No conversations found
+ $list-empty>
+ <$list-template>
+
+ <$link>
+ <$text text=<>/>
+ $link>
+
+ $list-template>
$list>
From 8efec8920d9e8d0a93720e314d82b78ef4be92a0 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Thu, 10 Oct 2024 13:22:59 +0100
Subject: [PATCH 23/25] User messages should be wikified
Makes it possible to include other tiddlers in a prompt
---
plugins/tiddlywiki/ai-tools/globals.tid | 14 ++++++++++++++
.../ai-tools/servers/llamafile-llava.tid | 2 +-
plugins/tiddlywiki/ai-tools/servers/openai.tid | 2 +-
plugins/tiddlywiki/ai-tools/styles.tid | 5 +++++
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/globals.tid b/plugins/tiddlywiki/ai-tools/globals.tid
index e6436913d..7aeabae18 100644
--- a/plugins/tiddlywiki/ai-tools/globals.tid
+++ b/plugins/tiddlywiki/ai-tools/globals.tid
@@ -101,6 +101,17 @@ Procedure to display a message from an AI conversation. Current tiddler is the c
$qualify>
\end ai-tools-message
+\procedure ai-tools-get-message()
+\whitespace trim
+<$wikify
+ name="messageText"
+ text={{!!text}}
+ output="text"
+>
+ <$text text={{{ [jsonstringify[]] }}}/>
+$wikify>
+\end
+
@@ -199,6 +210,9 @@ Action procedure to get the next response from the LLM
+
+ Note that your text will be wikified before being sent to the LLM. Use {{transclusion}} to include other tiddlers in your messages
+
$let>
\end ai-tools-conversation
diff --git a/plugins/tiddlywiki/ai-tools/servers/llamafile-llava.tid b/plugins/tiddlywiki/ai-tools/servers/llamafile-llava.tid
index 1334bea86..0ac1d8f33 100644
--- a/plugins/tiddlywiki/ai-tools/servers/llamafile-llava.tid
+++ b/plugins/tiddlywiki/ai-tools/servers/llamafile-llava.tid
@@ -54,7 +54,7 @@ Wikified JSON text to be sent to server
<%if [has[image]] %>
[img-<$text text=<>/>]
<%endif%>
-<$text text={{{ [get[text]jsonstringify[]] }}}/>
+<>
$list>
\nLlama:
\end json-prompt-text
diff --git a/plugins/tiddlywiki/ai-tools/servers/openai.tid b/plugins/tiddlywiki/ai-tools/servers/openai.tid
index 65ee9429a..2d4bacf6e 100644
--- a/plugins/tiddlywiki/ai-tools/servers/openai.tid
+++ b/plugins/tiddlywiki/ai-tools/servers/openai.tid
@@ -24,7 +24,7 @@ Wikified JSON text to be sent to server
"content": [
{
"type": "text",
- "text": "<$text text={{{ [get[text]jsonstringify[]] }}}/>"
+ "text": "<>"
}
<%if [get[image]else[]!match[]] %>
,
diff --git a/plugins/tiddlywiki/ai-tools/styles.tid b/plugins/tiddlywiki/ai-tools/styles.tid
index a477c4fb1..226f76953 100644
--- a/plugins/tiddlywiki/ai-tools/styles.tid
+++ b/plugins/tiddlywiki/ai-tools/styles.tid
@@ -147,6 +147,11 @@ tags: [[$:/tags/Stylesheet]]
fill: #000;
}
+.ai-conversation .ai-user-prompt-help {
+ font-size: 0.8em;
+ line-height: 1.5;
+}
+
.ai-request-spinner {
animation: ai-request-spinner-animation-rotate 1s infinite;
height: 50px;
From db692738fe1e74f015b28ad8530e2ab9b97b9da0 Mon Sep 17 00:00:00 2001
From: Jeremy Ruston
Date: Thu, 10 Oct 2024 14:54:12 +0100
Subject: [PATCH 24/25] Allow content type of user input to be specified
Useful to use text/plain for code
---
plugins/tiddlywiki/ai-tools/globals.tid | 8 ++++++--
plugins/tiddlywiki/ai-tools/styles.tid | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/plugins/tiddlywiki/ai-tools/globals.tid b/plugins/tiddlywiki/ai-tools/globals.tid
index 7aeabae18..78d6a3b1e 100644
--- a/plugins/tiddlywiki/ai-tools/globals.tid
+++ b/plugins/tiddlywiki/ai-tools/globals.tid
@@ -106,6 +106,7 @@ Procedure to display a message from an AI conversation. Current tiddler is the c
<$wikify
name="messageText"
text={{!!text}}
+ type={{!!type}}
output="text"
>
<$text text={{{ [jsonstringify[]] }}}/>
@@ -123,12 +124,13 @@ Action procedure to get the next response from the LLM
<$action-createtiddler
$basetitle=<>
tags=<>
- type="text/markdown"
role="user"
text={{!!current-response-text}}
+ type={{!!current-response-type}}
image={{!!current-response-image}}
>
<$action-deletefield $tiddler=<> $field="current-response-text"/>
+ <$action-setfield $tiddler=<> $field="current-response-type" $value="text/vnd.tiddlywiki"/>
<$action-deletefield $tiddler=<> $field="current-response-image"/>
<$transclude
$variable="ai-tools-get-llm-completion"
@@ -210,7 +212,8 @@ Action procedure to get the next response from the LLM
-
+
+ <$edit-text tiddler=<> field="current-response-type" tag="input" class="tc-edit-texteditor"/>
Note that your text will be wikified before being sent to the LLM. Use {{transclusion}} to include other tiddlers in your messages
@@ -223,6 +226,7 @@ Action procedure to get the next response from the LLM
tags="$:/tags/AI/Conversation"
system-prompt="Transcript of a never ending dialog, where the User interacts with an Assistant. The Assistant is helpful, kind, honest, good at writing, and never fails to answer the User's requests immediately and with precision."
current-response-text="Please list the 10 most important mechanical inventions of the Twentieth Century"
+ current-response-type="text/vnd.tiddlywiki"
>
<$action-navigate $to=<>/>
$action-createtiddler>
diff --git a/plugins/tiddlywiki/ai-tools/styles.tid b/plugins/tiddlywiki/ai-tools/styles.tid
index 226f76953..7225de54d 100644
--- a/plugins/tiddlywiki/ai-tools/styles.tid
+++ b/plugins/tiddlywiki/ai-tools/styles.tid
@@ -147,7 +147,7 @@ tags: [[$:/tags/Stylesheet]]
fill: #000;
}
-.ai-conversation .ai-user-prompt-help {
+.ai-conversation .ai-user-prompt-type {
font-size: 0.8em;
line-height: 1.5;
}
From 378b9b3627cab368ed216cf5eb856370cfb4b9b0 Mon Sep 17 00:00:00 2001
From: Leilei332
Date: Thu, 27 Feb 2025 19:00:58 +0800
Subject: [PATCH 25/25] Allow building external core version of main site
(#8953)
---
bin/build-site.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bin/build-site.sh b/bin/build-site.sh
index f1fe649e7..066d13d1f 100755
--- a/bin/build-site.sh
+++ b/bin/build-site.sh
@@ -105,6 +105,7 @@ node $TW5_BUILD_TIDDLYWIKI \
fi
# /index.html Main site
+# /external-(version).html External core version of main site
# /favicon.ico Favicon for main site
# /static.html Static rendering of default tiddlers
# /alltiddlers.html Static rendering of all tiddlers
@@ -117,7 +118,7 @@ node $TW5_BUILD_TIDDLYWIKI \
--version \
--load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_OUTPUT \
- --build favicon static index \
+ --build favicon static index external-js \
|| exit 1
# /empty.html Empty