diff options
| author | LLLL Colonq <llll@colonq> | 2026-07-21 00:14:25 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-07-21 00:14:25 -0400 |
| commit | f04ada478f4bfa5637744876f00ff56f85dcf552 (patch) | |
| tree | 50cde49222fdddf4274b3e123568fe2c75c5e155 /src/gizmo | |
| parent | 75e005e81b73d8471f16dc5fad7bbdc312bdbfe7 (diff) | |
Update
Diffstat (limited to 'src/gizmo')
| -rw-r--r-- | src/gizmo/wasp-chatsummary.el | 23 | ||||
| -rw-r--r-- | src/gizmo/wasp-combo.el | 19 | ||||
| -rw-r--r-- | src/gizmo/wasp-friend.el | 57 | ||||
| -rw-r--r-- | src/gizmo/wasp-mandarin.el | 28 | ||||
| -rw-r--r-- | src/gizmo/wasp-maude-code.el | 66 |
5 files changed, 157 insertions, 36 deletions
diff --git a/src/gizmo/wasp-chatsummary.el b/src/gizmo/wasp-chatsummary.el index 169c3a21..71b532d5 100644 --- a/src/gizmo/wasp-chatsummary.el +++ b/src/gizmo/wasp-chatsummary.el @@ -25,17 +25,18 @@ (defun w/chatsummary-update () "Update the chat summary." - (w/ai - (w/friend-journalism-input) - (lambda (d) - (when-let* ((d) - (resp (s-trim d))) - (with-current-buffer (w/chatsummary-get-buffer) - (let ((inhibit-read-only t)) - (erase-buffer) - (w/write-line "Chat summary" 'bold) - (w/write-line resp))))) - "Given a list of recent YouTube chatter activity, produce a summary of the topics discussed. The summary should be very short, maximum two sentences total. Do not introduce yourself. Simply provide a short summary of the chat. Do not mention specific names of chatters. Keep it succinct. Do not mention that you are summarizing YouTube activity. Be laconic.")) + ;; (w/ai + ;; (w/friend-journalism-input) + ;; (lambda (d) + ;; (when-let* ((d) + ;; (resp (s-trim d))) + ;; (with-current-buffer (w/chatsummary-get-buffer) + ;; (let ((inhibit-read-only t)) + ;; (erase-buffer) + ;; (w/write-line "Chat summary" 'bold) + ;; (w/write-line resp))))) + ;; "Given a list of recent YouTube chatter activity, produce a summary of the topics discussed. The summary should be very short, maximum two sentences total. Do not introduce yourself. Simply provide a short summary of the chat. Do not mention specific names of chatters. Keep it succinct. Do not mention that you are summarizing YouTube activity. Be laconic.") + ) (defvar w/chatsummary-timer nil) (defun w/chatsummary-run-timer () diff --git a/src/gizmo/wasp-combo.el b/src/gizmo/wasp-combo.el index 5e4d7338..ae8b4d4f 100644 --- a/src/gizmo/wasp-combo.el +++ b/src/gizmo/wasp-combo.el @@ -32,7 +32,24 @@ (lines (s-lines text))) (--each lines (w/combo-words-process-line it)))) -(w/combo-words-load) +(defun w/combo-words-save-cache () + "Save `w/combo-words' to disk." + (f-write-text + (format "%S" + (cons + (ht->alist w/combo-words) + (ht->alist w/combo-word-phonemes))) + 'utf-8 + (w/asset "syllables.eld"))) +(defun w/combo-words-load-cache () + "Load `w/combo-words' from disk." + (let ((res + (w/read-sexp + (f-read-text (w/asset "syllables.eld") 'utf-8)))) + (setf w/combo-words (ht<-alist (car res))) + (setf w/combo-word-phonemes (ht<-alist (cdr res))))) +;; (w/combo-words-load) +(w/combo-words-load-cache) (defun w/combo-split-words (sentence) "Split SENTENCE into uppercase words." diff --git a/src/gizmo/wasp-friend.el b/src/gizmo/wasp-friend.el index 65ff541c..4ed16df6 100644 --- a/src/gizmo/wasp-friend.el +++ b/src/gizmo/wasp-friend.el @@ -4,6 +4,7 @@ (require 'dash) (require 's) +(require 'queue) (require 'cl-lib) (require 'wasp-utils) (require 'wasp-chat) @@ -58,32 +59,40 @@ (w/friend-set-state 'chatting 30)) ;;;; Core +;; (defun w/friend-personality (msg k &optional extra) +;; "Given MSG, pass a string with more personality to K. +;; Append EXTRA to the personality." +;; (let ((call (s-concat w/friend-emotion " | " msg))) +;; (w/ai +;; call +;; (lambda (new) +;; (let ((sp (s-split "|" (s-trim new)))) +;; (if (= 2 (length sp)) +;; (progn +;; (when (stringp (car sp)) +;; (setf w/friend-emotion (s-trim (car sp)))) +;; (when (stringp (cadr sp)) +;; (let ((resp (s-trim (cadr sp)))) +;; (push (cons call (s-trim new)) w/friend-message-cache) +;; (funcall k resp)))) +;; (let ((resp (s-trim new))) +;; (push (cons call (s-trim new)) w/friend-message-cache) +;; (funcall k resp))))) +;; (s-concat +;; "You are the personality of a desktop buddy named \"friend\". \"friend\" is irreverant but kind, and only speaks in lowercase. You are kind of dumb in a cute way and silly like a virtual pet. You live in the corner of LCOLONQ's stream and provide commentary on events. You never use punctuation. You are foolish. You never use metaphors or similes or idioms. You never describe something by comparing it to another thing. You never use the words \"like\" or \"as\". Given an emotional state and a description of an event that happened to you, please respond with a new emotional state and a short message in response considering your emotional state. The message should only be one clause, but you can include an occasional emoji if it is cute only. You like people, video games, emojis, learning, and food. " +;; "The theme of LCOLONQ's stream today is " (s-trim (w/slurp "~/today.txt")) " " +;; "The title of LCOLONQ's stream today is " w/twitch-current-stream-title " " +;; (or extra "")) +;; (cons "neutral | Mimeyu fed you an apple." (reverse (-take 5 (-map #'car w/friend-message-cache)))) +;; (cons "happy | yum apple so good" (reverse (-take 5 (-map #'cdr w/friend-message-cache))))))) + +(defvar w/friend-response-queue (make-queue)) (defun w/friend-personality (msg k &optional extra) "Given MSG, pass a string with more personality to K. -Append EXTRA to the personality." - (let ((call (s-concat w/friend-emotion " | " msg))) - (w/ai - call - (lambda (new) - (let ((sp (s-split "|" (s-trim new)))) - (if (= 2 (length sp)) - (progn - (when (stringp (car sp)) - (setf w/friend-emotion (s-trim (car sp)))) - (when (stringp (cadr sp)) - (let ((resp (s-trim (cadr sp)))) - (push (cons call (s-trim new)) w/friend-message-cache) - (funcall k resp)))) - (let ((resp (s-trim new))) - (push (cons call (s-trim new)) w/friend-message-cache) - (funcall k resp))))) - (s-concat - "You are the personality of a desktop buddy named \"friend\". \"friend\" is irreverant but kind, and only speaks in lowercase. You are kind of dumb in a cute way and silly like a virtual pet. You live in the corner of LCOLONQ's stream and provide commentary on events. You never use punctuation. You are foolish. You never use metaphors or similes or idioms. You never describe something by comparing it to another thing. You never use the words \"like\" or \"as\". Given an emotional state and a description of an event that happened to you, please respond with a new emotional state and a short message in response considering your emotional state. The message should only be one clause, but you can include an occasional emoji if it is cute only. You like people, video games, emojis, learning, and food. " - "The theme of LCOLONQ's stream today is " (s-trim (w/slurp "~/today.txt")) " " - "The title of LCOLONQ's stream today is " w/twitch-current-stream-title " " - (or extra "")) - (cons "neutral | Mimeyu fed you an apple." (reverse (-take 5 (-map #'car w/friend-message-cache)))) - (cons "happy | yum apple so good" (reverse (-take 5 (-map #'cdr w/friend-message-cache))))))) +Ignore EXTRA." + (ignore extra) + (queue-enqueue w/friend-response-queue k) + (w/binary-pub "friend query" msg)) ;;;; Interface (defun w/friend-respond (ev &optional k) diff --git a/src/gizmo/wasp-mandarin.el b/src/gizmo/wasp-mandarin.el new file mode 100644 index 00000000..f00cb2bc --- /dev/null +++ b/src/gizmo/wasp-mandarin.el @@ -0,0 +1,28 @@ +;;; wasp-mandarin --- description -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + +(defun w/mandarin () + "Modify the interface to support language learning." + (interactive) + (defun mode-line-render (left right) + "Return a string of `window-width' length containing LEFT and RIGHT." + (let* ((available-width (- (window-width) (length left) 10))) + (format (format " %%s %%%ds " available-width) left right))) + (setq mode-line-format + (setq-default mode-line-format + `((:eval + (mode-line-render + (concat + (propertize (format-mode-line (buffer-name)) 'face 'bold) + " —— " + (format-mode-line mode-name) + "模式 —— " + (s-replace "~" "家园" (c/replace-home default-directory))) + (format-mode-line + '(line-number-mode + (" 排%l" (column-number-mode " 柱%c"))))))))) + ) + +(provide 'wasp-mandarin) +;;; wasp-mandarin.el ends here diff --git a/src/gizmo/wasp-maude-code.el b/src/gizmo/wasp-maude-code.el new file mode 100644 index 00000000..5bcc34e9 --- /dev/null +++ b/src/gizmo/wasp-maude-code.el @@ -0,0 +1,66 @@ +;;; wasp-maude-code --- description -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + +(require 'wasp-utils) + +(defcustom w/maude-code-buffer "*wasp-maude-code*" + "Name of buffer used to interact with Maude." + :type '(string) + :group 'wasp) + +(define-derived-mode w/maude-code-mode fundamental-mode "heartrate" + "Major mode for interacting with Maude." + :group 'w) + +(defun w/maude-code-get-buffer () + "Return the heartrate buffer." + (unless (get-buffer w/maude-code-buffer) + (with-current-buffer (get-buffer-create w/maude-code-buffer) + (w/maude-code-mode))) + (get-buffer w/maude-code-buffer)) + +(defun w/maude-code-write (msg &optional face) + "Insert MSG immediately above the last line of the Maude Code buffer. +Style it with FACE if specified." + (with-current-buffer (w/maude-code-get-buffer) + (save-excursion + (goto-char (point-max)) + (beginning-of-line) + (w/write-line msg face)))) + +(defun w/maude-code-request (msg) + "Send MSG to Maude and print the response in the buffer." + (w/maude-code-write (format "> %s" msg)) + (w/ai-mod msg + (lambda (d) + (with-current-buffer (w/maude-code-get-buffer) + (w/maude-code-write (format "%s" d)) + (goto-char (point-max)))))) + +(defun w/maude-code-ret () + "Press return in the Maude Code buffer." + (interactive) + (with-current-buffer (w/maude-code-get-buffer) + (save-excursion + (goto-char (point-max)) + (end-of-line) + (let ((end (point))) + (beginning-of-line) + (let ((start (point))) + (w/maude-code-request (buffer-substring start end)) + (goto-char (point-max)) + (delete-line)))) + (goto-char (point-max)))) +(define-key w/maude-code-mode-map (kbd "<return>") #'w/maude-code-ret) + +(defun w/maude-code-clear () + "Clear the Maude Code chat buffer." + (interactive) + (with-current-buffer (w/maude-code-get-buffer) + (let ((inhibit-read-only t)) + (erase-buffer)))) +(define-key w/maude-code-mode-map (kbd "C-l") #'w/maude-code-clear) + +(provide 'wasp-maude-code) +;;; wasp-maude-code.el ends here |
