Skip to content
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

How to set magit-gptcommit-llm-provider #6

Open
tsoernes opened this issue Oct 12, 2024 · 4 comments
Open

How to set magit-gptcommit-llm-provider #6

tsoernes opened this issue Oct 12, 2024 · 4 comments

Comments

@tsoernes
Copy link

I use the gptel backend. I have these providers registered there:

(setq-default gptel-model 'm-gpt-4o-mini-18072024)
(setq gptel-backend (gptel-make-azure "Azure-1-GPT-4o-mini"
                      :protocol "https"
                      :host "MYHOST.openai.azure.com"
                      :endpoint "/openai/deployments/m-gpt-4o-mini-18072024/chat/completions?api-version=2024-08-01-preview"
                      :stream t
                      :key #'gptel-api-key
                      :models '(m-gpt-4o-mini-18072024)))

How to set llm-provider?

@douo
Copy link
Owner

douo commented Oct 14, 2024

magit-gptcommit uses the variable gptel-backend by default. If your gptel-backend is configured correctly, magit-gptcommit should work as expected. However, please note that the gptel branch of magit-gptcommit is no longer maintained. I recommend using the latest version, which depends on https://github.com/ahyatt/llm

@tsoernes
Copy link
Author

gptel-backend works correctly standalone. When running generate, I get this error:

Debugger entered--Lisp error: (wrong-type-argument symbolp "user")
  json-serialize(((:role "user" :content "You are an expert programmer writing a commit message.\nYou went over every file diff that was changed in it.\n\nFirst Determine the best label for the diffs.\nHere are the labels you can choose from:\n- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)\n- chore: Updating libraries, copyrights or other repo setting, includes updating dependencies.\n- ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, GitHub Actions)\n- docs: Non-code changes, such as fixing typos or adding new documentation\n- feat: a commit of the type feat introduces a new feature to the codebase\n- fix: A commit of the type fix patches a bug in your codebase\n- perf: A code change that improves performance\n- refactor: A code change that neither fixes a bug nor adds a feature\n- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)\n- test: Adding missing tests or correcting existing tests\n\nThen summarize the commit into a single specific and cohesive theme.\nRemember to write in only one line, no more than 50 characters.\nWrite your response using the imperative tense following the kernel git commit style guide.\nWrite a high level title.\n\nTHE FILE DIFFS:\n```\nmodified   nysno/embedding.py\n@@ -1,4 +1,5 @@\n import os\n+from datetime import datetime\n from collections.abc import Generator\n from time import sleep, time\n from typing import Any\n@@ -98,9 +99,14 @@ class OpenAiEmbedding:\n         embedding_length = len(embeddings[0])\n         return pl.Series(embeddings, dtype=pl.Array(pl.Float64, embedding_length))\n \n-    def set_log_level(log_level):\n+    @staticmethod\n+    def set_log_level(log_level: int | str) -> None:\n         loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict]\n         openai_loggers = [logger for logger in loggers if logger.name.startswith(\"openai\")]\n+        for logger in openai_loggers:\n+            logger.setLevel(log_level)\n+            print(f\"Set level {log_level=} for logger {logger.name}\")\n+\n \n \n class EmbeddingDataset(OpenAiEmbedding):\n@@ -114,6 +120,7 @@ class EmbeddingDataset(OpenAiEmbedding):\n         model: str,\n         max_tokens_per_minute: int,\n         max_tokens_per_row: int = 8190,\n+        re_embed: bool = False,\n     ):\n         \"\"\"Initialize the EmbeddingDataset with the given data, text column,\n         model, and maximum tokens per minute.\n@@ -123,6 +130,7 @@ class EmbeddingDataset(OpenAiEmbedding):\n             model (str): The OpenAI model to use for embedding the text.\n             max_tokens_per_minute (int): The maximum number of tokens per minute.\n             max_tokens_per_row (int): The maximum number of tokens per row.\n+            re_embed (bool): Re-embed teksts that already have an embedding\n \n         \"\"\"\n         # Initialize the OpenAI client\n@@ -144,18 +152,17 @@ class EmbeddingDataset(OpenAiEmbedding):\n         self.token_count_column = f\"{text_column}.token_count\"\n         self.data = empty_string_to_null(self.data, self.text_column) \\\n             .drop_nulls(\n-            self.text_column\n+            subset=self.text_column\n         )\n-        self.data = self.data.with_columns(\n-            pl.Series(\n-                values=self.encoder.encode_batch(self.data[text_column]),  # type: ignore\n-            ).alias(self.tokens_column))\n+        if not re_embed:\n+            # Drop columns that already have embeddings\n+            self.data = self.data.filter(pl.col(self.embedding_column).is_null())\n+        tokens = self.encoder.encode_batch(self.data[text_column])  # type: ignore\n+        self.data = self.data.with_columns(pl.Series(self.tokens_column, tokens))\n         self.data = ...")) :null-object nil :false-object :json-false)
  (encode-coding-string (json-serialize data :null-object nil :false-object :json-false) 'utf-8)
  (let* ((url (let ((backend-url (let* (...) (progn ... ...)))) (if (functionp backend-url) (funcall backend-url) backend-url))) (data-json (encode-coding-string (json-serialize data :null-object nil :false-object :json-false) 'utf-8)) (headers (append '(("Content-Type" . "application/json")) (let* ((header (and t ...))) (if header (if (functionp header) (funcall header) header) nil))))) (if gptel-log-level (progn (if (eq gptel-log-level 'debug) (progn (gptel--log (json-serialize (mapcar ... headers) :null-object nil :false-object :json-false) "request headers"))) (gptel--log data-json "request body"))) (append gptel-curl--common-args (let* ((cl-x gptel-backend)) (progn (or (let* ((cl-x cl-x)) (progn (and ... t))) (signal 'wrong-type-argument (list 'gptel-backend cl-x))) (aref cl-x 10))) (list (format "-w(%s . %%{size_header})" token)) (if (length< data-json gptel-curl-file-size-threshold) (list (format "-d%s" data-json)) (let* ((temp-filename (make-temp-file "gptel-curl-data" nil ".json" data-json))) (let (cleanup-fn) (setq cleanup-fn #'(lambda ... ...)) (add-hook 'gptel-post-response-functions cleanup-fn) (list "--data-binary" (format "@%s" temp-filename))))) (if (not (string-empty-p gptel-proxy)) (progn (list "--proxy" gptel-proxy "--proxy-negotiate" "--proxy-user" ":"))) (let* ((--cl-var-- headers) (val nil) (key nil) (--cl-var-- nil)) (while (consp --cl-var--) (progn (setq val (car --cl-var--)) (setq key (car-safe (prog1 val ...)))) (setq --cl-var-- (cons (format "-H%s: %s" key val) --cl-var--)) (setq --cl-var-- (cdr --cl-var--))) (nreverse --cl-var--)) (list url)))
  gptel-curl--get-args(((:role "user" :content "You are an expert programmer writing a commit message.\nYou went over every file diff that was changed in it.\n\nFirst Determine the best label for the diffs.\nHere are the labels you can choose from:\n- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)\n- chore: Updating libraries, copyrights or other repo setting, includes updating dependencies.\n- ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, GitHub Actions)\n- docs: Non-code changes, such as fixing typos or adding new documentation\n- feat: a commit of the type feat introduces a new feature to the codebase\n- fix: A commit of the type fix patches a bug in your codebase\n- perf: A code change that improves performance\n- refactor: A code change that neither fixes a bug nor adds a feature\n- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)\n- test: Adding missing tests or correcting existing tests\n\nThen summarize the commit into a single specific and cohesive theme.\nRemember to write in only one line, no more than 50 characters.\nWrite your response using the imperative tense following the kernel git commit style guide.\nWrite a high level title.\n\nTHE FILE DIFFS:\n```\nmodified   nysno/embedding.py\n@@ -1,4 +1,5 @@\n import os\n+from datetime import datetime\n from collections.abc import Generator\n from time import sleep, time\n from typing import Any\n@@ -98,9 +99,14 @@ class OpenAiEmbedding:\n         embedding_length = len(embeddings[0])\n         return pl.Series(embeddings, dtype=pl.Array(pl.Float64, embedding_length))\n \n-    def set_log_level(log_level):\n+    @staticmethod\n+    def set_log_level(log_level: int | str) -> None:\n         loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict]\n         openai_loggers = [logger for logger in loggers if logger.name.startswith(\"openai\")]\n+        for logger in openai_loggers:\n+            logger.setLevel(log_level)\n+            print(f\"Set level {log_level=} for logger {logger.name}\")\n+\n \n \n class EmbeddingDataset(OpenAiEmbedding):\n@@ -114,6 +120,7 @@ class EmbeddingDataset(OpenAiEmbedding):\n         model: str,\n         max_tokens_per_minute: int,\n         max_tokens_per_row: int = 8190,\n+        re_embed: bool = False,\n     ):\n         \"\"\"Initialize the EmbeddingDataset with the given data, text column,\n         model, and maximum tokens per minute.\n@@ -123,6 +130,7 @@ class EmbeddingDataset(OpenAiEmbedding):\n             model (str): The OpenAI model to use for embedding the text.\n             max_tokens_per_minute (int): The maximum number of tokens per minute.\n             max_tokens_per_row (int): The maximum number of tokens per row.\n+            re_embed (bool): Re-embed teksts that already have an embedding\n \n         \"\"\"\n         # Initialize the OpenAI client\n@@ -144,18 +152,17 @@ class EmbeddingDataset(OpenAiEmbedding):\n         self.token_count_column = f\"{text_column}.token_count\"\n         self.data = empty_string_to_null(self.data, self.text_column) \\\n             .drop_nulls(\n-            self.text_column\n+            subset=self.text_column\n         )\n-        self.data = self.data.with_columns(\n-            pl.Series(\n-                values=self.encoder.encode_batch(self.data[text_column]),  # type: ignore\n-            ).alias(self.tokens_column))\n+        if not re_embed:\n+            # Drop columns that already have embeddings\n+            self.data = self.data.filter(pl.col(self.embedding_column).is_null())\n+        tokens = self.encoder.encode_batch(self.data[text_column])  # type: ignore\n+        self.data = self.data.with_columns(pl.Series(self.tokens_column, tokens))\n         self.da...")) "e76a472009ef05f4b61307bf8814ddec")
  (let* ((token (md5 (format "%s%s%s%s" (random) (emacs-pid) (user-full-name) (recent-keys)))) (args (gptel-curl--get-args (plist-get info :prompt) token)) (stream (and gptel-stream (let* ((cl-x gptel-backend)) (progn (or (let* ... ...) (signal ... ...)) (aref cl-x 5))))) (process (apply #'start-process "gptel-curl" (generate-new-buffer "*gptel-curl*") "curl" args))) (if (eq gptel-log-level 'debug) (progn (message "%S" args))) (magit-repository-local-set 'magit-gptcommit--active-worker (let ((key key) (process process) (message nil) (sections nil)) (progn (record 'magit-gptcommit--worker key process message sections)))) (save-current-buffer (set-buffer (process-buffer process)) (set-process-query-on-exit-flag process nil) (let* ((p (assq process gptel-curl--process-alist)) (v (nconc (list :token token :parser (let* ... ...) :callback (or callback ...) :transformer nil) info))) (progn (if p (setcdr p v) (setq gptel-curl--process-alist (cons (setq p ...) gptel-curl--process-alist))) v)) (if stream (progn (set-process-sentinel process #'magit-gptcommit--stream-cleanup) (set-process-filter process #'magit-gptcommit--stream-filter)) (set-process-sentinel process #'gptel-curl--sentinel))))
  magit-gptcommit-gptel-get-response("6c1d128a49ba7b9f19424aef24b97a51" (:prompt ((:role "user" :content "You are an expert programmer writing a commit message.\nYou went over every file diff that was changed in it.\n\nFirst Determine the best label for the diffs.\nHere are the labels you can choose from:\n- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)\n- chore: Updating libraries, copyrights or other repo setting, includes updating dependencies.\n- ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, GitHub Actions)\n- docs: Non-code changes, such as fixing typos or adding new documentation\n- feat: a commit of the type feat introduces a new feature to the codebase\n- fix: A commit of the type fix patches a bug in your codebase\n- perf: A code change that improves performance\n- refactor: A code change that neither fixes a bug nor adds a feature\n- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)\n- test: Adding missing tests or correcting existing tests\n\nThen summarize the commit into a single specific and cohesive theme.\nRemember to write in only one line, no more than 50 characters.\nWrite your response using the imperative tense following the kernel git commit style guide.\nWrite a high level title.\n\nTHE FILE DIFFS:\n```\nmodified   nysno/embedding.py\n@@ -1,4 +1,5 @@\n import os\n+from datetime import datetime\n from collections.abc import Generator\n from time import sleep, time\n from typing import Any\n@@ -98,9 +99,14 @@ class OpenAiEmbedding:\n         embedding_length = len(embeddings[0])\n         return pl.Series(embeddings, dtype=pl.Array(pl.Float64, embedding_length))\n \n-    def set_log_level(log_level):\n+    @staticmethod\n+    def set_log_level(log_level: int | str) -> None:\n         loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict]\n         openai_loggers = [logger for logger in loggers if logger.name.startswith(\"openai\")]\n+        for logger in openai_loggers:\n+            logger.setLevel(log_level)\n+            print(f\"Set level {log_level=} for logger {logger.name}\")\n+\n \n \n class EmbeddingDataset(OpenAiEmbedding):\n@@ -114,6 +120,7 @@ class EmbeddingDataset(OpenAiEmbedding):\n         model: str,\n         max_tokens_per_minute: int,\n         max_tokens_per_row: int = 8190,\n+        re_embed: bool = False,\n     ):\n         \"\"\"Initialize the EmbeddingDataset with the given data, text column,\n         model, and maximum tokens per minute.\n@@ -123,6 +130,7 @@ class EmbeddingDataset(OpenAiEmbedding):\n             model (str): The OpenAI model to use for embedding the text.\n             max_tokens_per_minute (int): The maximum number of tokens per minute.\n             max_tokens_per_row (int): The maximum number of tokens per row.\n+            re_embed (bool): Re-embed teksts that already have an embedding\n \n         \"\"\"\n         # Initialize the OpenAI client\n@@ -144,18 +152,17 @@ class EmbeddingDataset(OpenAiEmbedding):\n         self.token_count_column = f\"{text_column}.token_count\"\n         self.data = empty_string_to_null(self.data, self.text_column) \\\n             .drop_nulls(\n-            self.text_column\n+            subset=self.text_column\n         )\n-        self.data = self.data.with_columns(\n-            pl.Series(\n-                values=self.encoder.encode_batch(self.data[text_column]),  # type: ignore\n-            ).alias(self.tokens_column))\n+        if not re_embed:\n+            # Drop columns that already have embeddings\n+            self.data = self.data.filter(pl.col(self.embedding_column).is_null())\n+        tokens = self.encoder.encode_batch(self.data[text_column])  # type: ignore\n+        self.data = self.data.with_columns(pl.Series(self.tokens_column, tokens))\n      ...")) :buffer #<buffer magit: nysno> :position #<marker at 52995 in magit: nysno>) magit-gptcommit--stream-insert-response)
  (if (and worker (equal key oldkey)) (progn (assq-delete-all buf (eieio-oref worker 'sections)) (insert (eieio-oref (magit-repository-local-get 'magit-gptcommit--active-worker) 'message)) (insert "\n")) (if worker (progn (magit-gptcommit-abort))) (insert "\n") (magit-gptcommit-gptel-get-response key (list :prompt (list (list :role "user" :content (format magit-gptcommit-prompt diff))) :buffer buf :position (point-marker)) #'magit-gptcommit--stream-insert-response))
  (catch 'cancel-section (magit-insert-heading (format (propertize "GPT commit: %s" 'font-lock-face 'magit-section-heading) (propertize "Waiting" 'font-lock-face 'warning))) (if (and worker (equal key oldkey)) (progn (assq-delete-all buf (eieio-oref worker 'sections)) (insert (eieio-oref (magit-repository-local-get 'magit-gptcommit--active-worker) 'message)) (insert "\n")) (if worker (progn (magit-gptcommit-abort))) (insert "\n") (magit-gptcommit-gptel-get-response key (list :prompt (list (list :role "user" :content (format magit-gptcommit-prompt diff))) :buffer buf :position (point-marker)) #'magit-gptcommit--stream-insert-response)) (magit-insert-section--finish section693))
  (let* ((section693 (magit-insert-section--create 'gptcommit nil nil)) (magit-insert-section--current section693) (magit-insert-section--oldroot (or magit-insert-section--oldroot (and (not magit-insert-section--parent) (prog1 magit-root-section (setq magit-root-section section693))))) (magit-insert-section--parent section693)) (catch 'cancel-section (magit-insert-heading (format (propertize "GPT commit: %s" 'font-lock-face 'magit-section-heading) (propertize "Waiting" 'font-lock-face 'warning))) (if (and worker (equal key oldkey)) (progn (assq-delete-all buf (eieio-oref worker 'sections)) (insert (eieio-oref (magit-repository-local-get 'magit-gptcommit--active-worker) 'message)) (insert "\n")) (if worker (progn (magit-gptcommit-abort))) (insert "\n") (magit-gptcommit-gptel-get-response key (list :prompt (list (list :role "user" :content (format magit-gptcommit-prompt diff))) :buffer buf :position (point-marker)) #'magit-gptcommit--stream-insert-response)) (magit-insert-section--finish section693)) section693)
  (progn (let* ((section693 (magit-insert-section--create 'gptcommit nil nil)) (magit-insert-section--current section693) (magit-insert-section--oldroot (or magit-insert-section--oldroot (and (not magit-insert-section--parent) (prog1 magit-root-section (setq magit-root-section section693))))) (magit-insert-section--parent section693)) (catch 'cancel-section (magit-insert-heading (format (propertize "GPT commit: %s" 'font-lock-face 'magit-section-heading) (propertize "Waiting" 'font-lock-face 'warning))) (if (and worker (equal key oldkey)) (progn (assq-delete-all buf (eieio-oref worker 'sections)) (insert (eieio-oref (magit-repository-local-get ...) 'message)) (insert "\n")) (if worker (progn (magit-gptcommit-abort))) (insert "\n") (magit-gptcommit-gptel-get-response key (list :prompt (list (list :role "user" :content ...)) :buffer buf :position (point-marker)) #'magit-gptcommit--stream-insert-response)) (magit-insert-section--finish section693)) section693) (let ((section (car (last (eieio-oref magit-root-section 'children)))) (worker (magit-repository-local-get 'magit-gptcommit--active-worker))) (eieio-oset worker 'sections (cons (cons buf section) (eieio-oref worker 'sections)))) (set (make-local-variable 'magit-inhibit-refresh) t))
  (if msg (let* ((section692 (magit-insert-section--create 'gptcommit nil nil)) (magit-insert-section--current section692) (magit-insert-section--oldroot (or magit-insert-section--oldroot (and (not magit-insert-section--parent) (prog1 magit-root-section (setq magit-root-section section692))))) (magit-insert-section--parent section692)) (catch 'cancel-section (magit-insert-heading (format (propertize "GPT commit: %s" 'font-lock-face 'magit-section-heading) (propertize "Cache" 'font-lock-face 'success))) (insert msg) (insert "\n") (magit-repository-local-set 'magit-gptcommit--last-message msg) (magit-insert-section--finish section692)) section692) (progn (let* ((section693 (magit-insert-section--create 'gptcommit nil nil)) (magit-insert-section--current section693) (magit-insert-section--oldroot (or magit-insert-section--oldroot (and (not magit-insert-section--parent) (prog1 magit-root-section ...)))) (magit-insert-section--parent section693)) (catch 'cancel-section (magit-insert-heading (format (propertize "GPT commit: %s" 'font-lock-face 'magit-section-heading) (propertize "Waiting" 'font-lock-face 'warning))) (if (and worker (equal key oldkey)) (progn (assq-delete-all buf (eieio-oref worker ...)) (insert (eieio-oref ... ...)) (insert "\n")) (if worker (progn (magit-gptcommit-abort))) (insert "\n") (magit-gptcommit-gptel-get-response key (list :prompt (list ...) :buffer buf :position (point-marker)) #'magit-gptcommit--stream-insert-response)) (magit-insert-section--finish section693)) section693) (let ((section (car (last (eieio-oref magit-root-section ...)))) (worker (magit-repository-local-get 'magit-gptcommit--active-worker))) (eieio-oset worker 'sections (cons (cons buf section) (eieio-oref worker 'sections)))) (set (make-local-variable 'magit-inhibit-refresh) t)))
  (let* ((msg (and t (and (not no-cache) (magit-gptcommit--cache-get key))))) (if msg (let* ((section692 (magit-insert-section--create 'gptcommit nil nil)) (magit-insert-section--current section692) (magit-insert-section--oldroot (or magit-insert-section--oldroot (and (not magit-insert-section--parent) (prog1 magit-root-section ...)))) (magit-insert-section--parent section692)) (catch 'cancel-section (magit-insert-heading (format (propertize "GPT commit: %s" 'font-lock-face 'magit-section-heading) (propertize "Cache" 'font-lock-face 'success))) (insert msg) (insert "\n") (magit-repository-local-set 'magit-gptcommit--last-message msg) (magit-insert-section--finish section692)) section692) (progn (let* ((section693 (magit-insert-section--create 'gptcommit nil nil)) (magit-insert-section--current section693) (magit-insert-section--oldroot (or magit-insert-section--oldroot (and ... ...))) (magit-insert-section--parent section693)) (catch 'cancel-section (magit-insert-heading (format (propertize "GPT commit: %s" ... ...) (propertize "Waiting" ... ...))) (if (and worker (equal key oldkey)) (progn (assq-delete-all buf ...) (insert ...) (insert "\n")) (if worker (progn ...)) (insert "\n") (magit-gptcommit-gptel-get-response key (list :prompt ... :buffer buf :position ...) #'magit-gptcommit--stream-insert-response)) (magit-insert-section--finish section693)) section693) (let ((section (car (last ...))) (worker (magit-repository-local-get 'magit-gptcommit--active-worker))) (eieio-oset worker 'sections (cons (cons buf section) (eieio-oref worker 'sections)))) (set (make-local-variable 'magit-inhibit-refresh) t))))
  (let* ((diff (magit-gptcommit--retrieve-stashed-diff)) (key (magit-gptcommit--cache-key diff)) (worker (magit-repository-local-get 'magit-gptcommit--active-worker)) (oldkey (and worker (eieio-oref worker 'key)))) (let* ((msg (and t (and (not no-cache) (magit-gptcommit--cache-get key))))) (if msg (let* ((section692 (magit-insert-section--create 'gptcommit nil nil)) (magit-insert-section--current section692) (magit-insert-section--oldroot (or magit-insert-section--oldroot (and ... ...))) (magit-insert-section--parent section692)) (catch 'cancel-section (magit-insert-heading (format (propertize "GPT commit: %s" ... ...) (propertize "Cache" ... ...))) (insert msg) (insert "\n") (magit-repository-local-set 'magit-gptcommit--last-message msg) (magit-insert-section--finish section692)) section692) (progn (let* ((section693 (magit-insert-section--create ... nil nil)) (magit-insert-section--current section693) (magit-insert-section--oldroot (or magit-insert-section--oldroot ...)) (magit-insert-section--parent section693)) (catch 'cancel-section (magit-insert-heading (format ... ...)) (if (and worker ...) (progn ... ... ...) (if worker ...) (insert "\n") (magit-gptcommit-gptel-get-response key ... ...)) (magit-insert-section--finish section693)) section693) (let ((section (car ...)) (worker (magit-repository-local-get ...))) (eieio-oset worker 'sections (cons (cons buf section) (eieio-oref worker ...)))) (set (make-local-variable 'magit-inhibit-refresh) t)))))
  (progn (magit-repository-local-delete 'magit-gptcommit--last-message) (let* ((diff (magit-gptcommit--retrieve-stashed-diff)) (key (magit-gptcommit--cache-key diff)) (worker (magit-repository-local-get 'magit-gptcommit--active-worker)) (oldkey (and worker (eieio-oref worker 'key)))) (let* ((msg (and t (and (not no-cache) (magit-gptcommit--cache-get key))))) (if msg (let* ((section692 (magit-insert-section--create ... nil nil)) (magit-insert-section--current section692) (magit-insert-section--oldroot (or magit-insert-section--oldroot ...)) (magit-insert-section--parent section692)) (catch 'cancel-section (magit-insert-heading (format ... ...)) (insert msg) (insert "\n") (magit-repository-local-set 'magit-gptcommit--last-message msg) (magit-insert-section--finish section692)) section692) (progn (let* ((section693 ...) (magit-insert-section--current section693) (magit-insert-section--oldroot ...) (magit-insert-section--parent section693)) (catch 'cancel-section (magit-insert-heading ...) (if ... ... ... ... ...) (magit-insert-section--finish section693)) section693) (let ((section ...) (worker ...)) (eieio-oset worker 'sections (cons ... ...))) (set (make-local-variable 'magit-inhibit-refresh) t))))) (eieio-oset magit-root-section 'children (magit-gptcommit--move-last-to-position (eieio-oref magit-root-section 'children) pos)))
  (if magit-insert-section--parent (progn (magit-repository-local-delete 'magit-gptcommit--last-message) (let* ((diff (magit-gptcommit--retrieve-stashed-diff)) (key (magit-gptcommit--cache-key diff)) (worker (magit-repository-local-get 'magit-gptcommit--active-worker)) (oldkey (and worker (eieio-oref worker 'key)))) (let* ((msg (and t (and ... ...)))) (if msg (let* ((section692 ...) (magit-insert-section--current section692) (magit-insert-section--oldroot ...) (magit-insert-section--parent section692)) (catch 'cancel-section (magit-insert-heading ...) (insert msg) (insert "\n") (magit-repository-local-set ... msg) (magit-insert-section--finish section692)) section692) (progn (let* (... ... ... ...) (catch ... ... ... ...) section693) (let (... ...) (eieio-oset worker ... ...)) (set (make-local-variable ...) t))))) (eieio-oset magit-root-section 'children (magit-gptcommit--move-last-to-position (eieio-oref magit-root-section 'children) pos))) nil)
  (let* ((buf (and t (current-buffer))) (pos (and buf (magit-gptcommit--goto-target-position condition))) (inhibit-read-only (and pos t)) (magit-insert-section--parent (and inhibit-read-only magit-root-section))) (if magit-insert-section--parent (progn (magit-repository-local-delete 'magit-gptcommit--last-message) (let* ((diff (magit-gptcommit--retrieve-stashed-diff)) (key (magit-gptcommit--cache-key diff)) (worker (magit-repository-local-get 'magit-gptcommit--active-worker)) (oldkey (and worker (eieio-oref worker ...)))) (let* ((msg (and t ...))) (if msg (let* (... ... ... ...) (catch ... ... ... ... ... ...) section692) (progn (let* ... ... section693) (let ... ...) (set ... t))))) (eieio-oset magit-root-section 'children (magit-gptcommit--move-last-to-position (eieio-oref magit-root-section 'children) pos))) nil))
  (save-excursion (let* ((buf (and t (current-buffer))) (pos (and buf (magit-gptcommit--goto-target-position condition))) (inhibit-read-only (and pos t)) (magit-insert-section--parent (and inhibit-read-only magit-root-section))) (if magit-insert-section--parent (progn (magit-repository-local-delete 'magit-gptcommit--last-message) (let* ((diff (magit-gptcommit--retrieve-stashed-diff)) (key (magit-gptcommit--cache-key diff)) (worker (magit-repository-local-get ...)) (oldkey (and worker ...))) (let* ((msg ...)) (if msg (let* ... ... section692) (progn ... ... ...)))) (eieio-oset magit-root-section 'children (magit-gptcommit--move-last-to-position (eieio-oref magit-root-section 'children) pos))) nil)))
  magit-gptcommit--insert(staged t)
  (let nil (magit-gptcommit--insert 'staged t))
  (cond ((eq x1249 'magit-status-mode) (let nil (magit-gptcommit--insert 'staged t))) ((eq x1249 'magit-diff-mode) 'nil) ((buffer-local-value 'with-editor-mode val) 'nil) (t (let nil (user-error "Not in a magit status buffer or with-editor buffer"))))
  (let* ((val (current-buffer)) (x1249 (buffer-local-value 'major-mode val))) (cond ((eq x1249 'magit-status-mode) (let nil (magit-gptcommit--insert 'staged t))) ((eq x1249 'magit-diff-mode) 'nil) ((buffer-local-value 'with-editor-mode val) 'nil) (t (let nil (user-error "Not in a magit status buffer or with-editor buffer")))))
  magit-gptcommit-generate()
  funcall-interactively(magit-gptcommit-generate)
  command-execute(magit-gptcommit-generate record)
  execute-extended-command(nil "magit-gptcommit-generate" nil)
  funcall-interactively(execute-extended-command nil "magit-gptcommit-generate" nil)
  command-execute(execute-extended-command)

@douo
Copy link
Owner

douo commented Oct 15, 2024

What version of gptel are you using? The magit-gptcommit on the gptel branch heavily relies on gptel(0.6.0)'s internal implementation, which is why the gptel branch is no longer recommended for use.

@avishefi
Copy link
Collaborator

@tsoernes This is similar to: #2 (comment), see if this helps. In any case gptel was replaced by llm since then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants