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

@@ -4,33 +4,39 @@ import sys
from pathlib import Path
from dotenv import load_dotenv
load_dotenv(Path('../../.env'))
import configparser
from ..gpt_providers.gemini_pro_text import gemini_text_response
from ..gpt_providers.openai_text_gen import openai_chatgpt
def blog_proof_editor(blog_content, blog_keywords):
"""
Helper for blog proof reading.
"""
def blog_proof_editor(blog_content):
""" Helper for blog proof reading. """
gpt_provider = os.environ["GPT_PROVIDER"]
prompt = f"""As an expert copywriter, I will provide you with 'my blog' and its 'main keywords'.
try:
config_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'main_config'))
config = configparser.ConfigParser()
#config = configparser.RawConfigParser()
config.read(config_path, encoding='utf-8-sig')
except Exception as err:
print(f"ProofReader: Failed to read values from config: {err}")
prompt = f"""As an expert content writer and editor, I will provide you with 'my blog' content.
Your task is to rewrite my blog, by following the guidelines below.
Below are the guidelines to follow:
1). Ensure Originality: Edit any sections that lack originality, replacing them with unique and creative content.
1). You must respond in {config.get('blog_characteristics', 'blog_language')} language.
2). Vocabulary and Grammar Enhancement: Directly correct any grammatical errors and upgrade the
vocabulary for better readability.
3). Improve Sentence Structure: Enhance sentence construction for better clarity and flow.
4). Tone and Brand Alignment: Adjust the tone, voice, personality of given content to make it unique.
5). Optimize Content Structure: Reorganize the content for a more impactful presentation,
including better paragraphing and transitions.
3). Improve Sentence Structure: Enhance sentence construction for better clarity and conversational flow.
4). Tone and Brand Alignment: Adjust tone, voice, personality for {config.get('blog_characteristics', 'blog_tone')} audience.
5). Optimize Content Structure: Reorganize content for more impactful presentation, including better paragraphing & transitions.
6). Simplify content: Simplify concepts and replace overly complex words. Use simple english words.
7). Refine Overall Structure: Make structural changes to improve the overall impact of the content.
7). Make sure your response content length is of {config.get('blog_characteristics', 'blog_length')} words.
\n\nMain keywords: '{blog_keywords}'
My Blog: '{blog_content}'. """
\n\nMy Blog: '{blog_content}'. """
if 'openai' in gpt_provider.lower():
try: