Open aindilis opened 7 months ago
You can use gptel-prompt-prefix-alist
and gptel-response-prefix-alist
to add text before a response/prompt. This is intended for use in gptel chat buffers. See #103 for an example.
A more general solution is to use gptel-pre-response-hook
and gptel-post-response-functions
to add this stuff. Here is an example:
(defun gptel-tag-response (beg end)
(save-excursion
(goto-char end)
;; ending tag
(insert "</llm-content>\n\n<llm-prompt>")
(goto-char beg)
(skip-chars-backward " \n\r\t")
;; end of prompt tag
(insert "</llm-prompt>")
(skip-chars-forward " \n\r\t")
;; beginning of response tag
(insert (format "<llm-content model=\"%s\">\n"
gptel-model))))
(add-hook 'gptel-post-response-functions #'gptel-tag-response)
Modify as needed.
Closing this now, please reopen if the above solution doesn't work.
Hi @karthink,
Thank you for showing me how to do this!
It works well, however, when I ran it, I had problems with it not putting text annotations in the correct spot.
However, I am reopening as well because I realized a few more desirable features:
1) watermark using enriched text text properties (and other optional/configurable methods) 2) have the option for users and/or fact-checking programs like FEVER to annotate suspected or known hallucinations, or other LLM related metadata 3) allow the text properties to store or link to other metadata/properties/parameters, such as the LLM that was used, the prompt text, temperature, etc.
If you wish I can attempt to implement this in Elisp with Claude's help.
Best, Andrew
Hi,
I was wondering whether some feature such as the following could be implemented:
1) Inserting perhaps XML or Org-mode tags indicating the beginning and ending of LLM generated content.
E.g.
Would become
2) Making such context sensitive, so it would use the appropriate tags for the mode, e.g. Org-mode, or comment them out:
(in hypothetical file: apartments.el)
Thanks!
Andrew