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

Can you help me solve the connection waiting? #68

Open
e665107 opened this issue Jul 29, 2023 · 8 comments
Open

Can you help me solve the connection waiting? #68

e665107 opened this issue Jul 29, 2023 · 8 comments

Comments

@e665107
Copy link

e665107 commented Jul 29, 2023

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 snippets

Where do i get stuck in?

@rksm
Copy link
Owner

rksm commented Aug 2, 2023

(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-...").

@e665107
Copy link
Author

e665107 commented Aug 7, 2023

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

@rksm
Copy link
Owner

rksm commented Aug 8, 2023

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.

@e665107
Copy link
Author

e665107 commented Aug 8, 2023

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

@rksm
Copy link
Owner

rksm commented Aug 8, 2023

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.

@e665107
Copy link
Author

e665107 commented Aug 8, 2023

Yes, but after i have run the org-ai-open-request-buffer, it prints nothing,

image

@rksm
Copy link
Owner

rksm commented Aug 8, 2023

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)))

@e665107
Copy link
Author

e665107 commented Aug 9, 2023

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, #, :host, api.openai.com, :service, 443, :nowait, nil, :tls-parameters, nil, :coding, nil

Mark set [2 times]
image

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

2 participants