revert to 93075dc
This commit is contained in:
@@ -2,6 +2,7 @@ import re
|
||||
import streamlit as st
|
||||
import tempfile
|
||||
from loguru import logger
|
||||
from lib.ai_web_researcher.gpt_online_researcher import gpt_web_researcher
|
||||
from lib.ai_web_researcher.metaphor_basic_neural_web_search import metaphor_find_similar
|
||||
from lib.ai_writers.keywords_to_blog_streamlit import write_blog_from_keywords
|
||||
from lib.ai_writers.speech_to_blog.main_audio_to_blog import generate_audio_blog
|
||||
@@ -13,6 +14,7 @@ from lib.ai_writers.facebook_ai_writer import facebook_post_writer
|
||||
from lib.ai_writers.linkedin_ai_writer import linked_post_writer
|
||||
from lib.ai_writers.twitter_ai_writer import tweet_writer
|
||||
from lib.ai_writers.insta_ai_writer import insta_writer
|
||||
from lib.ai_writers.youtube_ai_writer import write_yt_title, write_yt_description, write_yt_script
|
||||
from lib.ai_writers.web_url_ai_writer import blog_from_url
|
||||
from lib.ai_writers.image_ai_writer import blog_from_image
|
||||
from lib.ai_writers.ai_essay_writer import ai_essay_generator
|
||||
@@ -20,6 +22,7 @@ import os
|
||||
import PyPDF2
|
||||
import tiktoken
|
||||
import openai
|
||||
from lib.gpt_providers.text_to_image_generation.main_generate_image_from_prompt import generate_image
|
||||
from lib.ai_seo_tools.seo_structured_data import ai_structured_data
|
||||
from lib.ai_seo_tools.content_title_generator import ai_title_generator
|
||||
from lib.ai_seo_tools.meta_desc_generator import metadesc_generator_main
|
||||
@@ -35,41 +38,41 @@ from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||
|
||||
|
||||
def is_youtube_link(text):
|
||||
"""Check if the provided text is a YouTube link."""
|
||||
if text:
|
||||
if text is not None:
|
||||
youtube_regex = re.compile(r'(https?://)?(www\.)?(youtube|youtu|youtube-nocookie)\.(com|be)/(watch\?v=|embed/|v/|.+\?v=)?([^&=%\?]{11})')
|
||||
return youtube_regex.match(text)
|
||||
|
||||
|
||||
def is_web_link(text):
|
||||
"""Check if the provided text is a web link."""
|
||||
if text:
|
||||
if text is not None:
|
||||
web_regex = re.compile(r'(https?://)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)')
|
||||
return web_regex.match(text)
|
||||
|
||||
|
||||
def process_input(input_text, uploaded_file):
|
||||
"""Process the input text or uploaded file and determine its type."""
|
||||
if input_text:
|
||||
if is_youtube_link(input_text):
|
||||
if input_text.startswith("https://www.youtube.com/") or input_text.startswith("http://www.youtube.com/"):
|
||||
return "youtube_url"
|
||||
else:
|
||||
st.error("Invalid YouTube URL. Please enter a valid URL.")
|
||||
return None
|
||||
elif is_web_link(input_text):
|
||||
return "web_url"
|
||||
if input_text and is_youtube_link(input_text):
|
||||
if input_text.startswith("https://www.youtube.com/") or input_text.startswith("http://www.youtube.com/"):
|
||||
return "youtube_url"
|
||||
else:
|
||||
return "keywords"
|
||||
st.error("Invalid YouTube URL. Please enter a valid URL.")
|
||||
return None
|
||||
|
||||
elif input_text and is_web_link(input_text):
|
||||
return "web_url"
|
||||
|
||||
if uploaded_file:
|
||||
elif input_text:
|
||||
return "keywords"
|
||||
|
||||
if uploaded_file is not None:
|
||||
file_details = {"filename": uploaded_file.name, "filetype": uploaded_file.type}
|
||||
st.write(file_details)
|
||||
if uploaded_file.type.startswith("text/"):
|
||||
content = uploaded_file.read().decode("utf-8")
|
||||
st.text(content)
|
||||
|
||||
elif uploaded_file.type == "application/pdf":
|
||||
return "PDF_file"
|
||||
|
||||
elif uploaded_file.type in ["application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/msword"]:
|
||||
st.write("Word document uploaded. Add your DOCX processing logic here.")
|
||||
elif uploaded_file.type.startswith("image/"):
|
||||
@@ -500,6 +503,24 @@ 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():
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
import streamlit as st
|
||||
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, competitor_analysis
|
||||
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
|
||||
from pytrends.request import TrendReq
|
||||
from datetime import datetime
|
||||
|
||||
def ai_writers():
|
||||
options = [
|
||||
@@ -61,64 +49,10 @@ 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":
|
||||
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 == "Keywords Researcher":
|
||||
google_trends_analysis()
|
||||
competitor_analysis()
|
||||
do_web_research()
|
||||
elif choice == "Competitor Analysis":
|
||||
competitor_analysis()
|
||||
elif choice == "Content Calender Ideator":
|
||||
plan_keywords = st.text_input(
|
||||
"**Enter Your main Keywords to get 2 months content calendar:**",
|
||||
placeholder="Enter 2-3 main keywords to generate AI content calendar with keyword researched blog titles",
|
||||
@@ -129,46 +63,3 @@ def content_planning_tools():
|
||||
ai_agents_content_planner(plan_keywords)
|
||||
else:
|
||||
st.error("Come on, really, Enter some keywords to plan on..")
|
||||
def google_trends_analysis():
|
||||
st.title("Google Trends Analysis")
|
||||
|
||||
# Prompt user for required input
|
||||
keyword = st.text_input("Enter Keyword(s)", help="Enter one or more keywords separated by commas.")
|
||||
|
||||
# Optional inputs with intelligent defaults
|
||||
start_time = st.date_input("Start Time", value=datetime(2004, 1, 1), help="Start date for the analysis.")
|
||||
end_time = st.date_input("End Time", value=datetime.now(), help="End date for the analysis.")
|
||||
geo = st.text_input("Geographic Location", value="US", help="Location of interest (e.g., 'US').")
|
||||
hl = st.text_input("Preferred Language", value="en", help="Preferred language (e.g., 'en').")
|
||||
timezone = st.number_input("Timezone", value=360, help="Timezone offset in minutes from UTC.")
|
||||
category = st.number_input("Category", value=0, help="Category to search within.")
|
||||
property = st.selectbox("Google Property", options=["", "images", "news", "youtube", "froogle"], help="Google property to filter on.")
|
||||
resolution = st.selectbox("Resolution", options=["COUNTRY", "REGION", "CITY", "DMA"], help="Granularity of the geo search.")
|
||||
granular_time_resolution = st.checkbox("Granular Time Resolution", value=False, help="Use finer time resolution if applicable.")
|
||||
|
||||
if st.button("Analyze"):
|
||||
if not keyword:
|
||||
st.error("Keyword is required.")
|
||||
return
|
||||
|
||||
# Initialize pytrends
|
||||
pytrends = TrendReq(hl=hl, tz=timezone)
|
||||
|
||||
# Build the payload
|
||||
pytrends.build_payload(
|
||||
kw_list=keyword.split(','),
|
||||
timeframe=f"{start_time.strftime('%Y-%m-%d')} {end_time.strftime('%Y-%m-%d')}",
|
||||
geo=geo,
|
||||
cat=category,
|
||||
gprop=property
|
||||
)
|
||||
|
||||
# Fetch interest over time
|
||||
interest_over_time_df = pytrends.interest_over_time()
|
||||
st.subheader("Interest Over Time")
|
||||
st.dataframe(interest_over_time_df)
|
||||
|
||||
# Fetch interest by region
|
||||
interest_by_region_df = pytrends.interest_by_region(resolution=resolution)
|
||||
st.subheader("Interest By Region")
|
||||
st.dataframe(interest_by_region_df)
|
||||
|
||||
Reference in New Issue
Block a user