Skip to content

Commit 365bcf4

Browse files
authored
Merge branch 'karthink:master' into master
2 parents 52281ca + 7e103f3 commit 365bcf4

13 files changed

+107
-17
lines changed

README.org

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ To use MCP servers with gptel, you thus need three pieces:
12051205
2. MCP servers configured for and running via mcp.el.
12061206
3. gptel and access to an LLM
12071207

1208-
While mcp.el [[https://github.com/lizqwerscott/mcp.el?tab=readme-ov-file#use-with-gptel][provides instructions]] for accessing MCP-provided tools from gptel, gptel includes =gptel-integrations=, a small library to make this more convenient. This library is not automatically loaded by gptel, so if you would like to use it you have to require it:
1208+
gptel includes =gptel-integrations=, a small library to make this more convenient. This library is not automatically loaded by gptel, so if you would like to use it you have to require it:
12091209

12101210
#+begin_src emacs-lisp
12111211
(require 'gptel-integrations)
@@ -1221,6 +1221,12 @@ MCP-provided tools can be used as normal with gptel. Here is a screencast of th
12211221
https://github.com/user-attachments/assets/f3ea7ac0-a322-4a59-b5b2-b3f592554f8a
12221222
#+html: </p>
12231223

1224+
Here's an example of using these tools:
1225+
1226+
#+html: <p align="center">
1227+
https://github.com/user-attachments/assets/b48a6a24-a130-4da7-a2ee-6ea568e10c85
1228+
#+html: </p>
1229+
12241230
#+html: </details>
12251231

12261232

gptel-anthropic.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ Keys:
591591
Information about the Anthropic models was obtained from the following
592592
comparison table:
593593
594-
<https://docs.anthropic.com/en/docs/about-claude/models#model-comparison-table>")
594+
URL `https://docs.anthropic.com/en/docs/about-claude/models#model-comparison-table'")
595595

596596
;;;###autoload
597597
(cl-defun gptel-make-anthropic
@@ -676,3 +676,8 @@ for."
676676

677677
(provide 'gptel-anthropic)
678678
;;; gptel-anthropic.el ends here
679+
680+
;; Local Variables:
681+
;; byte-compile-warnings: (not docstrings)
682+
;; End:
683+

gptel-context.el

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ context chunk. This is accessible as, for example:
8484
:group 'gptel
8585
:type 'function)
8686

87+
(defun gptel-context-add-current-kill (&optional arg)
88+
"Add current-kill to gptel, accumulating if arg is non-nil"
89+
(interactive "P")
90+
(let ((kill (current-kill 0)))
91+
(with-current-buffer (get-buffer-create " *gptel-kill-ring-context*")
92+
(if (not arg)
93+
(kill-region (point-min) (point-max))
94+
(goto-char (point-max))
95+
(unless (bobp)
96+
(insert "\n----\n")))
97+
(insert kill)
98+
(gptel-context--add-region (current-buffer)
99+
(point-min) (point-max))
100+
(message "*current-kill* has been added as context."))))
101+
87102
(defun gptel-context-add (&optional arg confirm)
88103
"Add context to gptel in a DWIM fashion.
89104

gptel-curl.el

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ REQUEST-DATA is the data to send, TOKEN is a unique identifier."
9090
(append
9191
gptel-curl--common-args
9292
gptel-curl-extra-args
93-
(gptel-backend-curl-args gptel-backend)
93+
(and-let* ((curl-args (gptel-backend-curl-args gptel-backend)))
94+
(if (functionp curl-args) (funcall curl-args) curl-args))
9495
(list (format "-w(%s . %%{size_header})" token))
9596
(if (length< data-json gptel-curl-file-size-threshold)
9697
(list (format "-d%s" data-json))
@@ -133,18 +134,25 @@ the response is inserted into the current buffer after point."
133134
(random) (emacs-pid) (user-full-name)
134135
(recent-keys))))
135136
(info (gptel-fsm-info fsm))
137+
(backend (plist-get info :backend))
136138
(args (gptel-curl--get-args info token))
137139
(stream (plist-get info :stream))
138140
(process (apply #'start-process "gptel-curl"
139-
(gptel--temp-buffer " *gptel-curl*") "curl" args)))
140-
;; Don't try to convert cr-lf to cr on Windows so that curl's "header size
141-
;; in bytes" stays correct. Explicitly set utf-8 for non-win systems too,
142-
;; for cases when buffer coding system is not set to utf-8.
143-
(set-process-coding-system process 'utf-8-unix 'utf-8-unix)
141+
(gptel--temp-buffer " *gptel-curl*") (gptel--curl-path) args)))
144142
(when (eq gptel-log-level 'debug)
145-
(gptel--log (mapconcat #'shell-quote-argument (cons "curl" args) " \\\n")
143+
(gptel--log (mapconcat #'shell-quote-argument (cons (gptel--curl-path) args) " \\\n")
146144
"request Curl command" 'no-json))
147145
(with-current-buffer (process-buffer process)
146+
(cond
147+
((eq (gptel-backend-coding-system backend) 'binary)
148+
;; set-buffer-file-coding-system is not needed since we don't save this buffer
149+
(set-buffer-multibyte nil)
150+
(set-process-coding-system process 'binary 'binary))
151+
(t
152+
;; Don't try to convert cr-lf to cr on Windows so that curl's "header size
153+
;; in bytes" stays correct. Explicitly set utf-8 for non-win systems too,
154+
;; for cases when buffer coding system is not set to utf-8.
155+
(set-process-coding-system process 'utf-8-unix 'utf-8-unix)))
148156
(set-process-query-on-exit-flag process nil)
149157
(if (plist-get info :token) ;not the first run, set only the token
150158
(plist-put info :token token)

gptel-gemini.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,15 @@ files in the context."
463463
:input-cost 0.15
464464
:output-cost 0.60 ; 3.50 for thinking
465465
:cutoff-date "2025-01")
466+
(gemini-2.5-flash-preview-05-20
467+
:description "Best Gemini model in terms of price-performance, offering well-rounded capabilities"
468+
:capabilities (tool-use json media)
469+
:mime-types ("image/png" "image/jpeg" "image/webp" "image/heic" "image/heif"
470+
"application/pdf" "text/plain" "text/csv" "text/html")
471+
:context-window 1048 ; 65536 output token limit
472+
:input-cost 0.15
473+
:output-cost 0.60 ; 3.50 for thinking
474+
:cutoff-date "2025-01")
466475
(gemini-2.5-pro-preview-05-06
467476
:description "Most powerful Gemini thinking model with maximum response accuracy and state-of-the-art performance"
468477
:capabilities (tool-use json media)

gptel-gh.el

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,7 @@ for."
364364

365365
(provide 'gptel-gh)
366366
;;; gptel-gh.el ends here
367+
368+
;; Local Variables:
369+
;; byte-compile-warnings: (not docstrings)
370+
;; End:

gptel-kagi.el

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,7 @@ Example:
190190

191191
(provide 'gptel-kagi)
192192
;;; gptel-kagi.el ends here
193+
194+
;; Local Variables:
195+
;; byte-compile-warnings: (not docstrings)
196+
;; End:

gptel-ollama.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ format."
239239
&optional inject-media)
240240
"Wrap the last user prompt in PROMPTS with the context string.
241241
242-
If INJECT-MEDIA is non-nil wrap it with base64-encoded media files in the context."
242+
If INJECT-MEDIA is non-nil wrap it with base64-encoded media
243+
files in the context."
243244
(if inject-media
244245
;; Wrap the first user prompt with included media files/contexts
245246
(when-let* ((media-list (gptel-context--collect-media))

gptel-openai-extras.el

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ the response."
219219
;;;###autoload
220220
(cl-defun gptel-make-perplexity
221221
(name &key curl-args stream key
222-
(header
222+
(header
223223
(lambda () (when-let* ((key (gptel--get-api-key)))
224224
`(("Authorization" . ,(concat "Bearer " key))))))
225225
(host "api.perplexity.ai")
@@ -309,7 +309,7 @@ parameters."
309309
(when (and (stringp reasoning) (length> reasoning 0))
310310
(plist-put info :reasoning reasoning))))
311311

312-
(cl-defmethod gptel--parse-buffer :around ((_backend gptel-deepseek) max-entries)
312+
(cl-defmethod gptel--parse-buffer :around ((_backend gptel-deepseek) _max-entries)
313313
"Merge successive prompts in the prompts list that have the same role.
314314
315315
The Deepseek API requires strictly alternating roles (user/assistant) in messages."
@@ -346,7 +346,9 @@ The Deepseek API requires strictly alternating roles (user/assistant) in message
346346
:context-window 64
347347
:input-cost 0.27
348348
:output-cost 1.10))))
349-
"Register a DeepSeek backend for gptel with NAME."
349+
"Register a DeepSeek backend for gptel with NAME.
350+
351+
For the meanings of the keyword arguments, see `gptel-make-openai'."
350352
(declare (indent 1))
351353
(let ((backend (gptel--make-deepseek
352354
:name name
@@ -438,3 +440,7 @@ see `gptel-make-openai'."
438440

439441
(provide 'gptel-openai-extras)
440442
;;; gptel-openai-extras.el ends here
443+
444+
;; Local Variables:
445+
;; byte-compile-warnings: (not docstrings)
446+
;; End:

gptel-openai.el

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ Throw an error if there is no match."
151151
(:copier gptel--copy-backend))
152152
name host header protocol stream
153153
endpoint key models url request-params
154-
curl-args)
154+
curl-args
155+
(coding-system nil :documentation "Can be set to `binary' if the backend expects non UTF-8 output."))
155156

156157
;;; OpenAI (ChatGPT)
157158
(cl-defstruct (gptel-openai (:constructor gptel--make-openai)
@@ -521,7 +522,7 @@ information, in the form
521522
(model-name . plist)
522523
523524
For a list of currently recognized plist keys, see
524-
`gptel--openai-models'. An example of a model specification
525+
`gptel--openai-models'. An example of a model specification
525526
including both kinds of specs:
526527
527528
:models
@@ -689,3 +690,7 @@ Example:
689690

690691
(provide 'gptel-openai)
691692
;;; gptel-openai.el ends here
693+
694+
;; Local Variables:
695+
;; byte-compile-warnings: (not docstrings)
696+
;; End:

0 commit comments

Comments
 (0)