Closed benthamite closed 6 months ago
@benthamite I see the problem. It's a little tricky to fix, I will think about the best way to do it. Basically every LLM provider does things differently and I'm failing to provide a uniform interface to all of them.
In the meantime, you can get around the problem by setting :stream
to nil
when you define the backend:
(defun gptel-model-config (model)
"Configure `gptel' for MODEL."
(interactive (list (completing-read "Model: " '("gpt-4" "gemini-pro") nil t)))
(pcase model
("gpt-4" (setq-default ...))
("gemini-pro" (setq-default ...))
("gemini-pro-no-stream" (setq-default gptel-model "gemini-pro"
gptel-backend
(gptel-make-gemini
"Gemini-no-stream"
:key "GEMINI-KEY"
:stream nil))))) ;;Change to nil
(gptel-model-config "gemini-pro-no-stream")
(my/summarize-article "test string")
This should work. I'll update this issue after I figure out the best way to fix it, and you can get rid of "gemini-pro-no-stream"
.
A couple of other notes:
You don't need setq-default
if you are going to change models with your gptel-model-config
function, just setq
(which will change the value in the active buffer) is fine.
You probably want to store the backends in variables and reuse them. Otherwise they are constructed every time the function gptel-model-config
is called.
(defvar my/gemini (gptel-make-gemini ...))
Then use my/gemini
the way you do gptel--openai
.
Thanks for the quick and detailed reply!
I confirm that it works. Thanks again!
EDIT: In case it is of interest, here’s the relevant code.
Keeping this issue open until gptel-request
handles Gemini correctly.
You can remove gptel-extras-gemini-pro-no-stream-backend
from your configuration now. If gptel-request
still fails please re-open this issue.
I have defined a custom command with
gptel-request
that works fine with a GPT backend, but fails when the backend is set to Gemini:My config:
With the above code evaluated, the following generates an error:
The error messages are:
Gemini works fine when I use
gptel
orgptel-menu
, so this seems specific togptel-request
.