GoogleLeak / app.py
cyberandy's picture
Update app.py
fa55365 verified
raw
history blame
1.39 kB
import streamlit as st
from gpt_researcher import GPTResearcher
import asyncio
import nest_asyncio
# Access secrets
openai_api_key = st.secrets["OPENAI_API_KEY"]
tavily_api_key = st.secrets["TAVILY_API_KEY"]
# Apply the asyncio patch from nest_asyncio if required
nest_asyncio.apply()
# Constants
REPORT_TYPE = "research_report" # Fixed report type
PREDEFINED_SOURCES = [
"https://hexdocs.pm/google_api_content_warehouse/",
"https://ipullrank.com/google-algo-leak"
]
# Function to handle asynchronous calls
def run_async(coroutine):
loop = asyncio.get_event_loop()
return loop.run_until_complete(coroutine)
# Streamlit interface
st.title("Google Leak Reporting Tool")
# User input for the query
query = st.text_input(
"Enter your research query:",
"Extract all the information about how the ranking for internal links works."
)
# Button to generate report
if st.button("Generate Report"):
if not query:
st.warning("Please enter a query to generate a report.")
else:
with st.spinner("Generating report..."):
# Fetch the report asynchronously using predefined sources and fixed report type
fetch_report_coroutine = fetch_report(query, REPORT_TYPE, PREDEFINED_SOURCES)
report = run_async(fetch_report_coroutine)
st.success("Report generated successfully!")
st.write(report)