Improved, refactored, added options, prompts, jekyll website
This commit is contained in:
1
lib/__init__.py
Normal file
1
lib/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# This file makes the `lib` directory a Python package
|
||||
@@ -8,16 +8,19 @@
|
||||
########################################################################
|
||||
|
||||
import json
|
||||
import os
|
||||
import datetime #I wish
|
||||
|
||||
import openai
|
||||
from tqdm import tqdm, trange
|
||||
import time
|
||||
import re
|
||||
from textwrap import dedent
|
||||
|
||||
from .gpt_providers.openai_gpt_provider import openai_chatgpt
|
||||
|
||||
|
||||
def generate_detailed_blog(num_blogs, blog_keywords, niche):
|
||||
def generate_detailed_blog(num_blogs, blog_keywords, niche, num_subtopics):
|
||||
"""
|
||||
This function will take a blog Topic to first generate sections for it
|
||||
and then generate content for each section.
|
||||
@@ -34,34 +37,44 @@ def generate_detailed_blog(num_blogs, blog_keywords, niche):
|
||||
|
||||
# Use to store the blog in a string, to save in a *.md file.
|
||||
blog_markdown_str = ""
|
||||
|
||||
|
||||
# TBD: Check if the generated topics are equal to what user asked.
|
||||
blog_topic_arr = generate_blog_topics(blog_keywords, num_blogs, niche)
|
||||
print(f"Generated Blog Topics:---- {blog_topic_arr}")
|
||||
print(f"Generated Blog Topics:---- {blog_topic_arr}\n")
|
||||
|
||||
# For each of blog topic, generate content.
|
||||
for a_blog_topic in blog_topic_arr:
|
||||
# if md/html
|
||||
blog_markdown_str = "# " + a_blog_topic + "\n"
|
||||
|
||||
blog_markdown_str = "# " + a_blog_topic.replace('"', '') + "\n\n"
|
||||
# Get the introduction specific to blog title and sub topics.
|
||||
tpc_outlines = generate_topic_outline(a_blog_topic)
|
||||
tpc_outlines = generate_topic_outline(a_blog_topic, num_subtopics)
|
||||
blog_intro = get_blog_intro(a_blog_topic, tpc_outlines)
|
||||
blog_markdown_str = blog_markdown_str + "### Introduction" + "\n" + f"{blog_intro}" + "\n"
|
||||
|
||||
print(f"The intro is:\n {blog_intro}")
|
||||
blog_markdown_str = blog_markdown_str + "### Introduction" + "\n\n" + f"{blog_intro}" + "\n\n"
|
||||
# Now, for each blog we have sub topic. Generate content for each of the sub topic.
|
||||
for a_outline in tpc_outlines:
|
||||
sub_topic_content = generate_topic_content(blog_keywords, a_outline)
|
||||
blog_markdown_str = blog_markdown_str + "\n" + f"\n{sub_topic_content}" + "\n"
|
||||
print(f"Generating content for sub-topic: {a_outline}")
|
||||
# a_outline is sub topic heading, hence part ToC also.
|
||||
blog_markdown_str = blog_markdown_str + "\n\n" + f"### {a_outline}" + "\n\n"
|
||||
blog_markdown_str = blog_markdown_str + "\n" + f"\n {sub_topic_content}" + "\n\n"
|
||||
blog_markdown_str = blog_markdown_str + "\n" + "-------------------------" + "\n"
|
||||
|
||||
# Get the Conclusion of the blog, by passing the generated blog.
|
||||
blog_conclusion = get_blog_conclusion(blog_markdown_str)
|
||||
blog_markdown_str = blog_markdown_str + "# Conclusion" + "\n" + f"{blog_conclusion}" + "\n"
|
||||
blog_markdown_str = blog_markdown_str + "### Conclusion" + "\n" + f"{blog_conclusion}" + "\n"
|
||||
|
||||
# print/check the final blog content.
|
||||
print(f"Final blog content: {blog_markdown_str}")
|
||||
# Save the blog content as a .md file. Markdown or HTML ?
|
||||
save_blog_to_file(blog_markdown_str)
|
||||
blog_meta_desc = generate_blog_description(blog_markdown_str)
|
||||
print(f"\nGet the blog meta description:{blog_meta_desc}")
|
||||
blog_tags = get_blog_tags(blog_markdown_str)
|
||||
print(f"\nBlog tags for generated content: {blog_tags}")
|
||||
blog_categories = get_blog_categories(blog_markdown_str)
|
||||
print(f"Generated blog categories: {blog_categories}")
|
||||
|
||||
# TBD: Save the blog content as a .md file. Markdown or HTML ?
|
||||
save_blog_to_file(blog_markdown_str, a_blog_topic, blog_meta_desc, blog_tags, blog_categories)
|
||||
|
||||
exit(1)
|
||||
|
||||
@@ -82,24 +95,25 @@ def generate_blog_topics(blog_keywords, num_blogs, niche):
|
||||
one for generating unique blog content.
|
||||
Ex: Generate SEO optimized blog topics on given keywords
|
||||
"""
|
||||
# Get more keywords, based on user given keywords.
|
||||
prompt = f"""As an SEO specialist and blog content writer, please write {num_blogs} catchy
|
||||
and SEO-friendly blog topics on {blog_keywords}. The blog title must be less than 80 characters.
|
||||
"""
|
||||
# Beware of keywords stuffing, clustering, semantic should help avoid.
|
||||
more_keywords = get_related_keywords(num_blogs, blog_keywords, niche)
|
||||
# f"including the following keywords: {more_keywords}."
|
||||
prompt = ("As an SEO specialist and blog content writer, "
|
||||
f"please write {num_blogs} catchy and SEO-friendly blog topics on {blog_keywords},"
|
||||
f"including the following keywords: {more_keywords}."
|
||||
)
|
||||
print(f"prompt used for blog titles: {prompt}")
|
||||
if num_blogs > 5:
|
||||
# Get more keywords, based on user given keywords.
|
||||
more_keywords = get_related_keywords(num_blogs, blog_keywords, niche)
|
||||
prompt = prompt + """Use the following keywords wisely, without keyword stuffing: {more_keywords}"""
|
||||
|
||||
print(f"prompt used for blog titles: {prompt}\n")
|
||||
# Calculate the max tokens based on the number of blogs
|
||||
max_tokens = min(1000, num_blogs * 100)
|
||||
try:
|
||||
response = openai_chatgpt(
|
||||
prompt,
|
||||
model="text-davinci-003",
|
||||
temperature=0.9,
|
||||
temperature=0.1,
|
||||
max_tokens=max_tokens,
|
||||
top_p=0.9,
|
||||
top_p=1,
|
||||
n=1
|
||||
)
|
||||
topic_list = extract_key_text(response)
|
||||
@@ -108,23 +122,23 @@ def generate_blog_topics(blog_keywords, num_blogs, niche):
|
||||
SystemError(f"Error in generating blog topics: {err}")
|
||||
|
||||
|
||||
def generate_topic_outline(blog_title):
|
||||
def generate_topic_outline(blog_title, num_subtopics):
|
||||
"""
|
||||
Given a blog title generate an outline for it
|
||||
"""
|
||||
# TBD: Remove hardcoding, make dynamic
|
||||
prompt = ("As a technical writer and SEO expert, suggest 7 beginner-friendly and helpful sub-topics"
|
||||
f"for the blog title '{blog_title}',"
|
||||
"Include 2 sub topics on related long-tailed keywords and "
|
||||
"2 sub topics on most popular questions."
|
||||
)
|
||||
prompt = f"""As a SEO expert, suggest only {num_subtopics}
|
||||
beginner-friendly and insightful sub topic for the blog title: {blog_title}.
|
||||
"""
|
||||
# The suggested {num_subtopics} outline should include few long-tailed keywords and most popular questions.
|
||||
# TBD: Include --niche
|
||||
print(f"prompt used for blog title Outline :{prompt}")
|
||||
# TBD: Add logic for which_provider and which_model
|
||||
response = openai_chatgpt(
|
||||
prompt,
|
||||
model="text-davinci-003",
|
||||
temperature=0.7,
|
||||
max_tokens=1000,
|
||||
temperature=0.1,
|
||||
max_tokens=100,
|
||||
top_p=0.9,
|
||||
n=1
|
||||
)
|
||||
@@ -139,9 +153,13 @@ def generate_topic_content(blog_keywords, sub_topic):
|
||||
For each of given topic generate content for it.
|
||||
"""
|
||||
# The outline should contain various subheadings and include the starting sentence for each section.
|
||||
prompt = (f"As a professional writer and topic authority on '{blog_keywords}',"
|
||||
f"craft a captivating, inviting and factual (no more than 700 characters) blog content on {sub_topic}."
|
||||
f"Use bulleit points and other readibility enhancers."
|
||||
# TBD: Depending on the usecase 'Voice and style' will change to professional etc.
|
||||
prompt = (f"As a professional blogger and topic authority on '{blog_keywords}',"
|
||||
f"craft factual (no more than 700 characters) blog content on {sub_topic}."
|
||||
"Your response should reflect Experience, Expertise, Authoritativeness, and Trustworthiness from content."
|
||||
"Voice and style guide: Write in a professional manner, giving enlightening details and reasons."
|
||||
"Use natural language and phrases that a real person would use: in normal conversations."
|
||||
"Format your response using markdown. Use headings, subheadings, bullet points, and bold to organize the information."
|
||||
)
|
||||
try:
|
||||
response = openai_chatgpt(prompt)
|
||||
@@ -167,16 +185,16 @@ def get_blog_intro(blog_title, blog_topics):
|
||||
"""
|
||||
Generate blog introduction as per title and sub topics
|
||||
"""
|
||||
prompt = (f"As a professional writer, craft a captivating, inviting, and concise (no more than 550 characters)"
|
||||
f"introduction for the blog titled '{blog_title}' with the following sub-topics: '{blog_topics}'"
|
||||
f"The introduction should compel readers to delve deeper into the blog post."
|
||||
)
|
||||
prompt = f"""As a professional writer, craft a captivating, inviting, and concise (no more than 550 characters).
|
||||
The introduction should compel readers to delve deeper into the blog post,
|
||||
titled: {blog_title} with the following sub-topics: {blog_topics}
|
||||
"""
|
||||
try:
|
||||
# TBD: Add logic for which_provider and which_model
|
||||
response = openai_chatgpt(
|
||||
prompt,
|
||||
model="text-davinci-003",
|
||||
temperature=0.7,
|
||||
temperature=0.1,
|
||||
max_tokens=1000,
|
||||
top_p=0.9,
|
||||
n=1
|
||||
@@ -193,15 +211,16 @@ def get_blog_conclusion(blog_content):
|
||||
"""
|
||||
Accepts a blog content and concludes it.
|
||||
"""
|
||||
prompt = ("As an expert SEO and blog writer, please conclude the given blog providing vital take aways,"
|
||||
"summarise key points (no more than 300 characters). The blog content: '{blog_content}'"
|
||||
)
|
||||
prompt = f"""As an expert SEO and blog writer, please conclude the given blog providing vital take aways,
|
||||
summarise key points (no more than 300 characters) in bullet points. The blog content: {blog_content}
|
||||
"""
|
||||
print(f"Generating blog conclusion iwth prompt: {prompt}")
|
||||
try:
|
||||
# TBD: Add logic for which_provider and which_model
|
||||
response = openai_chatgpt(
|
||||
prompt,
|
||||
model="text-davinci-003",
|
||||
temperature=0.9,
|
||||
temperature=0.1,
|
||||
max_tokens=450,
|
||||
top_p=0.7,
|
||||
n=1
|
||||
@@ -214,15 +233,37 @@ def get_blog_conclusion(blog_content):
|
||||
SystemError(f"Error in generating blog conclusion: {err}")
|
||||
|
||||
|
||||
def generate_blog_description():
|
||||
def generate_blog_description(blog_content):
|
||||
"""
|
||||
Prompt designed to give SEO optimized blog descripton
|
||||
"""
|
||||
# Suggest keywords that I should include in my meta description for my blog post on [topic]
|
||||
# I want to generate high CTR meta and keyword rich meta title and meta descriptions in text format.
|
||||
# My keywords are – [keyword 1], [keyword 2], [keyword 3]
|
||||
# Suggest a meta description for the content above, make it user-friendly
|
||||
# and with a call to action, include the keyword [keyword].
|
||||
prompt = f"""As an expert SEO and blog writer, write meta description for given blog content.
|
||||
The description should be between 150 and 160 characters long, uses strong, active verbs,
|
||||
avoids using all caps or excessive punctuation, and is relevant to the blog content.
|
||||
It should be engaging and encourages users to click on the link.
|
||||
The blog content: {blog_content}"""
|
||||
|
||||
pass
|
||||
try:
|
||||
# TBD: Add logic for which_provider and which_model
|
||||
response = openai_chatgpt(
|
||||
prompt,
|
||||
model="text-davinci-003",
|
||||
temperature=0.1,
|
||||
max_tokens=450,
|
||||
top_p=0.7,
|
||||
n=1
|
||||
)
|
||||
text_values = []
|
||||
for choice in response["choices"]:
|
||||
text_values.extend(choice["text"].split("\n"))
|
||||
return (' '.join([element for element in text_values if element]))
|
||||
except Exception as err:
|
||||
SystemError(f"Error in generating blog description: {err}")
|
||||
|
||||
|
||||
def get_blog_tags(blog_article):
|
||||
@@ -230,33 +271,101 @@ 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].
|
||||
pass
|
||||
prompt = f"""As an expert SEO and blog writer, suggest 3 to 5 relevant, specific,
|
||||
and popular tags that are unique and consistent to improve the visibility
|
||||
and discoverability of following blog content: {blog_article}"
|
||||
"""
|
||||
try:
|
||||
# TBD: Add logic for which_provider and which_model
|
||||
response = openai_chatgpt(
|
||||
prompt,
|
||||
model="text-davinci-003",
|
||||
temperature=0.1,
|
||||
max_tokens=450,
|
||||
top_p=0.7,
|
||||
n=1
|
||||
)
|
||||
text_values = []
|
||||
for choice in response["choices"]:
|
||||
text_values.extend(choice["text"].split("\n"))
|
||||
return (' '.join([element for element in text_values if element]))
|
||||
except Exception as err:
|
||||
SystemError(f"Error in generating blog tags: {err}")
|
||||
|
||||
|
||||
def get_long_tailed_keywords(blog_article):
|
||||
def get_blog_categories(blog_article):
|
||||
"""
|
||||
Function to get long tailed keywords for the blog article.
|
||||
Function to generate blog categories for given blog content.
|
||||
"""
|
||||
# Want you to generate a list of long-tail keywords that are related
|
||||
# to the following blog post [Enter blog post text here]
|
||||
pass
|
||||
prompt = f"""As an expert SEO and content writer, Suggest 2-3 blog categories by identifying
|
||||
the main topic, most relevant categories, considering the target
|
||||
audience and the blog's category taxonomy for the following blog content: {blog_article}"
|
||||
"""
|
||||
try:
|
||||
# TBD: Add logic for which_provider and which_model
|
||||
response = openai_chatgpt(
|
||||
prompt,
|
||||
model="text-davinci-003",
|
||||
temperature=0.1,
|
||||
max_tokens=100,
|
||||
top_p=0.7,
|
||||
n=1
|
||||
)
|
||||
text_values = []
|
||||
for choice in response["choices"]:
|
||||
text_values.extend(choice["text"].split("\n"))
|
||||
return (' '.join([element for element in text_values if element]))
|
||||
except Exception as err:
|
||||
SystemError(f"Error in generating blog categories: {err}")
|
||||
|
||||
|
||||
def save_blog_to_file(blog_content, file_type="md"):
|
||||
def save_blog_to_file(blog_content, blog_title,
|
||||
blog_meta_desc, blog_tags, blog_categories, file_type="md"
|
||||
):
|
||||
""" Common function to save the generated blog to a file.
|
||||
arg: file_type can be md or html
|
||||
"""
|
||||
output_path = "../generated_blogs"
|
||||
# TBD: This can come from config file.
|
||||
output_path = "pseo_website/_posts/"
|
||||
output_path = os.path.join(os.getcwd(), output_path)
|
||||
# Convert the spaces in blog_title with dash
|
||||
regex = re.compile('[^a-zA-Z0-9- ]')
|
||||
blog_title = regex.sub('', blog_title)
|
||||
blog_title = re.sub('--+', '-', blog_title)
|
||||
blog_title = blog_title.replace(' ', '-')
|
||||
|
||||
if not os.path.exists(output_path):
|
||||
# If the directory does not exist, create it
|
||||
os.makedirs(output_path)
|
||||
#os.makedirs(output_path)
|
||||
print("Error: Blog output directory is set to {output_path}, which Does Not Exist.")
|
||||
|
||||
output_today = os.path.join(output_path, f'{datetime.date.today().strftime("%d-%m-%y")}')
|
||||
if not os.path.exists(output_today):
|
||||
os.makedirs(output_today)
|
||||
else:
|
||||
with open(f"{output_today}/{blog_title}.md", "w") as f:
|
||||
f.write(blog_content)
|
||||
if file_type in "md":
|
||||
# fill the Front Matter as below at the top of the post: https://jekyllrb.com/docs/front-matter/
|
||||
# date: YYYY-MM-DD HH:MM:SS +/-TTTT
|
||||
formatted_date = f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S %z}"
|
||||
blog_frontmatter = """---
|
||||
title: {blog_title}
|
||||
date: {formatted_date}
|
||||
categories: [{blog_categories}]
|
||||
tags: [{blog_tags}]
|
||||
description: {blog_meta_desc}
|
||||
img_path: '/posts/20180809'
|
||||
---\n\n"""
|
||||
|
||||
# Create a new file named YYYY-MM-DD-TITLE.EXTENSION and put it in the _posts of the root directory.
|
||||
# Please note that the EXTENSION must be one of md or markdown
|
||||
blog_output_path = os.path.join(
|
||||
output_path,
|
||||
f"{datetime.date.today().strftime('%Y-%m-%d')}-{blog_title}.md"
|
||||
)
|
||||
# Save the generated blog content to a file.
|
||||
try:
|
||||
with open(blog_output_path, "w") as f:
|
||||
f.write(dedent(blog_frontmatter))
|
||||
f.write(blog_content)
|
||||
except Exception as e:
|
||||
raise Exception(f"Failed to write blog content: {e}")
|
||||
print(f"\nSuccessfully saved and Posted blog at: {blog_output_path,}\n")
|
||||
|
||||
|
||||
def extract_key_text(json_data):
|
||||
@@ -311,36 +420,39 @@ def get_related_keywords(num_blogs, keywords, niche):
|
||||
f" semantically related keywords and entities for the topic of {keywords} that are used"
|
||||
" in high-quality content and relevant to my competitors."
|
||||
)
|
||||
# TBD: Add logic for which_provider and which_model
|
||||
response = openai_chatgpt(
|
||||
prompt,
|
||||
model="text-davinci-003",
|
||||
temperature=0.7,
|
||||
max_tokens=100,
|
||||
top_p=0.9,
|
||||
n=10
|
||||
)
|
||||
try:
|
||||
# TBD: Add logic for which_provider and which_model
|
||||
response = openai_chatgpt(
|
||||
prompt,
|
||||
model="text-davinci-003",
|
||||
temperature=0.7,
|
||||
max_tokens=100,
|
||||
top_p=0.9,
|
||||
n=10
|
||||
)
|
||||
|
||||
# Extract the keywords from the response
|
||||
keywords = []
|
||||
for choice in response.choices:
|
||||
# Split the response into words
|
||||
words = choice.text.split(" ")
|
||||
# Extract the keywords from the response
|
||||
keywords = []
|
||||
for choice in response.choices:
|
||||
# Split the response into words
|
||||
words = choice.text.split(" ")
|
||||
|
||||
# Add the words to the list of keywords
|
||||
for text in words:
|
||||
# Remove digits
|
||||
text = re.sub(r'\d', '', text)
|
||||
# Add the words to the list of keywords
|
||||
for text in words:
|
||||
# Remove digits
|
||||
text = re.sub(r'\d', '', text)
|
||||
|
||||
# Remove special characters
|
||||
text = re.sub(r'[^\w\s]', '', text)
|
||||
# Remove newline characters
|
||||
text = text.replace('\n', '')
|
||||
# Remove special characters
|
||||
text = re.sub(r'[^\w\s]', '', text)
|
||||
# Remove newline characters
|
||||
text = text.replace('\n', '')
|
||||
|
||||
keywords.append(text)
|
||||
keywords.append(text)
|
||||
|
||||
# Remove any duplicate keywords
|
||||
keywords = set(keywords)
|
||||
# Remove any duplicate keywords
|
||||
keywords = set(keywords)
|
||||
|
||||
# Return the list of keywords
|
||||
return (' '.join(keywords))
|
||||
# Return the list of keywords
|
||||
return (' '.join(keywords))
|
||||
except Exception as err:
|
||||
SystemError(f"Error in getting related keywords.")
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import re
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# I want you to act as a plagiarism checker. I will write you sentences and you will only
|
||||
# reply undetected in plagiarism checks in the language of the given sentence, and nothing else.
|
||||
# Do not write explanations on replies. My first sentence is {}
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
class PlagiarismChecker:
|
||||
def __init__(self, known_sources):
|
||||
self.known_sources = known_sources
|
||||
|
||||
47
lib/prompts/README.md
Normal file
47
lib/prompts/README.md
Normal file
@@ -0,0 +1,47 @@
|
||||
## Prompting settings for LLMs
|
||||
|
||||
**Model:** Choose which LLM model to use. Different models have different strengths and weaknesses. For example, some models are better at generating creative text formats, while others are better at answering questions in an informative way.
|
||||
|
||||
**Temperature:** The temperature setting controls how creative and varied the text the LLM generates is. A higher temperature setting will result in more creative and varied text, but it may also be less accurate. A lower temperature setting will result in more accurate text, but it may also be less creative and varied.
|
||||
|
||||
**Top P:** The top P setting controls how likely the LLM is to generate the most likely words. A higher top P setting will result in more predictable and grammatically correct text, but it may also be less interesting. A lower top P setting will result in more interesting and creative text, but it may also be less predictable and grammatically correct.
|
||||
|
||||
**Frequency penalty:** The frequency penalty setting controls how likely the LLM is to generate words that are common in the text it is trained on. A higher frequency penalty setting will result in less repetitive text, but it may also be less fluent. A lower frequency penalty setting will result in more fluent text, but it may also be more repetitive.
|
||||
|
||||
**Presence penalty:** The presence penalty setting controls how likely the LLM is to generate words that are already present in the prompt. A higher presence penalty setting will result in more creative text, but it may also be less relevant to the prompt. A lower presence penalty setting will result in more relevant text, but it may also be less creative.
|
||||
|
||||
These settings can help you get better results from LLMs, depending on what you are trying to do. For example, if you are trying to generate a creative poem, you might want to use a higher temperature setting and a lower presence penalty setting. If you are trying to get an answer to a technical question, you might want to use a lower temperature setting and a higher presence penalty setting.
|
||||
|
||||
Experiment with the different settings to see what works best for you.
|
||||
|
||||
## Components of a prompt
|
||||
|
||||
**Instruction:** The specific task or instruction that you want the LLM to perform. For example, you might want it to generate a poem, translate a sentence, or answer a question.
|
||||
|
||||
**Context:** External information or additional context that can help the LLM to better understand your request and generate a better response. For example, if you are asking the LLM to generate a poem, you might provide it with the topic of the poem or the style of poem that you want.
|
||||
|
||||
**Input data:** The input or question that you are asking the LLM to respond to. For example, if you are asking the LLM to translate a sentence, you would provide it with the sentence that you want translated.
|
||||
|
||||
**Output indicator:** The type or format of the output that you want the LLM to generate. For example, you might want the LLM to generate a poem, translate a sentence, or answer a question in a specific format.
|
||||
|
||||
You don't need to include all four of these components in a prompt, but the more information you can provide to the LLM, the better it will be able to understand your request and generate a good response.
|
||||
|
||||
|
||||
## Tips for prompting large language models
|
||||
|
||||
**Be clear and concise in your prompt.** The LLM should be able to understand exactly what you are asking it to do.
|
||||
|
||||
**Provide context for your prompt.** This can help the LLM to generate a better response. For example, if you are asking the LLM to write a poem, you might provide it with the topic of the poem or the style of poem that you want.
|
||||
|
||||
**Break down complex tasks into smaller steps.** This can help the LLM to better understand what you are asking it to do and to generate a more accurate response.
|
||||
|
||||
**Use examples to illustrate your prompt.** This can help the LLM to understand what you are asking for and to generate a more relevant response.
|
||||
|
||||
**Test your prompts on different LLMs.** Different LLMs have different strengths and weaknesses, so some prompts may work better with certain LLMs than others.
|
||||
|
||||
**Additional tips:**
|
||||
|
||||
* **Use the right model.** Different LLMs are better at different tasks. For example, some LLMs are better at generating creative text formats, while others are better at answering questions in an informative way.
|
||||
* **Tune the prompting settings.** There are a number of prompting settings that you can adjust to get better results from LLMs. For example, you can adjust the temperature setting to control how creative the LLM is, or the top P setting to control how likely the LLM is to generate the most likely words.
|
||||
* **Experiment with different prompts.** The best way to find out what works for you is to experiment with different prompts. Try different ways of phrasing your prompt and see what works best.
|
||||
|
||||
67
lib/prompts/blog_ideas_prompts.md
Normal file
67
lib/prompts/blog_ideas_prompts.md
Normal file
@@ -0,0 +1,67 @@
|
||||
#####################################################
|
||||
# Act as travel guide:
|
||||
#####################################################
|
||||
want you to act as a travel guide. I will write you my location and you will suggest a place to visit near my location. In some cases, I will also give you the type of places I will visit. You will also suggest me places of similar type that are close to my first location. My first suggestion request is {}
|
||||
|
||||
|
||||
|
||||
#####################################################
|
||||
#
|
||||
# Use below prompts to generate Idea or topics, titles to write on.
|
||||
#
|
||||
#####################################################
|
||||
|
||||
# This is basically keyword research for a specific domain, narrowed down by blog topics.
|
||||
# We can craft prompts to get an idea on what to generate blogs on.
|
||||
# Divide them in topic and write for most searched ones, as below:
|
||||
|
||||
When using GPT to generate content, it is important to provide it with clear and concise instructions.
|
||||
For example, if you are asking GPT to generate a blog post outline, you should provide it with the following information:
|
||||
|
||||
- Topic: What is the topic of the blog post?
|
||||
- Audience: Who is the target audience for the blog post?
|
||||
- Purpose: What is the purpose of the blog post? (To inform, entertain, sell, etc.)
|
||||
- Keywords: What keywords do you want the blog post to rank for?
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Generate a list of the top {X} most popular and semantically related keywords and entities for the topic of {X}, categorized by search intent (informational, commercial, transactional).
|
||||
|
||||
Generate a list of the top {X} most popular and semantically related long-tail keywords and entities for the topic of {X}, categorized by buyer stage (awareness, consideration, decision).
|
||||
|
||||
Generate a list of the top {X} most popular and semantically related keywords and entities for the topic of {X} that are relevant to my target audience (e.g., small businesses in the United States).
|
||||
|
||||
Generate a list of the top {X} most popular and semantically related keywords and entities for the topic of {X} that are used in high-quality content.
|
||||
|
||||
Generate a list of the top {X} most popular and semantically related keywords and entities for the topic of {X} that are relevant to my competitors.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
--- Write seven subheadings for the blog article with the title [title]; the titles should be catchy and 60 characters max.
|
||||
|
||||
--- List the top 5 most popular long tail keywords for the topic [YOUR TOPIC]
|
||||
|
||||
--- What Are The {X} Most Popular Sub-topics Related To {Topic}?
|
||||
|
||||
--- What Are The {X} Most Popular Sub-topics Related To {Sub-topic}?
|
||||
|
||||
--- List Without Description The Top {X} Most Popular Keywords For The Topic Of {X}
|
||||
|
||||
--- List Without Description The Top {X} Most Popular Long-tail Keywords For The Topic “{X}”
|
||||
|
||||
--- List Without Description The Top Semantically Related Keywords And Entities For The Topic {X}
|
||||
|
||||
--- Give me five popular keywords that include “SEO” in the word, and the following letter starts with a. Once the answer has been done, move on to giving five more popular keywords that include “SEO” for each letter of the alphabet b to z.
|
||||
|
||||
--- For the topic of “{Topic}” list 10 keywords each for the different types of user personas
|
||||
|
||||
--- Generate 50 keywords for the topic “[Topic]” that contain “vs”
|
||||
|
||||
--- Perform the following steps in a consecutive order Step 1, Step 2, Step 3, Step 4.
|
||||
Step 1 – Generate the 5 most popular keywords related to the topic of “keyword" with their search intent.
|
||||
Step 2 – For each keyword provide 2 long-tail keywords.
|
||||
Step 3 – Generate the 5 most popular questions that include those keywords.
|
||||
Step 4 – Generate 5 blog article titles based on the keywords from Step 1 and Step 2.
|
||||
|
||||
--- As a technical writer experienced in SEO, please create a detailed blog post outline that provides a step-by-step guide
|
||||
for using [X], targeting beginners with a friendly and helpful tone and a desired length of 800-1000 words.
|
||||
@@ -1,3 +1,5 @@
|
||||
# WIP - Work in Progress
|
||||
|
||||
## Required Python third-party packages
|
||||
|
||||
- requests==2.26.0
|
||||
|
||||
@@ -38,8 +38,8 @@ def upload_blog_post(wix_site_id, wix_api_key, blog_post_title, blog_post_conten
|
||||
|
||||
###########################################################################################
|
||||
# Example usage:
|
||||
wix_site_id = "1234567890"
|
||||
wix_api_key = "YOUR_WIX_API_KEY"
|
||||
wix_site_id = ""
|
||||
wix_api_key = ""
|
||||
blog_post_title = "My first blog post"
|
||||
blog_post_content = "This is my first blog post."
|
||||
|
||||
|
||||
78
lib/webhosting_integrations/wix_integration_bard.py
Normal file
78
lib/webhosting_integrations/wix_integration_bard.py
Normal file
@@ -0,0 +1,78 @@
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
|
||||
class WixAPI:
|
||||
def __init__(self, api_key, site_id):
|
||||
self.api_key = api_key
|
||||
self.site_id = site_id
|
||||
self.headers = {
|
||||
"Authorization": f"Bearer {self.api_key}"
|
||||
}
|
||||
|
||||
def upload_blog(self, blog_title, blog_content, blog_image=None):
|
||||
"""Uploads a blog to a Wix website.
|
||||
|
||||
Args:
|
||||
blog_title: The title of the blog.
|
||||
blog_content: The content of the blog.
|
||||
blog_image: The image for the blog (optional).
|
||||
|
||||
Returns:
|
||||
The ID of the uploaded blog.
|
||||
"""
|
||||
|
||||
response = requests.post(
|
||||
f"https://www.wix.com/api/v1/sites/{self.site_id}/blogs",
|
||||
headers=self.headers,
|
||||
json={
|
||||
"title": blog_title,
|
||||
"content": blog_content,
|
||||
"image": blog_image
|
||||
}
|
||||
)
|
||||
|
||||
if response.status_code == 201:
|
||||
return json.loads(response.content)["id"]
|
||||
else:
|
||||
raise Exception(f"Failed to upload blog: {response.status_code}")
|
||||
|
||||
def upload_blogs(wix_api, local_directory):
|
||||
"""Uploads all blogs from a local directory to a Wix website.
|
||||
|
||||
Args:
|
||||
wix_api: A WixAPI object.
|
||||
local_directory: The local directory containing the blogs.
|
||||
"""
|
||||
|
||||
for blog_file in os.listdir(local_directory):
|
||||
blog_path = os.path.join(local_directory, blog_file)
|
||||
|
||||
# Read the blog content from the file.
|
||||
with open(blog_path, "r") as f:
|
||||
blog_content = f.read()
|
||||
|
||||
# Get the blog title from the file name.
|
||||
blog_title = blog_file.split(".")[0]
|
||||
|
||||
# Upload the blog to the Wix website.
|
||||
blog_id = wix_api.upload_blog(blog_title, blog_content)
|
||||
|
||||
print(f"Uploaded blog {blog_title} with ID {blog_id}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Get the Wix API key.
|
||||
wix_api_key = "IST.eyJraWQiOiJQb3pIX2FDMiIsImFsZyI6IlJTMjU2In0.eyJkYXRhIjoie1wiaWRcIjpcIjk3MDFlNTlhLTJlNmEtNDVhMy1hYmU2LWQ0ZWMxMWI4YWFhY1wiLFwiaWRlbnRpdHlcIjp7XCJ0eXBlXCI6XCJhcHBsaWNhdGlvblwiLFwiaWRcIjpcImNjYmI5OWQxLTk1ZmYtNGRmZC1iNGIxLTYwOWRmNWExNmUwN1wifSxcInRlbmFudFwiOntcInR5cGVcIjpcImFjY291bnRcIixcImlkXCI6XCJhNTZiYTM1Zi02NDUzLTQxMDAtYWM1ZC1lM2M4OGU4YTdjN2RcIn19IiwiaWF0IjoxNjk2NjY4MDE1fQ.XhR3cBfxXhjRIeRL28Y7x0lG7o3pN6Cibpe50rN2saJRxFGyVcQGpWt6R_RnyMaBXQrxyKQcLjpTTSxmdnC6Myby1oCFAHuOpmUoGnYz634J_Epfc2BdwnA2SbnvAEktbOoFhIlMf7is2Xt89bE-h7LUPIejGHdCUucv_F1n6gBY6Bl0KxQhA_9k7M92bKr_mvoncDwTPVoeI_CL6fsQZ19tWzSDfe-DvornEIPId-Pp8Gh-lx9LmyhWepQDxpDDXEtlCEEeWvTB8_6ohOC_Jc2gSp8pw7uEawmoAaaqRKsLPBHFjrdgddKJ9jesWWMXxUGWcvJtBtoB3bZypgJSkQ"
|
||||
|
||||
# Get the Wix site ID.
|
||||
wix_site_id = "a56ba35f-6453-4100-ac5d-e3c88e8a7c7d"
|
||||
|
||||
# Create a WixAPI object.
|
||||
wix_api = WixAPI(wix_api_key, wix_site_id)
|
||||
|
||||
# Get the local directory containing the blogs.
|
||||
local_directory = "/home/ajsingh/pseo_experiments/lib/webhosting_integrations"
|
||||
|
||||
# Upload all blogs from the local directory to the Wix website.
|
||||
upload_blogs(wix_api, local_directory)
|
||||
|
||||
Reference in New Issue
Block a user