Open e665107 opened 11 months ago
(setq org-ai-openai-api-token "~/.emacs.d/authinfo.gpg")
seems wrong, you want the token itself.
By default it will be set to (auth-source-pick-first-password :host "api.openai.com" :user "org-ai")
, i.e. that you should have a line like
machine api.openai.com login org-ai password sk-...
in your ~/.authinfo.gpg
file. Alternatively, you can set the token directly with (setq org-ai-openai-api-token "sk-...")
.
Hi, friend: I have do that depend on your suggestion. But it doesn't work! Where do i need change?
(setq org-ai-use-auth-source nil)
(use-package org-ai
:ensure t
:commands (org-ai-mode
org-ai-global-mode)
:init
(add-hook 'org-mode-hook #'org-ai-mode) ; enable org-ai in org-mode
(org-ai-global-mode) ; installs global keybindings on C-c M-a
;; (setq org-ai-openai-api-token "~/.emacs.d/authinfo.gpg")
(setq org-ai-openai-api-token "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")
:config
(setq org-ai-default-chat-model "gpt-3.5") ; if you are on the gpt-4 beta:
(org-ai-install-yasnippets)) ; if you are using yasnippet and want ai
snippets
Run M-x org-ai-prompt
, it should popup an error message if the command fails. Alternatively run C-c C-c
on an org-mode ai block and afterwards run M-x org-ai-open-request-buffer
. The request buffer might have an erro message in it as well.
I have do that as your suggestion: following is the message printed, when i pressed the C-c C-c, it gets stuck in the Contacting host: api.openai.com:443! Do i need log out from the chatgpt official website?
REQUEST {"messages":[{"role":"user","content":"nil"}],"model":"gpt-3.5-turbo","stream":true} Contacting host: api.openai.com:443 Quit REQUEST {"messages":[{"role":"user","content":"nil\nchatgpt"}],"model":"gpt-3.5-turbo","stream":true} Contacting host: api.openai.com:443 REQUEST {"messages":[{"role":"user","content":"hello"}],"model":"gpt-3.5-turbo","stream":true} Contacting host: api.openai.com:443 Mark set Mark activated
Do i need log out from the chatgpt official website?
No that should not be necessary. Can you run M-x org-ai-open-request-buffer
after running a prompt. There might be an error message in there. It's typically a mismatch in the API key or something.
Yes, but after i have run the org-ai-open-request-buffer, it prints nothing,
Change the model from gpt-3.5
to gpt-3.5-turbo
.
If this doesn't help please evaluate the following expression and post the result:
(let* ((url-request-extra-headers `(("Authorization" . ,(encode-coding-string (string-join `("Bearer" ,(org-ai--openai-get-token)) " ") 'utf-8))
("Content-Type" . "application/json")))
(url-request-method "POST")
(url-request-data (org-ai--payload :messages (org-ai--collect-chat-messages "Hello, how are you?")
:model "gpt-3.5-turbo"
:stream t)))
(pop-to-buffer (url-retrieve-synchronously org-ai-openai-chat-endpoint)))
I have do that as you suggest! The result is :
Contacting host: api.openai.com:443
open-network-stream: make client process failed: Connection timed out, :name, api.openai.com, :buffer, #
Mark set [2 times]
Hi , friend When i press C-c C-c , i get the notice as follow:
REQUEST {"messages":[{"role":"user","content":"hello"}],"model":"gpt-3.5","stream":true} Contacting host: api.openai.com:443
I have got the api key and set it like this : (setq org-ai-use-auth-source nil)
(use-package org-ai :ensure t :commands (org-ai-mode org-ai-global-mode) :init (add-hook 'org-mode-hook #'org-ai-mode) ; enable org-ai in org-mode (org-ai-global-mode) ; installs global keybindings on C-c M-a (setq org-ai-openai-api-token "~/.emacs.d/authinfo.gpg") :config (setq org-ai-default-chat-model "gpt-3.5") ; if you are on the gpt-4 beta: (org-ai-install-yasnippets)) ; if you are using yasnippet and want
ai
snippetsWhere do i get stuck in?