New: AI SEO tools, OpenGraph Tags generator
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
# How to ALwrity - Getting Started
|
||||
|
||||
Alwrity assists content creators and digital marketers in keyword web research, AI website & Social media content generation & AI Copywriting.
|
||||
Our toolkit integrates **(OpenAI, Gemini, Anthropic)** AI models for text generation, image creation **(Stability.ai), STT(whisper, AssemblyAI)** and Web or local data analysis, streamlining your content creation pipeline and ensuring high-quality output with minimal effort.
|
||||
Our toolkit integrates **(OpenAI, Gemini, Anthropic)** AI models for text generation, image creation **(Stability.ai), STT(whisper, AssemblyAI)** and AI Web research **(Tavily AI, exa AI, Serper.dev)**, streamlining your content creation pipeline and ensuring high-quality output with minimal effort.
|
||||
|
||||
Prompting is abstracted to get going sooner. Focus on your content quality, rather than AI tooling around it.
|
||||
Alwrity gives hyper content personalization, factual web researched & SEO optimized content and tools for automating content & digital marketing.
|
||||
|
||||
Alwrity, is a complete content life cycle platform with Content planning, Content Generation, Content publishing, Analytics & monitoring & more. AI SEO & marketing tools will help reach wider audience. Its in active development with many bridges to cross.
|
||||
|
||||
AI will help achieve Content Hyper-Personalization.
|
||||

|
||||
---
|
||||
|
||||
116
lib/ai_seo_tools/opengraph_generator.py
Normal file
116
lib/ai_seo_tools/opengraph_generator.py
Normal file
@@ -0,0 +1,116 @@
|
||||
import streamlit as st
|
||||
import os
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from ..ai_web_researcher.firecrawl_web_crawler import scrape_url
|
||||
from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||
|
||||
|
||||
def generate_og_tags(url, title_hint, description_hint, platform="General"):
|
||||
"""
|
||||
Generate Open Graph tags based on the provided URL, title hint, description hint, and platform.
|
||||
|
||||
Args:
|
||||
url (str): The URL of the webpage.
|
||||
title_hint (str): A hint for the title.
|
||||
description_hint (str): A hint for the description.
|
||||
platform (str): The platform for which to generate the tags (General, Facebook, or Twitter).
|
||||
|
||||
Returns:
|
||||
str: The generated Open Graph tags or an error message.
|
||||
"""
|
||||
prompt = (
|
||||
f"Generate Open Graph tags for the following page:\nURL: {url}\n"
|
||||
f"Title hint: {title_hint}\nDescription hint: {description_hint}"
|
||||
)
|
||||
if platform == "Facebook":
|
||||
prompt += "\nSpecifically for Facebook"
|
||||
elif platform == "Twitter":
|
||||
prompt += "\nSpecifically for Twitter"
|
||||
|
||||
try:
|
||||
response = llm_text_gen(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
st.error(f"Failed to generate Open Graph tags: {err}")
|
||||
return None
|
||||
|
||||
|
||||
def extract_default_og_tags(url):
|
||||
"""
|
||||
Extract default Open Graph tags from the provided URL.
|
||||
|
||||
Args:
|
||||
url (str): The URL of the webpage.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the title, description, and image URL, or None in case of an error.
|
||||
"""
|
||||
try:
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
|
||||
soup = BeautifulSoup(response.content, 'html.parser')
|
||||
title = soup.find('title').text if soup.find('title') else None
|
||||
description = soup.find('meta', attrs={'name': 'description'})['content'] if soup.find('meta', attrs={'name': 'description'}) else None
|
||||
image_url = soup.find('meta', attrs={'property': 'og:image'})['content'] if soup.find('meta', attrs={'property': 'og:image'}) else None
|
||||
|
||||
return title, description, image_url
|
||||
|
||||
except requests.exceptions.RequestException as req_err:
|
||||
st.error(f"Error fetching the URL: {req_err}")
|
||||
return None, None, None
|
||||
|
||||
except Exception as err:
|
||||
st.error(f"Error parsing the HTML content: {err}")
|
||||
return None, None, None
|
||||
|
||||
|
||||
def og_tag_generator():
|
||||
"""Main function to run the Streamlit app."""
|
||||
st.title("AI Open Graph Tag Generator")
|
||||
|
||||
platform = st.selectbox(
|
||||
"**Select the platform**",
|
||||
["General", "Facebook", "Twitter"],
|
||||
help="Choose the platform for which you want to generate Open Graph tags."
|
||||
)
|
||||
|
||||
url = st.text_input(
|
||||
"**Enter the URL of the page to generate Opengraph tags for:**",
|
||||
placeholder="e.g., https://example.com",
|
||||
help="Provide the URL of the page you want to generate Open Graph tags for."
|
||||
)
|
||||
|
||||
if url:
|
||||
title, description, image_url = extract_default_og_tags(url)
|
||||
# Use firecrawl to get the metadata of webpage.
|
||||
#existing_metadata = scrape_url(url)
|
||||
title_hint = st.text_input(
|
||||
"**Modify existing title Or Suggest New One (optional):**",
|
||||
value=title if title else "",
|
||||
placeholder="e.g., Amazing Blog Post Title"
|
||||
)
|
||||
|
||||
description_hint = st.text_area(
|
||||
"**Modifying existing description Or Suggest New One (optional):**",
|
||||
value=description if description else "",
|
||||
placeholder="e.g., This is a detailed description of the content."
|
||||
)
|
||||
|
||||
image_hint = st.text_input(
|
||||
"**Use this image Or Suggest New URL (optional):**",
|
||||
value=image_url if image_url else "",
|
||||
placeholder="e.g., https://example.com/image.jpg"
|
||||
)
|
||||
|
||||
if st.button("Generate Open Graph Tags"):
|
||||
with st.spinner("Generating Open Graph tags..."):
|
||||
og_tags = generate_og_tags(url, title_hint, description_hint, platform)
|
||||
if og_tags:
|
||||
st.success("Open Graph tags generated successfully!")
|
||||
st.markdown(og_tags)
|
||||
else:
|
||||
st.error("Failed to generate Open Graph tags.")
|
||||
else:
|
||||
st.info("Please enter a URL to generate Open Graph tags.")
|
||||
@@ -4,8 +4,9 @@ from bs4 import BeautifulSoup
|
||||
import requests
|
||||
import os
|
||||
|
||||
# Set up OpenAI API key
|
||||
openai.api_key = os.getenv('OPENAI_API_KEY') # Assuming you have it in a .env file
|
||||
from ..ai_web_researcher.firecrawl_web_crawler import scrape_url
|
||||
from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||
|
||||
|
||||
# Placeholder function for web scraping the URL (to be replaced with your mechanism)
|
||||
def scrape_webpage(url):
|
||||
|
||||
@@ -61,13 +61,14 @@ def scrape_url(url):
|
||||
dict: The result of the URL scraping, or None if an error occurred.
|
||||
"""
|
||||
client = initialize_client()
|
||||
params = {
|
||||
'pageOptions': {
|
||||
'onlyMainContent': True
|
||||
}
|
||||
}
|
||||
#params = {
|
||||
#'pageOptions': {
|
||||
# 'onlyMainContent': True
|
||||
# }
|
||||
#}
|
||||
try:
|
||||
result = client.scrape_url(url, params=params)
|
||||
#result = client.scrape_url(url, params=params)
|
||||
result = client.scrape_url(url)
|
||||
return result
|
||||
except Exception as e:
|
||||
logging.error(f"Error scraping URL: {e}")
|
||||
|
||||
@@ -42,6 +42,7 @@ 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
|
||||
from lib.ai_seo_tools.image_alt_text_generator import alt_text_gen
|
||||
from lib.ai_seo_tools.opengraph_generator import og_tag_generator
|
||||
from lib.gpt_providers.text_to_image_generation.main_generate_image_from_prompt import generate_image
|
||||
from lib.content_planning_calender.content_planning_agents_alwrity_crew import ai_agents_planner
|
||||
from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||
@@ -126,7 +127,7 @@ def ai_seo_tools():
|
||||
"Generate SEO optimized Blog Titles",
|
||||
"Generate Meta Description for SEO",
|
||||
"Generate Image Alt Text",
|
||||
"Quit"
|
||||
"Generate OpenGraph Tags"
|
||||
]
|
||||
choice = st.selectbox("**👇Select AI SEO Tool:**", options, index=0, format_func=lambda x: f"📝 {x}")
|
||||
|
||||
@@ -138,6 +139,8 @@ def ai_seo_tools():
|
||||
ai_title_generator()
|
||||
elif choice == "Generate Image Alt Text":
|
||||
alt_text_gen()
|
||||
elif choice == "Generate OpenGraph Tags":
|
||||
og_tag_generator()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user