WIP - Code refactoring

This commit is contained in:
AjaySi
2024-04-03 22:46:17 +05:30
parent 1833a85637
commit 75e5d25981
4 changed files with 67 additions and 44 deletions

View File

@@ -48,32 +48,32 @@ def write_blog_from_keywords(search_keywords, url=None):
# logger.info/check the final blog content.
logger.info(f"######### Blog content Google SERP research: ###########\n\n{blog_markdown_str}\n\n")
# Do Tavily AI research to augument the above blog.
try:
tavily_search_result, t_titles = do_tavily_ai_search(search_keywords)
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")
except Exception as err:
logger.error(f"Failed to do Tavily AI research: {err}")
try:
# Do Metaphor/Exa AI search.
metaphor_search_result, m_titles = do_metaphor_ai_research(search_keywords)
example_blog_titles.append(m_titles)
blog_markdown_str = blog_with_research(blog_markdown_str, metaphor_search_result)
logger.info(f"######## Blog content after EXA AI research: ########## \n\n{blog_markdown_str}\n\n")
except Exception as err:
logger.error(f"Failed to do Metaphor AI search: {err}")
# Do Google trends analysis and combine with latest blog.
try:
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)
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")
# # Do Tavily AI research to augument the above blog.
# try:
# tavily_search_result, t_titles = do_tavily_ai_search(search_keywords)
# 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")
# except Exception as err:
# logger.error(f"Failed to do Tavily AI research: {err}")
#
# try:
# # Do Metaphor/Exa AI search.
# metaphor_search_result, m_titles = do_metaphor_ai_research(search_keywords)
# example_blog_titles.append(m_titles)
# blog_markdown_str = blog_with_research(blog_markdown_str, metaphor_search_result)
# logger.info(f"######## Blog content after EXA AI research: ########## \n\n{blog_markdown_str}\n\n")
# except Exception as err:
# logger.error(f"Failed to do Metaphor AI search: {err}")
#
# # Do Google trends analysis and combine with latest blog.
# try:
# 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)
# 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")
# Combine YOU.com RAG search with the latest blog content.
#you_rag_result = get_rag_results(search_keywords)
@@ -81,7 +81,7 @@ def write_blog_from_keywords(search_keywords, url=None):
#blog_markdown_str = blog_with_research(blog_markdown_str, you_search_result)
#logger.info(f"Final blog content: {blog_markdown_str}")
blog_markdown_str = blog_proof_editor(blog_markdown_str, search_keywords)
blog_markdown_str = blog_proof_editor(blog_markdown_str)
blog_title, blog_meta_desc, blog_tags, blog_categories = blog_metadata(blog_markdown_str,
search_keywords, example_blog_titles)