feat: streamline web research process and integrate Google Trends results into Streamlit UI
This commit is contained in:
@@ -503,24 +503,6 @@ def competitor_analysis():
|
||||
st.error("Please enter a valid URL.")
|
||||
|
||||
|
||||
def do_web_research():
|
||||
""" Input keywords and do web research and present a report."""
|
||||
st.title("Web Research Assistant")
|
||||
st.write("Enter keywords for web research. The keywords should be at least three words long.")
|
||||
|
||||
search_keywords = st.text_input("Search Keywords", placeholder="Enter keywords for web research...")
|
||||
if st.button("Start Web Research"):
|
||||
if search_keywords and len(search_keywords.split()) >= 3:
|
||||
try:
|
||||
st.info(f"Starting web research on given keywords: {search_keywords}")
|
||||
with st.spinner("Performing web research..."):
|
||||
web_research_result = gpt_web_researcher(search_keywords)
|
||||
st.success("Web research completed successfully!")
|
||||
st.write(web_research_result)
|
||||
except Exception as err:
|
||||
st.error(f"ERROR: Failed to do web research: {err}")
|
||||
else:
|
||||
st.warning("Search keywords should be at least three words long. Please try again.")
|
||||
|
||||
|
||||
def ai_finance_ta_writer():
|
||||
|
||||
@@ -3,7 +3,17 @@ from lib.utils.alwrity_utils import (
|
||||
blog_from_keyword, ai_agents_team, essay_writer, ai_news_writer, ai_seo_tools,
|
||||
ai_finance_ta_writer, ai_social_writer, do_web_research, competitor_analysis
|
||||
)
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
from lib.ai_writers.ai_story_writer.story_writer import story_input_section
|
||||
from lib.ai_web_researcher.google_trends_researcher import (
|
||||
fetch_multirange_interest_over_time,
|
||||
fetch_historical_hourly_interest,
|
||||
fetch_trending_searches,
|
||||
fetch_realtime_search_trends,
|
||||
fetch_top_charts,
|
||||
fetch_suggestions
|
||||
)
|
||||
from lib.ai_writers.ai_product_description_writer import write_ai_prod_desc
|
||||
from lib.content_planning_calender.content_planning_agents_alwrity_crew import ai_agents_content_planner
|
||||
|
||||
@@ -49,7 +59,60 @@ def content_planning_tools():
|
||||
choice = st.radio("Select a content planning tool:", options, index=0, format_func=lambda x: f"🔍 {x}")
|
||||
|
||||
if choice == "Keywords Researcher":
|
||||
do_web_research()
|
||||
st.title("Web Research Assistant")
|
||||
st.write("Enter keywords for web research. The keywords should be at least three words long.")
|
||||
|
||||
search_keywords = st.text_input("Search Keywords", placeholder="Enter keywords for web research...")
|
||||
if st.button("Start Web Research"):
|
||||
if search_keywords and len(search_keywords.split()) >= 3:
|
||||
try:
|
||||
st.info(f"Starting web research on given keywords: {search_keywords}")
|
||||
with st.spinner("Performing web research..."):
|
||||
# Fetch and display multirange interest over time
|
||||
st.subheader("Multirange Interest Over Time")
|
||||
multirange_data = fetch_multirange_interest_over_time([search_keywords], ['today 3-m', 'today 1-m'])
|
||||
st.dataframe(multirange_data)
|
||||
|
||||
# Fetch and display historical hourly interest
|
||||
st.subheader("Historical Hourly Interest")
|
||||
hourly_data = fetch_historical_hourly_interest([search_keywords], '2023-01-01', '2023-01-31')
|
||||
st.dataframe(hourly_data)
|
||||
|
||||
# Fetch and display trending searches
|
||||
st.subheader("Trending Searches")
|
||||
trending_data = fetch_trending_searches()
|
||||
st.dataframe(trending_data)
|
||||
|
||||
# Fetch and display realtime search trends
|
||||
st.subheader("Realtime Search Trends")
|
||||
realtime_data = fetch_realtime_search_trends()
|
||||
st.dataframe(realtime_data)
|
||||
|
||||
# Fetch and display top charts
|
||||
st.subheader("Top Charts")
|
||||
top_charts_data = fetch_top_charts(2023)
|
||||
st.dataframe(top_charts_data)
|
||||
|
||||
# Fetch and display suggestions
|
||||
st.subheader("Suggestions")
|
||||
suggestions = fetch_suggestions(search_keywords)
|
||||
st.dataframe(pd.DataFrame(suggestions))
|
||||
|
||||
# Example of plotting with Matplotlib
|
||||
st.subheader("Interest Over Time Plot")
|
||||
plt.figure(figsize=(10, 6))
|
||||
plt.plot(multirange_data['date'], multirange_data[search_keywords], label=search_keywords)
|
||||
plt.title(f'Interest Over Time for "{search_keywords}"')
|
||||
plt.xlabel('Date')
|
||||
plt.ylabel('Interest')
|
||||
plt.legend()
|
||||
st.pyplot(plt)
|
||||
|
||||
st.success("Web research completed successfully!")
|
||||
except Exception as err:
|
||||
st.error(f"ERROR: Failed to do web research: {err}")
|
||||
else:
|
||||
st.warning("Search keywords should be at least three words long. Please try again.")
|
||||
elif choice == "Competitor Analysis":
|
||||
competitor_analysis()
|
||||
elif choice == "Content Calender Ideator":
|
||||
|
||||
Reference in New Issue
Block a user