Backlinking tool & Img optimization, PIL & Tinify API
This commit is contained in:
@@ -56,7 +56,9 @@ def gpt_web_researcher(search_keywords):
|
|||||||
|
|
||||||
|
|
||||||
def do_google_serp_search(search_keywords):
|
def do_google_serp_search(search_keywords):
|
||||||
""" """
|
""" COmmon function to do google SERP analysis and return results. """
|
||||||
|
|
||||||
|
# FIXME: Add a return filter to either return full json, titles, PAA, relatedsearches etc.
|
||||||
try:
|
try:
|
||||||
logger.info(f"Doing Google search for: {search_keywords}\n")
|
logger.info(f"Doing Google search for: {search_keywords}\n")
|
||||||
g_results = google_search(search_keywords)
|
g_results = google_search(search_keywords)
|
||||||
|
|||||||
@@ -1,50 +1,39 @@
|
|||||||
import time #Iwish
|
import time
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
|
|
||||||
|
from streamlit_quill import st_quill
|
||||||
|
from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||||
|
|
||||||
|
|
||||||
def generate_facebook_post(business_type, target_audience, post_goal, post_tone, include, avoid):
|
def generate_facebook_post(business_type, target_audience, post_goal, post_tone, include, avoid):
|
||||||
"""
|
"""
|
||||||
Generates a Facebook post prompt for an LLM based on user input.
|
Generates a Facebook post prompt for an LLM based on user input.
|
||||||
|
|
||||||
Args:
|
|
||||||
business_type: The type of business, e.g., fashion retailer, fitness coach.
|
|
||||||
target_audience: A description of the target audience.
|
|
||||||
post_goal: The goal of the Facebook post.
|
|
||||||
post_tone: The desired tone of the post.
|
|
||||||
include: Elements to include in the post (e.g., images, videos, links).
|
|
||||||
avoid: Elements to avoid in the post (e.g., long paragraphs, technical jargon).
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
A string containing the LLM prompt.
|
|
||||||
"""
|
"""
|
||||||
prompt = f"""I am a {business_type}.
|
prompt = f"""
|
||||||
|
I am a {business_type} looking to engage my target audience, {target_audience}, on Facebook.
|
||||||
|
|
||||||
Please help me write a detailed Facebook post that will engage my target audience, {target_audience}.
|
My goal for this detailed post is: {post_goal}. The tone should be {post_tone}.
|
||||||
|
|
||||||
Here are some additional details to consider:
|
Here are some additional preferences:
|
||||||
|
- **Include:** {include}
|
||||||
|
- **Avoid:** {avoid}
|
||||||
|
|
||||||
* **Post Goal:** {post_goal}
|
Please write a well-structured Facebook post with:
|
||||||
* **Post Tone:** {post_tone}
|
1. A **catchy opening** to grab attention.
|
||||||
* **Include:** {include}
|
2. Detailed **Engaging content** that highlights key benefits or features.
|
||||||
* **Avoid:** {avoid}
|
3. A **strong call-to-action** (CTA) encouraging my audience to take action.
|
||||||
|
4. If applicable, suggest **multimedia** (images, videos, etc.).
|
||||||
|
5. Include **relevant hashtags** for visibility.
|
||||||
|
|
||||||
**Example Post Structure:**
|
"""
|
||||||
|
|
||||||
1. **Attention-Grabbing Opening:** Start with a question or a bold statement to capture attention.
|
|
||||||
2. **Engaging Content:** Briefly describe the main message or offer, highlighting key benefits or features.
|
|
||||||
3. **Call-to-Action (CTA):** Encourage the audience to take a specific action (e.g., visit a link, comment, share).
|
|
||||||
4. **Multimedia:** Mention the types of multimedia elements to include (e.g., images, videos).
|
|
||||||
5. **Hashtags:** Include relevant hashtags to increase post visibility.
|
|
||||||
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
response = generate_text_with_exception_handling(prompt)
|
response = llm_text_gen(prompt)
|
||||||
return response
|
return response
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
st.error(f"An error occurred while generating the prompt: {e}")
|
st.error(f"An error occurred while generating the prompt: {err}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -57,76 +46,74 @@ def facebook_post_writer():
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
# Inputs for the Facebook post generator
|
||||||
col1, col2 = st.columns(2)
|
col1, col2 = st.columns(2)
|
||||||
|
|
||||||
with col1:
|
with col1:
|
||||||
post_goal_options = ["Promote a new product", "Share valuable content", "Increase engagement", "Customize"]
|
post_goal_options = ["Promote a new product", "Share valuable content", "Increase engagement", "Customize"]
|
||||||
post_goal = st.selectbox(
|
post_goal = st.selectbox(
|
||||||
"🎯 **What is the goal of your post?**",
|
"🎯 **What is the goal of your post?**",
|
||||||
post_goal_options,
|
post_goal_options,
|
||||||
index=2,
|
index=2,
|
||||||
help="Select the main goal of your post."
|
help="Select the main goal of your post."
|
||||||
|
)
|
||||||
|
|
||||||
|
if post_goal == "Customize":
|
||||||
|
post_goal = st.text_input(
|
||||||
|
"🎯 **Customize your goal:**",
|
||||||
|
placeholder="e.g., Announce an event",
|
||||||
|
help="Provide a specific goal if you selected 'Customize'."
|
||||||
|
)
|
||||||
|
target_audience = st.text_input(
|
||||||
|
"👥 **Describe your target audience:**",
|
||||||
|
placeholder="e.g., Fitness enthusiasts",
|
||||||
|
help="Describe the audience you are targeting with this post."
|
||||||
|
)
|
||||||
|
include = st.text_input(
|
||||||
|
"📷 **What elements do you want to include?**",
|
||||||
|
placeholder="e.g., Short video with a sneak peek of the challenge",
|
||||||
|
help="Specify any elements you want to include in the post (e.g., images, videos, links, hashtags, questions)."
|
||||||
|
)
|
||||||
|
|
||||||
|
with col2:
|
||||||
|
post_tone_options = ["Informative", "Humorous", "Inspirational", "Upbeat", "Casual", "Customize"]
|
||||||
|
post_tone = st.selectbox(
|
||||||
|
"🎨 **What tone do you want to use?**",
|
||||||
|
post_tone_options,
|
||||||
|
index=3,
|
||||||
|
help="Choose the tone you want to use for the post."
|
||||||
|
)
|
||||||
|
|
||||||
|
if post_tone == "Customize":
|
||||||
|
post_tone = st.text_input(
|
||||||
|
"🎨 **Customize your tone:**",
|
||||||
|
placeholder="e.g., Professional",
|
||||||
|
help="Provide a specific tone if you selected 'Customize'."
|
||||||
)
|
)
|
||||||
|
|
||||||
if post_goal == "Customize":
|
business_type = st.text_input(
|
||||||
post_goal = st.text_input(
|
"🏢 **What is your business type?**",
|
||||||
"🎯 **Customize your goal:**",
|
placeholder="e.g., Fitness coach",
|
||||||
placeholder="e.g., Announce an event",
|
help="Provide the type of your business. This will help tailor the post content."
|
||||||
help="Provide a specific goal if you selected 'Customize'."
|
)
|
||||||
)
|
|
||||||
target_audience = st.text_input(
|
|
||||||
"👥 **Describe your target audience:**",
|
|
||||||
placeholder="e.g., Fitness enthusiasts",
|
|
||||||
help="Describe the audience you are targeting with this post."
|
|
||||||
)
|
|
||||||
include = st.text_input(
|
|
||||||
"📷 **What elements do you want to include?**",
|
|
||||||
placeholder="e.g., Short video with a sneak peek of the challenge",
|
|
||||||
help="Specify any elements you want to include in the post (e.g., images, videos, links, hashtags, questions)."
|
|
||||||
)
|
|
||||||
|
|
||||||
with col2:
|
avoid = st.text_input(
|
||||||
post_tone_options = ["Informative", "Humorous", "Inspirational", "Upbeat", "Casual", "Customize"]
|
"❌ **What elements do you want to avoid?**",
|
||||||
post_tone = st.selectbox(
|
placeholder="e.g., Long paragraphs",
|
||||||
"🎨 **What tone do you want to use?**",
|
help="Specify any elements you want to avoid in the post (e.g., long paragraphs, technical jargon)."
|
||||||
post_tone_options,
|
)
|
||||||
index=3,
|
|
||||||
help="Choose the tone you want to use for the post."
|
|
||||||
)
|
|
||||||
|
|
||||||
if post_tone == "Customize":
|
# Handle the generation button
|
||||||
post_tone = st.text_input(
|
if st.button("🚀 Generate Facebook Post"):
|
||||||
"🎨 **Customize your tone:**",
|
with st.spinner():
|
||||||
placeholder="e.g., Professional",
|
|
||||||
help="Provide a specific tone if you selected 'Customize'."
|
|
||||||
)
|
|
||||||
|
|
||||||
business_type = st.text_input(
|
|
||||||
"🏢 **What is your business type?**",
|
|
||||||
placeholder="e.g., Fitness coach",
|
|
||||||
help="Provide the type of your business. This will help tailor the post content."
|
|
||||||
)
|
|
||||||
|
|
||||||
avoid = st.text_input(
|
|
||||||
"❌ **What elements do you want to avoid?**",
|
|
||||||
placeholder="e.g., Long paragraphs",
|
|
||||||
help="Specify any elements you want to avoid in the post (e.g., long paragraphs, technical jargon)."
|
|
||||||
)
|
|
||||||
|
|
||||||
if st.button("🚀 Generate Facebook Post"):
|
|
||||||
if not business_type or not target_audience:
|
if not business_type or not target_audience:
|
||||||
st.error("🚫 Please provide the required inputs: Business Type and Target Audience.")
|
st.error("🚫 Please provide the required inputs: Business Type and Target Audience.")
|
||||||
else:
|
else:
|
||||||
generated_post = generate_facebook_post(
|
generated_post = generate_facebook_post(
|
||||||
business_type, target_audience, post_goal, post_tone, include, avoid
|
business_type, target_audience, post_goal, post_tone, include, avoid
|
||||||
)
|
)
|
||||||
|
|
||||||
if generated_post:
|
if generated_post:
|
||||||
st.subheader("**🧕 Verify: Alwrity can make mistakes.**")
|
st.markdown(generated_post)
|
||||||
st.write("## 📄 Generated Facebook Post:")
|
|
||||||
st.write(generated_post)
|
|
||||||
st.markdown("---")
|
|
||||||
else:
|
else:
|
||||||
st.error("Error: Failed to generate Facebook Post.")
|
st.error("Error: Failed to generate Facebook Post.")
|
||||||
except Exception as e:
|
|
||||||
st.error(f"An error occurred: {e}")
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import json
|
|||||||
import requests
|
import requests
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
|
|
||||||
|
from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||||
|
from ..ai_web_researcher.gpt_online_researcher import do_google_serp_search
|
||||||
|
|
||||||
|
|
||||||
def linked_post_writer():
|
def linked_post_writer():
|
||||||
# Title and description
|
# Title and description
|
||||||
@@ -43,12 +46,12 @@ def generate_linkedin_post(input_blog_keywords, input_linkedin_type, input_linke
|
|||||||
""" Function to call upon LLM to get the work done. """
|
""" Function to call upon LLM to get the work done. """
|
||||||
|
|
||||||
# Fetch SERP results & PAA questions for FAQ.
|
# Fetch SERP results & PAA questions for FAQ.
|
||||||
serp_results, people_also_ask = get_serp_results(input_blog_keywords)
|
serp_results, people_also_ask = do_google_serp_search(input_blog_keywords)
|
||||||
|
|
||||||
# If keywords and content both are given.
|
# If keywords and content both are given.
|
||||||
if serp_results:
|
if serp_results:
|
||||||
prompt = f"""As a SEO expert and experienced linkedin content writer,
|
prompt = f"""As an Experienced, industry veteran and experienced linkedin content writer,
|
||||||
I will provide you with my 'blog keywords' and 'google serp results'.
|
I will provide you with my 'blog keywords' and 'google serp results' done for the keywords.
|
||||||
Your task is to write a detailed linkedin post, using given keywords and search results.
|
Your task is to write a detailed linkedin post, using given keywords and search results.
|
||||||
|
|
||||||
Follow below guidelines for generating the linkedin post:
|
Follow below guidelines for generating the linkedin post:
|
||||||
@@ -59,9 +62,15 @@ def generate_linkedin_post(input_blog_keywords, input_linkedin_type, input_linke
|
|||||||
5). Optimise your response for blog type of {input_linkedin_type}.
|
5). Optimise your response for blog type of {input_linkedin_type}.
|
||||||
6). Important to provide your response in {input_linkedin_language} language.\n
|
6). Important to provide your response in {input_linkedin_language} language.\n
|
||||||
|
|
||||||
blog keywords: '{input_blog_keywords}'\n
|
Your final response should demostrate Experience, Expertise, Authoritativeness, and Trustworthiness.
|
||||||
google serp results: '{serp_results}'
|
|
||||||
people_also_ask: '{people_also_ask}'
|
blog keywords: \'\'\'{input_blog_keywords}\'\'\'
|
||||||
|
google serp results: \'\'\'{serp_results}\'\'\'
|
||||||
"""
|
"""
|
||||||
linkedin_post = generate_text_with_exception_handling(prompt)
|
|
||||||
return linkedin_post
|
try:
|
||||||
|
response = llm_text_gen(prompt)
|
||||||
|
return response
|
||||||
|
except Exception as err:
|
||||||
|
st.error(f"Failed to generate Open Graph tags: {err}")
|
||||||
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user