aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-22 15:34:07 -0500
committerCraig Jennings <c@cjennings.net>2026-05-22 15:34:07 -0500
commit759597d42102778e91f7f62ef1b13b9b041efc75 (patch)
treea47b52786266ee8c486541d9526293393fea6103 /modules
parent74a8b45badb807fc1b7b5242887dd5b7093ddb87 (diff)
downloaddotemacs-759597d42102778e91f7f62ef1b13b9b041efc75.tar.gz
dotemacs-759597d42102778e91f7f62ef1b13b9b041efc75.zip
fix(ai-config): require gptel backend libs so the fork's constructors load
cj/toggle-gptel and gptel chat errored with "Symbol's function definition is void: gptel-make-anthropic". The local gptel fork on :load-path with :ensure nil ships no generated autoloads, so (require 'gptel) loads gptel.el but never gptel-anthropic.el or gptel-openai.el, where the gptel-make-* constructors live. cj/ensure-gptel-backends then reached gptel-make-anthropic before it was defined. cj/ensure-gptel-backends now requires gptel-anthropic and gptel-openai first, through a small cj/--gptel-load-backend-libs helper. Verified end-to-end: with the fork on load-path, the constructors are fbound and both backends build.
Diffstat (limited to 'modules')
-rw-r--r--modules/ai-config.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/ai-config.el b/modules/ai-config.el
index ddbe91b87..8cf70ee42 100644
--- a/modules/ai-config.el
+++ b/modules/ai-config.el
@@ -122,9 +122,19 @@ HOST and USER must be strings that identify the credential to return."
(setq cj/openai-api-key-cached
(cj/auth-source-secret "api.openai.com" "apikey"))))
+(defun cj/--gptel-load-backend-libs ()
+ "Require the gptel backend libraries so their `gptel-make-*' constructors exist.
+The local fork (`:load-path \"~/code/gptel\"', `:ensure nil') ships no generated
+autoloads, so requiring `gptel' alone never loads `gptel-anthropic' /
+`gptel-openai', where the constructors are defined."
+ (require 'gptel-anthropic)
+ (require 'gptel-openai))
+
(defun cj/ensure-gptel-backends ()
"Initialize GPTel backends if they are not already available.
-Call this only after loading `gptel' so the backend constructors exist."
+Loads the backend libraries first so the `gptel-make-*' constructors are
+defined even when gptel is the local fork without generated autoloads."
+ (cj/--gptel-load-backend-libs)
(unless gptel-claude-backend
(setq gptel-claude-backend
(gptel-make-anthropic