Created
November 15, 2025 19:38
-
-
Save ahyatt/cf27b7c6ed360aade41c4965e3998be6 to your computer and use it in GitHub Desktop.
LLMs in your Emacs yes-or-no prompts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;; llm-yes-or-no.el --- Don't configure yourself to yes or no! -*- lexical-binding: t -*- | |
| (require 'llm) | |
| (defconst yes-or-no-p-llm my-small-llm-model) | |
| (defun llm-yes-or-no-p (prompt) | |
| (let ((response nil)) | |
| (llm-chat yes-or-no-p-llm (llm-make-chat-prompt | |
| (format "The user has been asked a yes or no question (%s) and has answered '%s'. Report whether they have answered yes or no by calling the appropriate function. Always call one of the two functions." | |
| prompt | |
| (read-string (format "%s (yes/no): " prompt))) | |
| :tools (list | |
| (llm-make-tool | |
| :name "yes" | |
| :description "Indicates that the user has answered yes to the question." | |
| :function (lambda (&rest _) (setq response t)) | |
| :args '()) | |
| (llm-make-tool | |
| :name "no" | |
| :description "Indicates that the user has answered no to the question." | |
| :function (lambda (&rest _) (setq response nil)) | |
| :args '())))) | |
| response)) | |
| (defalias 'y-or-n-p #'llm-yes-or-no-p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool!