Function: gptel--fsm-transition

gptel--fsm-transition is a natively compiled function defined in gptel-request.el.

Signature

(gptel--fsm-transition MACHINE &optional NEW-STATE)

Documentation

Move MACHINE to its next state.

MACHINE is an instance of gptel-fsm.

The next state is NEW-STATE if given. Otherwise it is determined automatically from MACHINE's transition table.

Source Code

;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel-request.el
(defun gptel--fsm-transition (machine &optional new-state)
  "Move MACHINE to its next state.

MACHINE is an instance of `gptel-fsm'.

The next state is NEW-STATE if given.  Otherwise it is determined
automatically from MACHINE's transition table."
  (unless new-state (setq new-state (gptel--fsm-next machine)))
  (push (gptel-fsm-state machine)
        (plist-get (gptel-fsm-info machine) :history))
  (setf (gptel-fsm-state machine) new-state)
  (when-let* ((handlers (alist-get new-state (gptel-fsm-handlers machine))))
    (mapc (lambda (h) (funcall h machine)) handlers)))