python-3.x Openai不断抛出RateLimitError,甚至不让一个请求通过

dly7yett  于 2023-08-08  发布在  Python
关注(0)|答案(1)|浏览(225)

我正在学习Langchain教程。代码如下:

from langchain.document_loaders import WebBaseLoader
from langchain.indexes import VectorstoreIndexCreator

# Load document from web (blogpost)
loader = WebBaseLoader("https://lilianweng.github.io/posts/2023-06-23-agent/")

data = loader.load()

# Split the text
from langchain.text_splitter import RecursiveCharacterTextSplitter
text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
all_splits = text_splitter.split_documents(data)

# Embed and store the splits in a vector db (chroma)
from langchain.vectorstores import Chroma
from langchain.embeddings import OpenAIEmbeddings
vectorstore = Chroma.from_documents(documents=all_splits, embedding=OpenAIEmbeddings())

question = "what are the approaches to task decomposition"
docs = vectorstore.similarity_search(question)
print(len(docs))

字符串
我不断得到以下错误跟踪:

Retrying langchain.embeddings.openai.embed_with_retry.<locals>._embed_with_retry in 4.0 seconds as it raised RateLimitError: You exceeded your current quota, please check your plan and billing details..


API甚至不允许一个请求通过。所以,RateLimitError让人困惑。
在我的代码中是否有需要优化的地方,或者是否有解决方案/修复方案?

ltskdhd1

ltskdhd11#

我提到了this forum post关于类似的问题。解决方案似乎是在OpenAI账户中添加支付模式,使其成为paid账户。
一旦帐户转换为paid帐户,RateLimitError就停止弹出,请求也会得到很好的处理。

相关问题