我正在学习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
让人困惑。
在我的代码中是否有需要优化的地方,或者是否有解决方案/修复方案?
1条答案
按热度按时间ltskdhd11#
我提到了this forum post关于类似的问题。解决方案似乎是在OpenAI账户中添加支付模式,使其成为
paid
账户。一旦帐户转换为
paid
帐户,RateLimitError
就停止弹出,请求也会得到很好的处理。