diff --git a/README.org b/README.org index 8a15663..202a961 100644 --- a/README.org +++ b/README.org @@ -34,6 +34,8 @@ builder to create custom commands without having to write code. - [[#built-in-action-functions][Built-in Action Functions]] - [[#built-in-grounding-functions][Built-in Grounding Functions]] - [[#customization][Customization]] + - [[#openai-url][OpenAI URL]] + - [[#api-options][API Options]] - [[#animated-gifs][Animated Gifs]] * Requirements @@ -468,7 +470,12 @@ Replace =%= with =%%= in TEXT to avoid format string errors calling ~message~. *** ~robby-remove-trailing-end-of-line~ Remove the end of line character at the very end of a string if present. * Customization -Use ~customize-group~ | ~robby~ to see the various customization options. Robby will validate values as appropriate, for example ~robby-chat-temperature~ values must be between =0.0= and =2.0=. +Use ~customize-group~ | ~robby~ to see the various customization options. Robby will validate values as appropriate, for example ~robby-chat-temperature~ values must be between =0.0= and =2.0=. + +** OpenAI URL +Customize the ~robby-chat-api~ variable to use a different OpenAI compatible provider. By default it is set to =https://api.openai.com/v1/chat/completions=. + +** API Options The ~robby-chat-api~ customization group species the OpenAI API options. Here are a few important ones: diff --git a/robby-customization.el b/robby-customization.el index 9c934a5..de2b8d7 100644 --- a/robby-customization.el +++ b/robby-customization.el @@ -88,6 +88,11 @@ It should include a `%s' placeholder for the spinner." :type 'string :group 'robby) +(defcustom robby-api-url "https://api.openai.com/v1/chat/completions" + "URL to use for OpenAI API requests." + :type 'string + :group 'robby) + ;;; chat api options (defgroup robby-chat-api nil "Options to pass to the chat API." diff --git a/robby-request.el b/robby-request.el index be0cde9..0f1fd13 100644 --- a/robby-request.el +++ b/robby-request.el @@ -13,12 +13,10 @@ (require 'url-vars) (require 'robby-api-key) +(require 'robby-customization) (require 'robby-logging) (require 'robby-utils) -;;; constants -(defconst robby--request-url "https://api.openai.com/v1/chat/completions") - ;;; util functions (defun robby--request-parse-error-data (data) "Get error from response DATA." @@ -102,7 +100,7 @@ STREAMP is non-nil if the response is a stream." "curl" proc-buffer "curl" - robby--request-url + robby-api-url curl-options) (error (funcall on-error err))))) (let ((remaining "") @@ -163,7 +161,7 @@ ON-ERROR is the callback for when an error is received." (message-log-max nil)) (robby--log (format "#url-retrieve request JSON payload:\n%s\n" url-request-data)) (url-retrieve - robby--request-url + robby-api-url (lambda (_status) (goto-char (point-min)) (re-search-forward "^{")