WIP - Code refactoring

This commit is contained in:
AjaySi
2024-04-04 18:19:49 +05:30
parent 75e5d25981
commit aa004a05b8
3 changed files with 66 additions and 29 deletions

View File

@@ -0,0 +1,34 @@
import os
import sys
from pathlib import Path
from dotenv import load_dotenv
load_dotenv(Path('../../.env'))
from ..gpt_providers.gemini_pro_text import gemini_text_response
from ..gpt_providers.openai_text_gen import openai_chatgpt
def blog_humanize(blog_content):
""" Helper for blog proof reading. """
gpt_provider = os.environ["GPT_PROVIDER"]
prompt = f"""As an expert content writer and editor, I will provide you with blog content.
Your task is to replace all occurances of words given below:
['Its important to note', 'Delve into', 'Tapestry', 'Bustling', 'In summary', 'In conclusion', 'Unleash', 'Unveiling', 'ever-evolving', '', 'Remember that', 'Take a dive into', 'Navigating', 'Navigating the landscape', 'Navigating the complexities of', 'Landscape', 'The landscape of', 'Testament', 'a testament to', 'In the world of', 'Realm', 'Embark', 'virtuoso', 'Let's explore', 'symphony', 'Harnessing', 'Revolutionizing', 'Empower', 'game changing', 'ever-changing', 'Embrace', 'Embracing', 'game-changing', 'ever-evolving']
\n\nBlog Content: '{blog_content}'
"""
if 'openai' in gpt_provider.lower():
try:
response = openai_chatgpt(prompt)
return response
except Exception as err:
SystemError(f"Openai Error Blog Proof Reading: {err}")
elif 'google' in gpt_provider.lower():
try:
response = gemini_text_response(prompt)
return response
except Exception as err:
SystemError(f"Gemini Error Blog Proof Reading: {err}")