gptel-ollama: Fix buffer parsing
* gptel-ollama.el (gptel--parse-buffer): The prompt construction for Ollama fails when starting from (point-min). Fix by checking if a valid text-property match object is found in the parsing.
This commit is contained in:
parent
57a70c23cb
commit
66d2bafad6
1 changed files with 13 additions and 10 deletions
|
@ -76,20 +76,23 @@ Ollama models.")
|
|||
prompts-plist))
|
||||
|
||||
(cl-defmethod gptel--parse-buffer ((_backend gptel-ollama) &optional _max-entries)
|
||||
(let ((prompts) (prop))
|
||||
(setq prop (text-property-search-backward
|
||||
(let ((prompts)
|
||||
(prop (text-property-search-backward
|
||||
'gptel 'response
|
||||
(when (get-char-property (max (point-min) (1- (point)))
|
||||
'gptel)
|
||||
t)))
|
||||
(if (prop-match-value prop)
|
||||
t))))
|
||||
(if (and (prop-match-p prop)
|
||||
(prop-match-value prop))
|
||||
(user-error "No user prompt found!")
|
||||
(setq prompts (list
|
||||
:system gptel--system-message
|
||||
:prompt
|
||||
(if (prop-match-p prop)
|
||||
(string-trim (buffer-substring-no-properties (prop-match-beginning prop)
|
||||
(prop-match-end prop))
|
||||
"[*# \t\n\r]+"))))))
|
||||
"[*# \t\n\r]+")
|
||||
""))))))
|
||||
|
||||
;;;###autoload
|
||||
(cl-defun gptel-make-ollama
|
||||
|
|
Loading…
Add table
Reference in a new issue