assafelovic / gpt-researcher

LLM based autonomous agent that conducts local and web research on any topic and generates a comprehensive report with citations.
https://gptr.dev
Apache License 2.0
14.74k stars 1.97k forks source link

KeyError: 'snippet' #694

Closed trangrta closed 2 months ago

trangrta commented 3 months ago

I'm run code detailed report and getting the following error:

File "d:\rtGIT\rta-aiteam\TEST\test1.py", line 25, in _initial_research await main_task_assistant.conduct_research() File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\gpt_researcher\master\agent.py", line 107, in conduct_research context = await self.get_context_by_search(self.query) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\gpt_researcher\master\agent.py", line 202, in get_context_by_search context = await asyncio.gather(*[self.__process_sub_query(sub_query, scraped_data) for sub_query in sub_queries])

File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\gpt_researcher\master\agent.py", line 219, in process_sub_query scraped_data = await self.__scrape_data_by_query(sub_query) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\gpt_researcher\master\agent.py", line 256, in scrape_data_by_query search_results = retriever.search( ^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\gpt_researcher\retrievers\serper\serper.py", line 77, in search "body": result["snippet"],


KeyError: 'snippet'

 I'm using retriever = googleSerp,
- query= "Vinfast Cars: Comprehensive Investment Analysis for Potential Stock Investors"
- report_type = "research_report"
Note: The error only occurs with this query, other queries run normally
0x11c11e commented 3 months ago

I cannot reproduce the same error. Make sure you have assigned the correct environment variables. Based on the source code, the following variables must be set for googleSerp to work properly. I think you set a wrong retriever or API key. Here are the correct settings:

RETRIEVER=googleSerp
SERPER_API_KEY=You can get a key at https://serper.dev/