Agents team, better prompts, WIP
This commit is contained in:
@@ -16,25 +16,25 @@ from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||
def write_blog_google_serp(search_keyword, search_results):
|
||||
"""Combine the given online research and gpt blog content"""
|
||||
prompt = f"""
|
||||
You are Alwrity, the Creative Content writer, writing up fresh ideas and crafts them with care and uniqueness.
|
||||
She makes complex topics simple to understand and writes in a friendly, conversational tone that connects with everyone.
|
||||
She excels at creating a introductions that attract users, to read more.
|
||||
|
||||
As a SEO expert and content writer, I will provide you with my 'web research keywords' and its 'google search result'.
|
||||
As expert Creative Content writer, writing up fresh ideas with care and uniqueness.
|
||||
I will provide you with my 'web research keywords' and its 'google search result'.
|
||||
Your goal is to create detailed SEO-optimized content and also include 5 FAQs.
|
||||
|
||||
|
||||
Follow below guidelines:
|
||||
1). Your blog content should compete against all blogs from search results.
|
||||
2). Your FAQ should be based on 'People also ask' and 'Related Queries' from given search result.
|
||||
Always include answers for each FAQ, use your knowledge and confirm with snippets given in search result.
|
||||
3). Act as subject matter expert for given research keywords: {search_keyword}.
|
||||
4). Your blog should be highly formatted in markdown style and highly readable.
|
||||
5). Always write in the first person.
|
||||
6). Inject Your Unique Voice and Style: Add personal insights, anecdotes, or experiences to infuse authenticity and humanize the content, making it engaging and authentic.
|
||||
4). Conversational tone: Write like you're chatting with a friend, making the topic approachable and interesting.
|
||||
5). Your blog should be highly formatted in markdown style and highly readable.
|
||||
6). Friendly tone: Write like you're talking to a friend, not giving a lecture.
|
||||
7). Simple explanations: No robotic jargon! Make AI writing easy to understand.
|
||||
8). Personal touch: Share your own experiences and opinions to make it relatable.
|
||||
9). Examples and stories: Bring the topic to life with real-world examples.
|
||||
|
||||
\n\nWeb Research Keyword: "{search_keyword}"
|
||||
Google search Result: "{search_results}"
|
||||
Here are some Google search results to spark your creativity: "{search_results}".
|
||||
But don't just rehash them - use your own voice and insights!
|
||||
"""
|
||||
logger.info("Generating blog and FAQs from Google web search results.")
|
||||
try:
|
||||
@@ -43,3 +43,70 @@ def write_blog_google_serp(search_keyword, search_results):
|
||||
except Exception as err:
|
||||
logger.error(f"Exit: Failed to get response from LLM: {err}")
|
||||
exit(1)
|
||||
|
||||
|
||||
def improve_blog_intro(blog_content, blog_intro):
|
||||
"""Combine the given online research and gpt blog content"""
|
||||
prompt = f"""
|
||||
As an expert Content editor, I will provide you with my 'blog content' and its new 'blog introduction'.
|
||||
Your goal is to replace the old introduction with the given new introduction.
|
||||
Do Not change any other section of the blog content.
|
||||
You must respond with the complete blog content with replaced introduction.
|
||||
Do not provide explanations for your response.
|
||||
|
||||
\n\nBlog Content: "{blog_content}"
|
||||
Blog Introduction: "{blog_intro}".
|
||||
"""
|
||||
logger.info("Generating blog introduction from tavily answer.")
|
||||
try:
|
||||
response = llm_text_gen(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
logger.error(f"Exit: Failed to get response from LLM: {err}")
|
||||
exit(1)
|
||||
|
||||
|
||||
def blog_with_keywords(blog, keywords):
|
||||
"""Combine the given online research and gpt blog content"""
|
||||
prompt = f"""
|
||||
As an expert digital content writer, specializing in content optimization and SEO.
|
||||
I will provide you with my 'blog content' and 'list of keywords' on the same topic.
|
||||
Your task is to write an original blog, utilizing given keywords and blog content.
|
||||
Your blog should be highly detailed and well formatted.
|
||||
|
||||
You are Sarah, the Creative Content writer, writing up fresh ideas and crafts them with care.
|
||||
She makes complex topics easy to understand and writes in a friendly tone that connects with everyone.
|
||||
She excels at simplifying complex topics and communicates with charisma, making technical jargon come alive for her audience.
|
||||
|
||||
|
||||
Blog content: '{blog}'
|
||||
list of keywords: '{keywords}'
|
||||
"""
|
||||
try:
|
||||
response = llm_text_gen(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
logger.error(f"blog_with_keywords: Failed to get response from LLM: {err}")
|
||||
raise err
|
||||
|
||||
|
||||
def blog_with_research(report, blog):
|
||||
"""Combine the given online research and gpt blog content"""
|
||||
prompt = f"""
|
||||
You are Alwrity, the Creative Content writer, writing up fresh ideas and crafts them with care and uniqueness.
|
||||
She makes complex topics simple to understand and writes in a friendly, conversational tone that connects with everyone.
|
||||
She excels at simplifying complex topics and writes in the first person, for her audience.
|
||||
|
||||
I will provide you with a latest 'research report' and a outdated 'blog content' on the same topic.
|
||||
Your task is to update the given blog content, using the new research report, as context.
|
||||
|
||||
\n\nResearch report: '{report}'
|
||||
\n\nBlog content: '{blog}'
|
||||
"""
|
||||
|
||||
try:
|
||||
response = llm_text_gen(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
logger.error(f"blog_with_research: Failed to get response from LLM: {err}")
|
||||
raise err
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
from loguru import logger
|
||||
logger.remove()
|
||||
logger.add(sys.stdout,
|
||||
colorize=True,
|
||||
format="<level>{level}</level>|<green>{file}:{line}:{function}</green>| {message}"
|
||||
)
|
||||
|
||||
from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||
|
||||
|
||||
def blog_with_keywords(blog, keywords):
|
||||
"""Combine the given online research and gpt blog content"""
|
||||
prompt = f"""
|
||||
As an expert digital content writer, specializing in content optimization and SEO.
|
||||
I will provide you with my 'blog content' and 'list of keywords' on the same topic.
|
||||
Your task is to write an original blog, utilizing given keywords and blog content.
|
||||
Your blog should be highly detailed and well formatted.
|
||||
|
||||
You are Sarah, the Creative Content writer, writing up fresh ideas and crafts them with care.
|
||||
She makes complex topics easy to understand and writes in a friendly tone that connects with everyone.
|
||||
She excels at simplifying complex topics and communicates with charisma, making technical jargon come alive for her audience.
|
||||
|
||||
|
||||
Blog content: '{blog}'
|
||||
list of keywords: '{keywords}'
|
||||
"""
|
||||
try:
|
||||
response = llm_text_gen(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
logger.error(f"blog_with_keywords: Failed to get response from LLM: {err}")
|
||||
raise err
|
||||
@@ -1,33 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from loguru import logger
|
||||
logger.remove()
|
||||
logger.add(sys.stdout,
|
||||
colorize=True,
|
||||
format="<level>{level}</level>|<green>{file}:{line}:{function}</green>| {message}"
|
||||
)
|
||||
# Intenral libraries
|
||||
from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||
|
||||
|
||||
def blog_with_research(report, blog):
|
||||
"""Combine the given online research and gpt blog content"""
|
||||
prompt = f"""
|
||||
You are Alwrity, the Creative Content writer, writing up fresh ideas and crafts them with care and uniqueness.
|
||||
She makes complex topics simple to understand and writes in a friendly, conversational tone that connects with everyone.
|
||||
She excels at simplifying complex topics and writes in the first person, for her audience.
|
||||
|
||||
I will provide you with a latest 'research report' and a outdated 'blog content' on the same topic.
|
||||
Your task is to update the given blog content, using the new research report, as context.
|
||||
|
||||
\n\nResearch report: '{report}'
|
||||
\n\nBlog content: '{blog}'
|
||||
"""
|
||||
|
||||
try:
|
||||
response = llm_text_gen(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
logger.error(f"blog_with_research: Failed to get response from LLM: {err}")
|
||||
raise err
|
||||
@@ -15,9 +15,7 @@ logger.add(sys.stdout,
|
||||
|
||||
from ..ai_web_researcher.gpt_online_researcher import do_google_serp_search,\
|
||||
do_tavily_ai_search, do_metaphor_ai_research, do_google_pytrends_analysis
|
||||
from .blog_from_google_serp import write_blog_google_serp
|
||||
from .combine_research_and_blog import blog_with_research
|
||||
from .combine_blog_and_keywords import blog_with_keywords
|
||||
from .blog_from_google_serp import write_blog_google_serp, improve_blog_intro, blog_with_keywords, blog_with_research
|
||||
from ..ai_web_researcher.you_web_reseacher import get_rag_results, search_ydc_index
|
||||
from ..blog_metadata.get_blog_metadata import blog_metadata
|
||||
from ..blog_postprocessing.save_blog_to_file import save_blog_to_file
|
||||
@@ -49,7 +47,8 @@ def write_blog_from_keywords(search_keywords, url=None):
|
||||
# Commenting it out for blog writing, using Tavily for other forms of writing.
|
||||
# Do Tavily AI research to augument the above blog.
|
||||
try:
|
||||
tavily_search_result, t_titles = do_tavily_ai_search(search_keywords)
|
||||
tavily_search_result, t_titles, t_answer = do_tavily_ai_search(search_keywords)
|
||||
blog_markdown_str = improve_blog_intro(blog_markdown_str, t_answer)
|
||||
example_blog_titles.append(t_titles)
|
||||
blog_markdown_str = blog_with_research(blog_markdown_str, tavily_search_result)
|
||||
logger.info(f"######### Blog content after Tavily AI research: ######### \n\n{blog_markdown_str}\n\n")
|
||||
@@ -71,6 +70,7 @@ def write_blog_from_keywords(search_keywords, url=None):
|
||||
pytrends_search_result = do_google_pytrends_analysis(search_keywords)
|
||||
logger.info(f"Google Trends keywords to use in the blog: {pytrends_search_result}\n")
|
||||
blog_markdown_str = blog_with_keywords(blog_markdown_str, pytrends_search_result)
|
||||
blog_markdown_str = improve_blog_intro(blog_markdown_str, t_answer)
|
||||
except Exception as err:
|
||||
logger.error(f"Failed to do Google Trends Analysis:{err}")
|
||||
logger.info(f"########### Blog Content After Google Trends Analysis:######### \n {blog_markdown_str}\n\n")
|
||||
|
||||
@@ -15,7 +15,7 @@ logger.add(sys.stdout,
|
||||
|
||||
from .write_blogs_from_youtube_videos import youtube_to_blog
|
||||
from ...ai_web_researcher.gpt_online_researcher import do_google_serp_search
|
||||
from ...ai_writers.combine_research_and_blog import blog_with_research
|
||||
from ..blog_from_google_serp import blog_with_research
|
||||
from ...blog_metadata.get_blog_metadata import blog_metadata
|
||||
from ...blog_postprocessing.save_blog_to_file import save_blog_to_file
|
||||
|
||||
|
||||
Reference in New Issue
Block a user