WIP- Try AI-Writer and Web research; working. Working on usuability aspects.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
from .gpt_providers.openai_gpt_provider import openai_chatgpt
|
||||
from .gpt_providers.gemini_pro_text import gemini_text_response
|
||||
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv(Path('../.env'))
|
||||
from loguru import logger
|
||||
logger.remove()
|
||||
logger.add(sys.stdout,
|
||||
@@ -10,11 +11,15 @@ logger.add(sys.stdout,
|
||||
format="<level>{level}</level>|<green>{file}:{line}:{function}</green>| {message}"
|
||||
)
|
||||
|
||||
from ..gpt_providers.openai_gpt_provider import openai_chatgpt
|
||||
from ..gpt_providers.gemini_pro_text import gemini_text_response
|
||||
|
||||
def get_blog_categories(blog_article, gpt_providers):
|
||||
|
||||
def get_blog_categories(blog_article):
|
||||
"""
|
||||
Function to generate blog categories for given blog content.
|
||||
"""
|
||||
gpt_providers = os.environ["GPT_PROVIDER"]
|
||||
prompt = f"""As an expert SEO and content writer, I will provide you with blog content.
|
||||
Suggest only 2 blog categories which are most relevant to provided blog content,
|
||||
by identifying the main topic. Also consider the target audience and the
|
||||
@@ -22,7 +27,7 @@ def get_blog_categories(blog_article, gpt_providers):
|
||||
The blog content is: '{blog_article}'"
|
||||
"""
|
||||
logger.info("Generating blog categories for the given blog.")
|
||||
if 'gemini' in gpt_providers:
|
||||
if 'google' in gpt_providers:
|
||||
try:
|
||||
response = gemini_text_response(prompt)
|
||||
return response
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from .gpt_providers.openai_chat_completion import openai_chatgpt
|
||||
from .gpt_providers.gemini_pro_text import gemini_text_response
|
||||
import google.generativeai as genai
|
||||
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv(Path('../.env'))
|
||||
|
||||
@@ -16,11 +11,15 @@ logger.add(sys.stdout,
|
||||
format="<level>{level}</level>|<green>{file}:{line}:{function}</green>| {message}"
|
||||
)
|
||||
|
||||
from ..gpt_providers.openai_chat_completion import openai_chatgpt
|
||||
from ..gpt_providers.gemini_pro_text import gemini_text_response
|
||||
|
||||
def generate_blog_description(blog_content, gpt_providers):
|
||||
|
||||
def generate_blog_description(blog_content):
|
||||
"""
|
||||
Prompt designed to give SEO optimized blog descripton
|
||||
"""
|
||||
gpt_providers = os.environ["GPT_PROVIDER"]
|
||||
logger.info("Generating Blog Meta Description for the given blog.")
|
||||
prompt = f"""As an expert SEO and blog writer, Compose a compelling meta description for the given blog content,
|
||||
adhering to SEO best practices. Keep it between 150-160 characters.
|
||||
@@ -28,7 +27,7 @@ def generate_blog_description(blog_content, gpt_providers):
|
||||
Respond with only one of your best effort and do not include your explanations.
|
||||
Blog Content: '{blog_content}'"""
|
||||
|
||||
if 'gemini' in gpt_providers:
|
||||
if 'google' in gpt_providers:
|
||||
try:
|
||||
response = gemini_text_response(prompt)
|
||||
return response
|
||||
|
||||
@@ -13,14 +13,14 @@ logger.add(sys.stdout,
|
||||
)
|
||||
|
||||
|
||||
def blog_metadata(blog_content, gpt_providers="openai"):
|
||||
def blog_metadata(blog_content, search_keywords, blog_titles):
|
||||
""" Common function to get blog metadata """
|
||||
blog_title = generate_blog_title(blog_content, gpt_providers)
|
||||
blog_meta_desc = generate_blog_description(blog_content, gpt_providers)
|
||||
blog_title = generate_blog_title(blog_content, search_keywords, blog_titles)
|
||||
blog_meta_desc = generate_blog_description(blog_content)
|
||||
logger.info(f"The blog meta description is: {blog_meta_desc}\n")
|
||||
blog_tags = get_blog_tags(blog_content, gpt_providers)
|
||||
blog_tags = get_blog_tags(blog_content)
|
||||
logger.info(f"Blog tags for generated content: {blog_tags}")
|
||||
blog_categories = get_blog_categories(blog_content, gpt_providers)
|
||||
blog_categories = get_blog_categories(blog_content)
|
||||
logger.info(f"Generated blog categories: {blog_categories}\n")
|
||||
|
||||
return(blog_title, blog_meta_desc, blog_tags, blog_categories)
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from .gpt_providers.openai_chat_completion import openai_chatgpt
|
||||
from .gpt_providers.gemini_pro_text import gemini_text_response
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv(Path('../../.env'))
|
||||
|
||||
from ..gpt_providers.openai_chat_completion import openai_chatgpt
|
||||
from ..gpt_providers.gemini_pro_text import gemini_text_response
|
||||
|
||||
from loguru import logger
|
||||
logger.remove()
|
||||
@@ -11,20 +16,33 @@ logger.add(sys.stdout,
|
||||
)
|
||||
|
||||
|
||||
def generate_blog_title(blog_article, gpt_providers="openai"):
|
||||
def generate_blog_title(blog_article, keywords=None, example_titles=None, num_titles=1):
|
||||
"""
|
||||
Given a blog title generate an outline for it
|
||||
"""
|
||||
prompt = ''
|
||||
gpt_providers = os.environ["GPT_PROVIDER"]
|
||||
logger.info("Generating blog title.")
|
||||
prompt = f"""As a SEO expert, I will provide you with a blog content.
|
||||
Your task is write a SEO optimized, call to action and engaging blog title for it.
|
||||
Follows SEO best practises to suggest the blog title.
|
||||
Please keep the titles concise, not exceeding 60 words.
|
||||
Respond with only one title and no explanations.
|
||||
Important: Your response should be in plaintext.
|
||||
Generate blog title for this given blog content:\n '{blog_article}' """
|
||||
|
||||
if 'gemini' in gpt_providers:
|
||||
if not keywords and not example_titles:
|
||||
prompt = f"""As a SEO expert, I will provide you with a blog content.
|
||||
Your task is write a SEO optimized and call to action, blog title for given blog content.
|
||||
Follow SEO best practises to suggest the blog title.
|
||||
Please keep the titles concise, not exceeding 60 words.
|
||||
Respond with only {num_titles} title and no explanations.
|
||||
Negative Keywords: Unvieling, unleash, power of. Dont use such words in your title.
|
||||
Generate {num_titles} blog title for this given blog content:\n '{blog_article}' """
|
||||
elif keywords and example_titles:
|
||||
prompt = f"""As a SEO expert, I will provide you with my blog keywords and example titles.
|
||||
Your task is to write {num_titles} blog title.
|
||||
Ensure that your blog titles will help in competing against given example titles.
|
||||
Follow SEO best practises to suggest the blog title.
|
||||
Please keep the titles concise, not exceeding 60 words.
|
||||
Respond with only {num_titles} title and no explanations.
|
||||
Negative Keywords: Unvieling, unleash, power of. Dont use such words in your title.
|
||||
Blog Keywords: '{keywords}'
|
||||
Example Titles: '{example_titles}'
|
||||
"""
|
||||
if 'google' in gpt_providers:
|
||||
try:
|
||||
response = gemini_text_response(prompt)
|
||||
return response
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
from .gpt_providers.openai_chat_completion import openai_chatgpt
|
||||
from .gpt_providers.gemini_pro_text import gemini_text_response
|
||||
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv(Path('../.env'))
|
||||
from loguru import logger
|
||||
logger.remove()
|
||||
logger.add(sys.stdout,
|
||||
@@ -10,17 +11,21 @@ logger.add(sys.stdout,
|
||||
format="<level>{level}</level>|<green>{file}:{line}:{function}</green>| {message}"
|
||||
)
|
||||
|
||||
from ..gpt_providers.openai_chat_completion import openai_chatgpt
|
||||
from ..gpt_providers.gemini_pro_text import gemini_text_response
|
||||
|
||||
def get_blog_tags(blog_article, gpt_providers):
|
||||
|
||||
def get_blog_tags(blog_article):
|
||||
"""
|
||||
Function to suggest tags for the given blog content
|
||||
"""
|
||||
# Suggest at least 5 tags for the following blog post [Enter your blog post text here].
|
||||
gpt_providers = os.environ["GPT_PROVIDER"]
|
||||
prompt = f"""As an expert SEO and blog writer, suggest only 2 relevant and specific blog tags
|
||||
for the given blog content. Only reply with comma separated values.
|
||||
Blog content: {blog_article}."""
|
||||
logger.info("Generating Blog tags for the given blog post.")
|
||||
if 'gemini' in gpt_providers:
|
||||
if 'google' in gpt_providers:
|
||||
try:
|
||||
response = gemini_text_response(prompt)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user