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

GPT-4 supports. #11

Open
hongyi-zhao opened this issue May 11, 2023 · 9 comments
Open

GPT-4 supports. #11

hongyi-zhao opened this issue May 11, 2023 · 9 comments

Comments

@hongyi-zhao
Copy link

hongyi-zhao commented May 11, 2023

I tried this package with GPT-4 using the following configuration:

(defvar my-openai-api-key "sk-xxx")
(use-package openai
  :straight (openai :type git :host github :repo "emacs-openai/openai")
  :config
  (setq openai-key my-openai-api-key)
  )

(use-package chatgpt
  :straight (chatgpt :type git :host github :repo "emacs-openai/chatgpt")
  :config
  (setq chatgpt-model "gpt-4")
  )

But when I try to do query, the following error will be triggered:

Error in post-command-hook (chatgpt-input--post-command): (error "Cannot resize the root window of a frame")
hungry-delete-impl: End of buffer
[error] request--callback: peculiar error: 404
Internal error: 404

Regards,
Zhao

@jcs090218
Copy link
Member

jcs090218 commented May 11, 2023

It seems like it is not available yet. 404 is expected unless you have already gained access from them through the waitlist. Moreover, the model name should be gpt-4-0314 and not gpt-4 (see their official page, the API section).

@hongyi-zhao
Copy link
Author

hongyi-zhao commented May 11, 2023

But https://platform.openai.com/docs/models/gpt-4 lists the following:

Latest model Description Max tokens Training data
gpt-4 More capable than any GPT-3.5 model, able to do more complex tasks, and optimized for chat. Will be updated with our latest model iteration. 8,192 tokens Up to Sep 2021
gpt-4-0314 Snapshot of gpt-4 from March 14th 2023. Unlike gpt-4, this model will not receive updates, and will be deprecated 3 months after a new version is released. 8,192 tokens Up to Sep 2021
gpt-4-32k Same capabilities as the base gpt-4 mode but with 4x the context length. Will be updated with our latest model iteration. 32,768 tokens Up to Sep 2021
gpt-4-32k-0314 Snapshot of gpt-4-32 from March 14th 2023. Unlike gpt-4-32k, this model will not receive updates, and will be deprecated 3 months after a new version is released. 32,768 tokens Up to Sep 2021

Based on my tries, none of them working, but I really have access to it, as shown below:

image

@jcs090218
Copy link
Member

But https://platform.openai.com/docs/models/gpt-4 lists the following:

Ah, okay. Then you are right! Sorry, I only have a quick glance on this. 😅

Can you try raw curl? Does it work? I have no way to test this since I don't have access to the GPT-4 model. 😓

@hongyi-zhao
Copy link
Author

hongyi-zhao commented May 12, 2023

I tried with the example shown here, but failed:

werner@X10DAi:~$ curl -x socks5h://127.0.0.1:18890 -i -X POST \
   -H "Authorization:Bearer sk-xxx" \
   -H "Content-Type:application/json" \
   -d \
'{"model":"gpt-4",
 "max_tokens": 2000,
  "temperature": 0.9,
  "n": 1,
   "stream": false,
 "messages":
[
   {
"role": "user",
"content": "add sample prompt description"
},
  { "role": "user", "content": "From now on call me test" },
   { "role": "assistant", "content": "From I live in the Kingdom of ruv" },
  { "role": "system", "content": "Amazing Right, your name is kid." },
  { "role": "user", "content": "tell me a story" }
]
}' \
 'https://api.openai.com/v1/chat/completions'
HTTP/2 404 
date: Fri, 12 May 2023 01:08:18 GMT
content-type: application/json; charset=utf-8
content-length: 179
vary: Origin
x-request-id: 73865e0152a53e025046c31a7def82b4
strict-transport-security: max-age=15724800; includeSubDomains
cf-cache-status: DYNAMIC
server: cloudflare
cf-ray: 7c5ec5119952f234-KHH
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

{
    "error": {
        "message": "The model: `gpt-4` does not exist",
        "type": "invalid_request_error",
        "param": null,
        "code": "model_not_found"
    }
}

But it really works for gpt-3.5-turbo:

werner@X10DAi:~$ curl -x socks5h://127.0.0.1:18890 -i -X POST \
  -H "Authorization:Bearer sk-xxx"  \
  -H "Content-Type:application/json"  \
  -d '{"model":"gpt-3.5-turbo",
 "max_tokens": 20,
  "temperature": 0.9,
  "n": 1,
   "stream": false,
 "messages":
[
   {
"role": "user",
"content": "add sample prompt description"
},
  { "role": "user", "content": "From now on call me test" },
   { "role": "assistant", "content": "From I live in the Kingdom of ruv" },
  { "role": "system", "content": "Amazing Right, your name is kid." },
  { "role": "user", "content": "tell me a story" }
]
}'  'https://api.openai.com/v1/chat/completions'
HTTP/2 200 
date: Fri, 12 May 2023 01:11:12 GMT
content-type: application/json
content-length: 376
access-control-allow-origin: *
cache-control: no-cache, must-revalidate
openai-model: gpt-3.5-turbo-0301
openai-organization: user-cycirv7tg3umtkc0ijlplsz5
openai-processing-ms: 689
openai-version: 2020-10-01
strict-transport-security: max-age=15724800; includeSubDomains
x-ratelimit-limit-requests: 3
x-ratelimit-limit-tokens: 40000
x-ratelimit-remaining-requests: 2
x-ratelimit-remaining-tokens: 39941
x-ratelimit-reset-requests: 20s
x-ratelimit-reset-tokens: 88ms
x-request-id: af35ab93131133f27139821ca070b0ec
cf-cache-status: DYNAMIC
server: cloudflare
cf-ray: 7c5ec94c0ed2f1d0-KHH
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

{"id":"chatcmpl-7FBbMy8ckS9HuXjpY5cxv1EJzMvWg","object":"chat.completion","created":1683853872,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":59,"completion_tokens":20,"total_tokens":79},"choices":[{"message":{"role":"assistant","content":"Once upon a time, there was a small village nestled in the middle of a dense forest. The"},"finish_reason":"length","index":0}]}

See here for the related discussion.

Could you please give an example template?

@hongyi-zhao
Copy link
Author

It seems that is the desired behavior, as stated on the official website here:

image

See karthink/gptel#59 (comment) for the related discussion.

@beyondpie
Copy link

beyondpie commented Aug 5, 2023

@jcs090218
Hi author, I think the error I have is the same here. So it's just because GPT-4 is not supported to be used as API.
Thanks!
Songpeng

@beyondpie
Copy link

@jcs090218
Copy link
Member

Does this mean GPT-4 is now supported?

It has been a while since I have followed the OpenAI development. Can you see if it works?

(setq chatgpt-model "gpt-4")

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Aug 5, 2023

I tried but still failed:

image

The official help says that:

On July 6, 2023 , we gave access to the GPT-4 API (8k) to all API users who have made a successful payment of $1 or more.

So, it should mean that you must first be a successful-paid user of its API instead of the web based access.

See https://stackoverflow.com/questions/76653119/openai-gpt-4-api-error-the-model-gpt-4-does-not-exist for the related discussion.

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

3 participants