-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Claude) Request fails with "all messages must have non-empty content" #409
Comments
Ah yeah, I'm aware of this issue. It's unrelated to Org mode. See prior discussions in #406, #321, #351, #343. There is no easy fix for this yet. Rather, there are several easy ways to fix it but all of them create new problems. Here are three independent things you can do to avoid the error (i.e., any one of them will work, don't do them all):
(setf (alist-get 'gptel 'text-property-default-nonsticky nil 'remove) nil) Each of these causes other problems, but it's possible you may not encounter any of them. Eventually I need to find a solution that works with minimal compromises. |
For some reason I don't see it (at least not as often) when using Markdown mode. |
when i looked at the code after a recent "invalid_request_error" I realized, that my buffer had adjacent |
thats the relevant snippet from gptel-log
|
* gptel-anthropic.el (gptel--parse-buffer): Ignore blank user promps in the buffer when creating the full prompt. The most common way to unintentionally produce these blank regions is to reformat the response in some way, such as by filling the response region. Until a better solution for tracking responses can be found, this will have to do. Address #409, #406 and #351. Also relevant to the discussion about overlay-based tracking in #321.
Apologies for the delay, just wanted to make sure it's good. This is what I have in my config
Sorry, with org-indent-mode my converstations were weirdly shifting onto the right, so I removed a few asterisks. Been using it for a couple of days, so far no issues with the requests. Looks good. Thank you very much. |
karthik, if you write an updated |
Fixed-point iteration: https://github.com/karthink/gptel/blob/master/gptel-org.el#L410 |
I think it is nice to have a workaround hack, to be able to work with Claude in conversation mode even if something is broken at the moment, but at the same time I think we are very close at finding the real problem, and this workaround obscures the fact that something is broken. Do you understand why the gptel--get-buffer-bounds() function. from gptel.el (defun gptel--get-buffer-bounds ()
"Return the gptel response boundaries in the buffer as an alist."
(save-excursion
(save-restriction
(widen)
(goto-char (point-max))
(let ((prop) (bounds))
(while (setq prop (text-property-search-backward
'gptel 'response t))
(push (cons (prop-match-beginning prop)
(prop-match-end prop))
bounds))
bounds)))) returns, two adjacent cells of a text which has consecutively the text property ' gptel 'response? eg. |
If you are referring to the workaround chosen as the solution in this thread, it's a workaround, but nothing is broken. The text-properties are applied and read as intended.
These bounds are correct, you can have one character without the The real question is if we should also apply this text property to the range 2720-2721. Unfortunately making the |
i thought the above means. character 359 up to and included character 2720 is an assistant message? |
thanks for pointing me to the sticky text properties documentation. |
There is no character at 359, a character occupies the range from 359 to 360. Similarly, there is no character at 2720. So the above means that all characters between points 359 and 2720 are part of an assistant message, as are characters between points 2721 and 3388. The single character between the points 2720 and 2721 is part of the user prompt. It's recognized as user input because it was inserted by the user, possibly by running a command like |
Anecdotally, I never had this error. |
* gptel-anthropic.el (gptel--parse-buffer): Following from the previous approach, change how we guard against blank response regions (#452, #409, #406, #351, #321). This time we compare the current and previous values of (point), after skipping whitespace, when parsing the buffer and constructing the prompt.
I set
gptel-default-mode
toorg-mode
and at first, it seemed that it's worked, but it sometimes can fail.What I did:
The text was updated successfully, but these errors were encountered: