Skip to content

Commit

Permalink
fixed bug with websocket and added quality improvements to ux ui and …
Browse files Browse the repository at this point in the history
…research report output
  • Loading branch information
assafelovic committed Jul 6, 2024
1 parent 861e3d8 commit 7c7ff95
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 117 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ https://github.com/assafelovic/gpt-researcher/assets/13554167/dd6cf08f-b31e-40c6

## Architecture
The main idea is to run "planner" and "execution" agents, whereas the planner generates questions to research, and the execution agents seek the most related information based on each generated research question. Finally, the planner filters and aggregates all related information and creates a research report. <br /> <br />
The agents leverage both `gpt3.5-turbo` and `gpt-4o` (128K context) to complete a research task. We optimize for costs using each only when necessary. **The average research task takes around 3 minutes to complete, and costs ~$0.1.**
The agents leverage both `gpt3.5-turbo` and `gpt-4o` (128K context) to complete a research task. We optimize for costs using each only when necessary. **The average research task takes around 3 minutes to complete, and costs ~$0.005.**

<div align="center">
<img align="center" height="600" src="https://github.com/assafelovic/gpt-researcher/assets/13554167/4ac896fd-63ab-4b77-9688-ff62aafcc527">
Expand Down Expand Up @@ -104,8 +104,8 @@ export TAVILY_API_KEY={Your Tavily API Key here}

For a more permanent setup, create a `.env` file in the current `gpt-researcher` directory and input the env vars (without `export`).

- For LLM provider, we recommend **[OpenAI GPT](https://platform.openai.com/docs/guides/gpt)**, but you can use any other LLM model (including open sources). To learn how to change the LLM model, please refer to the [documentation](https://docs.gptr.dev/docs/gpt-researcher/llms) page.
- For web search API, we recommend **[Tavily Search API](https://app.tavily.com)**, but you can also refer to other search APIs of your choice by changing the search provider in config/config.py to `duckduckgo`, `google`, `bing`, `serper`, `searx` and more. Then add the corresponding env API key.
- For LLM, we recommend **[OpenAI GPT](https://platform.openai.com/docs/guides/gpt)**, but you can use other LLMs such as `claude`, `ollama3`, `gemini`, `mistral` and more. To learn how to change the LLM provider, see the [LLMs documentation](https://docs.gptr.dev/docs/gpt-researcher/llms) page.
- The default retriever is **[Tavily](https://app.tavily.com)**, but you can refer to other retrievers such as `duckduckgo`, `google`, `bing`, `serper`, `searx`, `arxiv`, `exa` and more. To learn how to change the search provider, see the [retrievers documentation](https://docs.gptr.dev/docs/gpt-researcher/retrievers) page.

### Quickstart

Expand Down
3 changes: 2 additions & 1 deletion backend/report_type/basic_report/basic_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def __init__(self, query: str, report_type: str, report_source:str, source_urls,

async def run(self):
# Initialize researcher
researcher = GPTResearcher(self.query, self.report_type, self.report_source, self.source_urls, self.config_path, self.websocket)
researcher = GPTResearcher(query=self.query, report_type=self.report_type, report_source=self.report_source,
source_urls=self.source_urls, config_path=self.config_path, websocket=self.websocket)

# Run research
await researcher.conduct_research()
Expand Down
13 changes: 4 additions & 9 deletions backend/report_type/detailed_report/detailed_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def __init__(self, query: str, report_type: str, report_source: str, source_urls
self.subtopics = subtopics

# A parent task assistant. Adding research_report as default
self.main_task_assistant = GPTResearcher(self.query, "research_report", self.report_source, self.source_urls, self.config_path, self.websocket)
self.main_task_assistant = GPTResearcher(query=self.query, report_type="research_report",
report_source=self.report_source, source_urls=self.source_urls,
config_path=self.config_path, websocket=self.websocket)
self.existing_headers = []
# This is a global variable to store the entire context accumulated at any point through searching and scraping
self.global_context = []
Expand Down Expand Up @@ -81,13 +83,6 @@ async def fetch_report(subtopic):
# and passed to the next subtopic report generation.
# This is only possible to do sequentially

# tasks = [fetch_report(subtopic) for subtopic in subtopics]
# results = await asyncio.gather(*tasks)

# for result in filter(lambda r: r["report"], results):
# subtopic_reports.append(result)
# subtopics_report_body += "\n\n\n" + result["report"]

for subtopic in subtopics:
result = await fetch_report(subtopic)
if result["report"]:
Expand All @@ -96,7 +91,7 @@ async def fetch_report(subtopic):

return subtopic_reports, subtopics_report_body

async def _get_subtopic_report(self, subtopic: dict) -> tuple:
async def _get_subtopic_report(self, subtopic: dict) -> str:
current_subtopic_task = subtopic.get("task")
subtopic_assistant = GPTResearcher(
query=current_subtopic_task,
Expand Down
6 changes: 3 additions & 3 deletions frontend/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ body {
}

.container {
max-width: 900px;
margin: auto;
padding: 20px;
background-color: rgba(255, 255, 255, 0.1);
Expand Down Expand Up @@ -107,7 +106,7 @@ footer {
.margin-div {
margin-top: 20px;
margin-bottom: 20px;
padding: 10px;
padding: 25px;
}

.agent_response {
Expand All @@ -124,13 +123,14 @@ footer {
padding: 10px;
margin-bottom: 10px;
margin-top: 10px;
border-radius: 12px;
}

#reportContainer {
background-color: rgba(255,255,255,0.1);
border: none;
color: #fff;
transition: all .3s ease-in-out;
padding: 10px;
padding: 25px;
border-radius: 12px;
}
Loading

0 comments on commit 7c7ff95

Please sign in to comment.