我正在尝试使用spacy-llm
包来试验各种NLP任务,并渴望看到通过OpenAI API可以实现什么结果。
然而,当我尝试运行spacy-llm
提供的玩具示例时(示例1位于https://spacy.io/usage/large-language-models#-api),我得到一个错误代码为429的ConnectionError
:
>>> import spacy_llm
>>> from spacy_llm.util import assemble
>>> nlp = assemble("config.cfg")
>>> doc = nlp("You look gorgeous!")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/admin/platform-api/venv/lib/python3.11/site-packages/spacy/language.py", line 1047, in __call__
error_handler(name, proc, [doc], e)
File "/home/admin/platform-api/venv/lib/python3.11/site-packages/spacy/util.py", line 1724, in raise_error
raise e
File "/home/admin/platform-api/venv/lib/python3.11/site-packages/spacy/language.py", line 1042, in __call__
doc = proc(doc, **component_cfg.get(name, {})) # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/admin/platform-api/venv/lib/python3.11/site-packages/spacy_llm/pipeline/llm.py", line 145, in __call__
docs = self._process_docs([doc])
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/admin/platform-api/venv/lib/python3.11/site-packages/spacy_llm/pipeline/llm.py", line 199, in _process_docs
responses_iters = tee(self._model(prompts_iters[0]), n_iters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/admin/platform-api/venv/lib/python3.11/site-packages/spacy_llm/models/rest/openai/model.py", line 115, in __call__
responses = _request(
^^^^^^^^^
File "/home/admin/platform-api/venv/lib/python3.11/site-packages/spacy_llm/models/rest/openai/model.py", line 86, in _request
r = self.retry(
^^^^^^^^^^^
File "/home/admin/platform-api/venv/lib/python3.11/site-packages/spacy_llm/models/rest/base.py", line 147, in retry
raise ConnectionError(
ConnectionError: API could not be reached after 34.710 seconds in total and attempting to connect 5 times. Check your network connection and the API's availability.
429 Too Many Requests
它似乎认为有“太多的请求”-也许请求在后台被重复?有没有办法禁用它?
任何帮助将非常感谢!
作为参考,我还尝试了OpenAI网站上提供的一个示例,以确保我的密钥正确工作,如下所示。这完全符合预期。
import os
import openai
openai.organization = "org-xxx"
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Model.list()
1条答案
按热度按时间ar5n3qh51#
这个问题的解决方案是更仔细地阅读-虽然我的使用量是0美元,但剩余的18美元免费点数不可用,实际上已经过期......