NoviScl / AI-Researcher

MIT License
235 stars 22 forks source link

KeywordQuery function return None when s2_key is missing #17

Open Jiajing-Chen opened 2 months ago

Jiajing-Chen commented 2 months ago

Hi the creator of the AI-Researcher, Your project is really interesting and creative! I try to run your repo based on the guidance on your Readme.md. I didn't set the value of s2_key in keys.json because it says it's optional. But the function KeywordQuery returns None because it seems to require s2_key in headers = {'x-api-key': S2_KEY}. I got an error because the KeywordQuery function returns None:

Traceback (most recent call last): File "/Users/username/Desktop/AI-Researcher/ai_researcher/src/lit_review.py", line 215, in paper_bank, total_cost, all_queries = collect_papers(topic_description, client, args.engine, args.seed, args.grounding_k, max_papers=args.max_paper_bank_size, print_all=args.print_all, mode=args.mode, idea=idea) File "/opt/anaconda3/envs/ai-researcher/lib/python3.10/site-packages/decorator.py", line 232, in fun return caller(func, *(extras + args), *kw) File "/opt/anaconda3/envs/ai-researcher/lib/python3.10/site-packages/retry/api.py", line 73, in retry_decorator return __retry_internal(partial(f, args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter, File "/opt/anaconda3/envs/ai-researcher/lib/python3.10/site-packages/retry/api.py", line 33, in __retry_internal return f() File "/Users/username/Desktop/AI-Researcher/ai_researcher/src/lit_review.py", line 86, in collect_papers paper_lst = parse_and_execute(query) File "/Users/username/Desktop/AI-Researcher/ai_researcher/src/lit_review_tools.py", line 120, in parse_and_execute if 'total' in response and response['total'] == 0: TypeError: argument of type 'NoneType' is not iterable

I requested the s2 key from semanticscholar.org already, but I am still confused since you mentioned that this key is optional, but without using it, I am not able to follow your readme instructions. Could you please help with solving it? Thanks