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

[Bug]: KeyError: 'Could not automatically map gpt-4 to a tokeniser. Please use tiktok.get_encoding to explicitly get the tokeniser you expect.' #718

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

Comments

@hongyi-zhao
Copy link
Collaborator

Installation Method | 安装方法与平台

Pip Install (I used latest requirements.txt and python>=3.8)

Describe the bug & Screen Shot | 简述 与 有帮助的截图

$ python main.py 
 [PROXY] 网络代理状态已配置配置信息如下: {'http': 'socks5h://localhost:18890', 'https': 'socks5h://localhost:18890'} 
 [API_KEY] 本项目现已支持OpenAI和API2D的api-key也支持同时填写多个api-key如API_KEY="openai-key1,openai-key2,api2d-key3" 
 [API_KEY] 您既可以在config.py中修改api-key(s),也可以在问题输入区输入临时的api-key(s),然后回车键提交后即可生效。 
 [API_KEY] 您的 API_KEY : sk-uqK3QZVkFjSH*** API_KEY 导入成功 
所有问询记录将自动保存在本地目录./gpt_log/chat_secrets.log, 请注意自我隐私保护哦查询代理的地理位置返回的结果是{'ip': '60.249.28.129', 'network': '60.249.28.0/23', 'version': 'IPv4', 'city': 'New Taipei', 'region': 'New Taipei', 'region_code': 'NWT', 'country': 'TW', 'country_name': 'Taiwan', 'country_code': 'TW', 'country_code_iso3': 'TWN', 'country_capital': 'Taipei', 'country_tld': '.tw', 'continent_code': 'AS', 'in_eu': False, 'postal': None, 'latitude': 24.9466, 'longitude': 121.586, 'timezone': 'Asia/Taipei', 'utc_offset': '+0800', 'country_calling_code': '+886', 'currency': 'TWD', 'currency_name': 'Dollar', 'languages': 'zh-TW,zh,nan,hak', 'country_area': 35980.0, 'country_population': 23451837, 'asn': 'AS3462', 'org': 'Data Communication Business Group'}
代理配置 socks5h://localhost:18890, 代理所在地Taiwan
如果浏览器没有自动打开请复制并转到以下URL:
	(亮色主题): http://localhost:54021暗色主题): http://localhost:54021/?__theme=dark
正在执行一些模块的预热...
正在加载tokenizer如果是第一次运行可能需要一点时间下载参数
加载tokenizer完毕
正在加载tokenizer如果是第一次运行可能需要一点时间下载参数
Exception in thread warm-up:
Traceback (most recent call last):
  File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/home/werner/Public/repo/github.com/binary-husky/gpt_academic.git/check_proxy.py", line 152, in warm_up_modules
    enc.encode("模块预热", disallowed_special=())
  File "/home/werner/Public/repo/github.com/binary-husky/gpt_academic.git/request_llm/bridge_all.py", line 43, in encode
    encoder = self.get_encoder(self.model) 
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/binary-husky/gpt_academic.git/request_llm/bridge_all.py", line 38, in get_encoder
    tmp = tiktoken.encoding_for_model(model)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/tiktoken/model.py", line 68, in encoding_for_model
    raise KeyError(
KeyError: 'Could not automatically map gpt-4 to a tokeniser. Please use `tiktok.get_encoding` to explicitly get the tokeniser you expect.'
Running on local URL:  http://0.0.0.0:54021

To create a public link, set `share=True` in `launch()`.
[GFX1-]: glxtest: VA-API test failed: no supported VAAPI profile found.
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
[ERROR viaduct::backend::ffi] Missing HTTP status
[ERROR viaduct::backend::ffi] Missing HTTP status

Terminal Traceback & Material to Help Reproduce Bugs | 终端traceback(如有) + 帮助我们复现的测试材料样本(如有)

No response

@binary-husky
Copy link
Owner

是否使用了 requirements.txt 安装依赖?
tiktoken的版本是多少?

@hongyi-zhao
Copy link
Collaborator Author

多谢提醒,执行下面的命令后成功了:

$ pip install -U tiktoken

image

实际上,我的 API_KEY 是购买了 GPT-4 的:

image

但是,从 gpt_academic 中无法使用这个功能:

image

这是什么原因?

@hongyi-zhao
Copy link
Collaborator Author

hongyi-zhao commented May 12, 2023

就是没有获得 GPT-4 API 访问的体验资格。参考下面的讨论:

karthink/gptel#59
emacs-openai/chatgpt#11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants