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

chain.run threw 403 error #1795

Closed
mzhadigerov opened this issue Mar 19, 2023 · 6 comments
Closed

chain.run threw 403 error #1795

mzhadigerov opened this issue Mar 19, 2023 · 6 comments

Comments

@mzhadigerov
Copy link

mzhadigerov commented Mar 19, 2023

I'm using the pipeline for Q&A pipeline on non-english language:

pinecone.init(
    api_key=PINECONE_API_KEY,  # find at app.pinecone.io
    environment=PINECONE_API_ENV  # next to api key in console
)
index_name = "langchain2"
embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)

docsearch = Pinecone.from_existing_index(index_name=index_name, embedding=embeddings)

llm = OpenAI(temperature=0, openai_api_key=OPENAI_API_KEY)
chain = load_qa_chain(llm, chain_type="stuff")

query = "QUESTION"
docs = docsearch.similarity_search(query, include_metadata=True)

res = chain.run(input_documents=docs, question=query)
print(res)

It stucks in res = chain.run(input_documents=docs, question=query) lane. I'm waiting for ~20 mins already. What's the reason for that and how to investigate?


UPD

After ~30 mins I got

Retrying langchain.llms.openai.completion_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised Timeout: Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Read timed out. (read timeout=600).

What's the reason for that and how can I fix it?

@mzhadigerov mzhadigerov changed the title chain.run stucks chain.run threw 403 error Mar 19, 2023
@dlqqq
Copy link
Contributor

dlqqq commented Mar 19, 2023

This looks like an issue with the upstream API and not LangChain itself. LangChain is not responsible for upstream API availability or rate limiting policies.

@mzhadigerov
Copy link
Author

@dlqqq How can I set a limit for response time? I'm using signal library from python. Wondering If there are alternative ways

@dlqqq
Copy link
Contributor

dlqqq commented Mar 20, 2023

@mzhadigerov Unfortunately, a quick glance at the pinecone.py source seems to show that there isn't timeout support at the moment for Pinecone. The community is still working to bring timeouts to classes throughout the repo: #1798

@mzhadigerov
Copy link
Author

sorry @dlqqq ,but what it has to do with pinecone? The problem arises in openai side, not in pinecone side. Please, correct me If I misunderstood you.

@dlqqq
Copy link
Contributor

dlqqq commented Mar 20, 2023

@mzhadigerov Sorry, I misread your error log. Yes, you are correct, this is an issue with the upstream OpenAI API.

How can I set a limit for response time?

There actually is a request_timeout option on the OpenAI providers. You can declare this when instantiating the provider:

TIMEOUT = 60 # <= timeout in seconds. default is 600 (set by OpenAI)
llm = OpenAI(temperature=0, openai_api_key=OPENAI_API_KEY, request_timeout=TIMEOUT)

This change was implemented by #398. Support for the request_timeout kwarg was implemented upstream in the OpenAI Python SDK here: openai/openai-python#116

@dlqqq
Copy link
Contributor

dlqqq commented Mar 22, 2023

@mzhadigerov Can we close this issue?

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

2 participants