QuantumLearner commited on
Commit
6eb7b3b
·
verified ·
1 Parent(s): a31c9e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -22,31 +22,27 @@ if not openai_api_key or not tavily_api_key:
22
  # Define the asynchronous function to get the report and capture logs
23
  async def get_report(query: str, report_type: str, sources: list, report_source: str):
24
  f = io.StringIO()
25
- logs_container = st.empty() # Create a placeholder for the logs
26
-
27
  with redirect_stdout(f):
28
  if report_source == 'local':
 
29
  os.environ['DOC_PATH'] = './uploads'
30
  researcher = GPTResearcher(query=query, report_type=report_type, report_source=report_source)
31
  else:
32
  researcher = GPTResearcher(query=query, report_type=report_type, source_urls=sources)
33
 
34
- # Start the research process
35
  await researcher.conduct_research()
36
 
37
  while True:
38
  logs = f.getvalue()
39
- # Update the text area within the placeholder
40
- logs_container.text_area("Agent Logs", logs, height=200)
41
- await asyncio.sleep(1) # Wait for a second before the next update
42
  if "Finalized research step" in logs:
43
  break
44
 
45
- # Generate the final report
46
  report = await researcher.write_report()
47
  return report, f.getvalue()
48
 
49
-
50
  # Function to create PDF using fpdf with UTF-8 encoding
51
  class PDF(FPDF):
52
  def header(self):
@@ -93,7 +89,6 @@ with st.expander("Why Use GPT Researcher?", expanded=False):
93
  - **Up-to-Date Information**: Unlike traditional LLMs, GPT Researcher avoids outdated information and minimizes the risk of hallucinations.
94
  - **Comprehensive Reports**: Capable of producing long, detailed research reports (2,000+ words).
95
  - **Reduced Misinformation**: By considering a wide range of sources, it minimizes the risks associated with limited or biased information.
96
-
97
  For more details, visit the [GPT Researcher GitHub repository](https://github.com/assafelovic/gpt-researcher).
98
  """)
99
 
@@ -205,4 +200,4 @@ hide_streamlit_style = """
205
  footer {visibility: hidden;}
206
  </style>
207
  """
208
- st.markdown(hide_streamlit_style, unsafe_allow_html=True)
 
22
  # Define the asynchronous function to get the report and capture logs
23
  async def get_report(query: str, report_type: str, sources: list, report_source: str):
24
  f = io.StringIO()
25
+ logs_container = st.empty()
 
26
  with redirect_stdout(f):
27
  if report_source == 'local':
28
+ # Set the DOC_PATH environment variable
29
  os.environ['DOC_PATH'] = './uploads'
30
  researcher = GPTResearcher(query=query, report_type=report_type, report_source=report_source)
31
  else:
32
  researcher = GPTResearcher(query=query, report_type=report_type, source_urls=sources)
33
 
 
34
  await researcher.conduct_research()
35
 
36
  while True:
37
  logs = f.getvalue()
38
+ logs_container.text_area("Agent Logs", logs, height=200, key="realtime_logs_display")
39
+ await asyncio.sleep(1) # Update every second
 
40
  if "Finalized research step" in logs:
41
  break
42
 
 
43
  report = await researcher.write_report()
44
  return report, f.getvalue()
45
 
 
46
  # Function to create PDF using fpdf with UTF-8 encoding
47
  class PDF(FPDF):
48
  def header(self):
 
89
  - **Up-to-Date Information**: Unlike traditional LLMs, GPT Researcher avoids outdated information and minimizes the risk of hallucinations.
90
  - **Comprehensive Reports**: Capable of producing long, detailed research reports (2,000+ words).
91
  - **Reduced Misinformation**: By considering a wide range of sources, it minimizes the risks associated with limited or biased information.
 
92
  For more details, visit the [GPT Researcher GitHub repository](https://github.com/assafelovic/gpt-researcher).
93
  """)
94
 
 
200
  footer {visibility: hidden;}
201
  </style>
202
  """
203
+ st.markdown(hide_streamlit_style, unsafe_allow_html=True)