GoogleLeak / app.py
cyberandy's picture
update
c8a34e3 verified
raw
history blame
2.17 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",
"https://sparktoro.com/blog/an-anonymous-source-shared-thousands-of-leaked-google-search-api-documents-with-me-everyone-in-seo-should-see-them/"]
async def fetch_report(query, report_type, sources):
"""
Fetch a research report based on the provided query, report type, and sources.
This function assumes that `GPTResearcher` has methods to conduct research and write a report.
"""
# Initialize the researcher with required parameters
researcher = GPTResearcher(query=query, report_type=report_type, source_urls=sources)
# Conduct research
await researcher.conduct_research()
# Write the report after research has been conducted
report = await researcher.write_report()
# Return the completed report
return report
# 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)