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

Passing "detailed_report" in GPTResearcher constructor (still) results in key error #442

Open
Handschrift opened this issue Apr 11, 2024 · 7 comments

Comments

@Handschrift
Copy link

I already opened an issue (see #431) but the issue got closed.

The mentioned problem still exists. So running the code:

report_type = "detailed_report" # using ReportType.DetailedReport.value does not work aswell
researcher = GPTResearcher(query, report_type, config_path="config.json")
await researcher.conduct_research()
report = await researcher.write_report()

does produce a KeyError because:

    report_type_mapping = {
        ReportType.ResearchReport.value: generate_report_prompt,
        ReportType.ResourceReport.value: generate_resource_report_prompt,
        ReportType.OutlineReport.value: generate_outline_report_prompt,
        ReportType.CustomReport.value: generate_custom_report_prompt,
        ReportType.SubtopicReport.value: generate_subtopic_report_prompt
    }

does not contain the "detailed_report" key.

This error still exists even if I use the latest version (the master branch, currently at commit 53f2da7) of the package.

@assafelovic
Copy link
Owner

@proy9714 can you take a look?

@assafelovic
Copy link
Owner

@Handschrift I understand where the misunderstanding is. GPT Researcher as a package does not yet support long detailed report, and not sure it will. The package is used for doing specific research reports on a topic. The way we're creating long detailed reports is by leveraging GPT Researcher package multiple times and on various formats. You can check out the implementation here: https://github.com/assafelovic/gpt-researcher/blob/master/backend/report_type/detailed_report/detailed_report.py

Due to this misunderstanding, I've refactored the codebase to make it more understandable and also added some better error logs in case this issue happens to others: #443

Thanks for raising this!
FYI @proy9714

@assafelovic
Copy link
Owner

I will leave this issue open for awhile in case others run into this issue

@NicoLiendro14
Copy link

I have the same error but using de UI. Using Detailed Report I get this:

🤔 Generating subtopics...
📋Subtopics: []
ERROR: Exception in ASGI application
....
File "G:\GPT SCRAPER\gpt-researcher\backend\report_type\detailed_report\detailed_report.py", line 61, in _get_all_subtopics
return subtopics.dict()["subtopics"]
~~~~~~~~~^^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str

So, subtopics is an empty list.

@assafelovic
Copy link
Owner

@proy9714 can you please help with this? Looks like either non determinstic issue with LLMs or some validation that needs to be added for better stability

@proy9714
Copy link
Contributor

proy9714 commented May 15, 2024

Hey @NicoLiendro14 can you provide me the details of the report you are generating so that I can try to emulate it and see where the error is! The report topic, source, the search provider and LLM you are using should be enough! Thanks!

@proy9714
Copy link
Contributor

proy9714 commented May 15, 2024

@assafelovic @Handschrift @NicoLiendro14

Found the problem : langchain-ai/langchain#21635

Anyone know of any fixes?

In the meantime I would highly advise using gpt-4-turbo....until the langchain library gets updated. The present version still uses pydantic v1 instead of v2.

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

4 participants