copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.83k stars 128 forks source link

Suggestion: Advanced Parameters #330

Closed xnwh12 closed 1 month ago

xnwh12 commented 3 months ago

something like

"github.copilot.advanced": {
        "debug.overrideCAPIUrl": "http://ip:port/v1",
        "debug.overrideProxyUrl": "http://ip:port",
        "debug.chatOverrideProxyUrl": "http://ip:port/v1/chat/completions",
        "authProvider": "github-enterprise"
    },
    "github-enterprise.uri": "https://xxx.xxx",

To use a customized Copilot, such as a local model, and more.

knilink commented 2 months ago

those can be set by env var

AGENT_DEBUG_OVERRIDE_ENGINE
AGENT_DEBUG_OVERRIDE_PROXY_URL
AGENT_DEBUG_OVERRIDE_CAPI_URL
AGENT_DEBUG_USE_EDITOR_FETCHER
AGENT_DEBUG_OVERRIDE_RELATED_FILES

as for enterprise uri if i'm not mistaken can by set by setEditorInfo {editorInfo: {authProvider:{url:'https://xxx.xxx'}}

xnwh12 commented 1 month ago

those can be set by env var

AGENT_DEBUG_OVERRIDE_ENGINE
AGENT_DEBUG_OVERRIDE_PROXY_URL
AGENT_DEBUG_OVERRIDE_CAPI_URL
AGENT_DEBUG_USE_EDITOR_FETCHER
AGENT_DEBUG_OVERRIDE_RELATED_FILES

as for enterprise uri if i'm not mistaken can by set by setEditorInfo {editorInfo: {authProvider:{url:'https://xxx.xxx'}}

Thank you for your enthusiastic response. May I ask for the specific configuration file? As a newbie, I really appreciate your answer. Here is my configuration, which I'm not very familiar with. I look forward to your help.


 (use-package copilot
  :straight (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))
  :ensure t
  :config
  (setenv "AGENT_DEBUG_OVERRIDE_CAPI_URL" "https://xxx/v1")
  (setenv "AGENT_DEBUG_OVERRIDE_PROXY_URL" "https://xxx"))
(add-hook 'prog-mode-hook 'copilot-mode) 
knilink commented 1 month ago

for authProvider it's done by sending another setEditorInfo request to update the info with authProvide, or just adding it to copilot.el https://github.com/copilot-emacs/copilot.el/blob/8ddfbee370d4c6705b3bbd9532d0c722a78ba844/copilot.el#L331-L335

             (copilot--async-request 'setEditorInfo
                                     `(:editorInfo (:name "Emacs" :version ,emacs-version)
                                                   :editorPluginInfo (:name "copilot.el" :version ,copilot-version)
+                                                  :authProvider (:url "https://xxx.xxx")
                                                   ,@(when copilot-network-proxy
                                                       `(:networkProxy ,copilot-network-proxy))))))))))

debug.chatOverrideProxyUrl isn't something that i know of.

also one thing worth mention is the language server will reject url protocol that is not https unless it's dev built.

if you are still struggling to get it works then this PR may help understanding what's happening inside the server and whether the request are sent to the expected url

xnwh12 commented 1 month ago

Thanks a lot! It finally works with the following configuration:

(use-package copilot
  :straight (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))
  :ensure t
  :config
  (setenv "AGENT_DEBUG_OVERRIDE_CAPI_URL" "https://xxx/v1")
  (setenv "AGENT_DEBUG_OVERRIDE_PROXY_URL" "https://xxx"))
(add-hook 'prog-mode-hook 'copilot-mode) 
             (copilot--async-request 'setEditorInfo
                                     `(:editorInfo (:name "Emacs" :version ,emacs-version)
                                                   :editorPluginInfo (:name "copilot.el" :version ,copilot-version)
+                                                  :authProvider (:url "https://xxx.xxx")
                                                   ,@(when copilot-network-proxy
                                                       `(:networkProxy ,copilot-network-proxy))))))))))