eimenhmdt / autoresearcher

⚡ Automating scientific workflows with AI ⚡
MIT License
373 stars 38 forks source link

Exception: Failed to fetch data from API: 429 #18

Open ammaraziz opened 1 year ago

ammaraziz commented 1 year ago

Cool package!

I am receiving this error:

Research question: What mutations in the N gene of sars cov 2 are involved in rapid antigen test failurre?
Auto Researcher initiated!
Generating keyword combinations...
Keyword combinations generated!
Fetching top 20 papers...

Traceback (most recent call last): File "", line 1, in File "/home/amar/miniconda3/envs/write-the/lib/python3.9/site-packages/autoresearcher/workflows/literature_review/literature_review.py", line 85, in literature_review top_papers = SemanticScholar.fetch_and_sort_papers(search_query, keyword_combinations=keyword_combinations, year_range="2000-2023") File "/home/amar/miniconda3/envs/write-the/lib/python3.9/site-packages/autoresearcher/data_sources/web_apis/semantic_scholar_loader.py", line 27, in fetch_and_sort_papers papers.extend(self.fetch_data(combination, limit, year_range)) File "/home/amar/miniconda3/envs/write-the/lib/python3.9/site-packages/autoresearcher/data_sources/web_apis/semantic_scholar_loader.py", line 18, in fetch_data data = self.make_request("", params=params) File "/home/amar/miniconda3/envs/write-the/lib/python3.9/site-packages/autoresearcher/data_sources/web_apis/base_web_api_data_loader.py", line 20, in make_request raise Exception(f"Failed to fetch data from API: {response.status_code}") Exception: Failed to fetch data from API: 429

My code:

from autoresearcher import literature_review

research_question = "What mutations in the N gene of sars cov 2 are involved in rapid antigen test failurre?"
researcher = literature_review(research_question)
researcher = literature_review(research_question, output_file="my_literature_review.txt")

429 response suggests too many queries.

ammaraziz commented 1 year ago

This is an issue on my end with SSL certs that I think was resulting in the above 429 error. Closing :)

ammaraziz commented 1 year ago

Sorry opening again. I have a new error:

openai.error.RateLimitError: Rate limit reached for default-gpt-3.5-turbo in organization org-sKBYXnh22DxRDpCw42jRYT2E on requests per min. Limit: 3 / min. Please try again in 20s. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment method.

eimenhmdt commented 1 year ago

Hey @ammaraziz! Are you the owner of the OpenAI organization you're using the API key from?

ammaraziz commented 1 year ago

It's a personal account with no org attached.

GilbertHan1011 commented 1 year ago

I encountered the same two problems. Please let me know if there are any solutions。

eimenhmdt commented 1 year ago

Try adding a payment method to your account to increase your rate limit, as the error suggests. Let me know if this solves the issue.

GilbertHan1011 commented 1 year ago

I am not a US resident and it is a bit difficult to provide payment methods that are recognized by open ai. It would be nice if it could be done by changing the code (e.g. offering the option to limit to 3 times per minute)

eimenhmdt commented 1 year ago

I'm working on adding the option to use an open source model that is free!

GilbertHan1011 commented 1 year ago

Thank you for your efforts!

sjssmits commented 1 year ago

I have the same problem, other API requests work normally.

adamengberg commented 1 year ago

This is an issue on my end with SSL certs that I think was resulting in the above 429 error. Closing :)

I have this problem as well. how did you solve it?

sjssmits commented 1 year ago

It's working again, reason unknown.