WIP000.1- AI content writer
This commit is contained in:
@@ -1,31 +1,72 @@
|
||||
from .gpt_providers.openai_chat_completion import openai_chatgpt
|
||||
from .gpt_providers.gemini_pro_text import gemini_text_response
|
||||
|
||||
|
||||
def convert_tomarkdown_format(blog_content):
|
||||
def convert_tomarkdown_format(blog_content, gpt_provider="openai"):
|
||||
""" Helper for converting content to markdown format for static sites. """
|
||||
prompt = f"""
|
||||
As an expert in markdown language format and font matter, used for static webpages.
|
||||
Your task is to convert and improve formatting of given blog content.
|
||||
Do Not modify the content, only modify to convert it into highly readable blog content.
|
||||
As an expert in markdown language format and font matter,
|
||||
I will provide you with a blog post.
|
||||
Your task is to improve formatting of given blog post.
|
||||
|
||||
Use below guidelines and include other best practises:
|
||||
1). Headers for Structure: Use # for main headings and increase the number of # for
|
||||
subheadings (##, ###, etc.). Organize given content into clear, hierarchical sections.
|
||||
2). Emphasizing Text: Use single asterisks or underscores for italic (*italic* or _italic_),
|
||||
double for bold (**bold** or __bold__), and triple for bold italic (***bold italic***).
|
||||
3). Lists: For unordered lists, use dashes, asterisks, or plus signs (-, *, +).
|
||||
For ordered lists, use numbers followed by periods (1., 2., etc.).
|
||||
4). Blockquotes: Use > for blockquotes, and add additional > for nested blockquotes.
|
||||
5). Code Blocks: Use backticks for inline code (code) and triple backticks for code blocks.
|
||||
Specify a language for syntax highlighting.
|
||||
6). Horizontal Lines: Create a horizontal line using three or more asterisks, dashes, or underscores (---, ***).
|
||||
7). Table Formatting: Use pipes | and dashes - to create tables. Align text with colons.
|
||||
8). Remember to use suitable emojis for the given blog content.
|
||||
Use below guidelines to do formatting, structuring to make it highly readable:
|
||||
1. **Headings for Structure:**
|
||||
- Use # for the main title of the blog post.
|
||||
- Use ## for subheadings that divide the post into clear sections.
|
||||
- Use ###, ####, etc. for additional subheadings as needed.
|
||||
- Keep the headings concise and descriptive.
|
||||
|
||||
Convert the given blog content in well organised markdown content: {blog_content}"""
|
||||
try:
|
||||
# TBD: Add logic for which_provider and which_model
|
||||
response = openai_chatgpt(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
SystemError(f"Error in converting to Markdown format.")
|
||||
2. **Emphasizing Text:**
|
||||
- Use * or _ for italicizing important words or phrases.
|
||||
- Use ** or __ for bolding key points.
|
||||
- Use *** or ___ for bold italicizing very important text.
|
||||
- Use sparingly to avoid overwhelming the reader.
|
||||
|
||||
3. **Lists:**
|
||||
- Use - or * for unordered lists.
|
||||
- Use 1., 2., etc. for ordered lists.
|
||||
- Keep list items concise and to the point.
|
||||
- Use consistent formatting for all lists.
|
||||
|
||||
4. **Blockquotes:**
|
||||
- Use > to indent and highlight quotes or important information.
|
||||
- Use additional > for nested blockquotes.
|
||||
- Attribute quotes to their original source if applicable.
|
||||
|
||||
5. **Code Blocks:**
|
||||
- Use backticks ` for inline code.
|
||||
- Use triple backticks ``` for code blocks.
|
||||
- Specify the language of the code block for syntax highlighting, e.g., ```python```.
|
||||
- Use code blocks to display code snippets or technical information.
|
||||
|
||||
6. **Horizontal Lines:**
|
||||
- Use three or more asterisks, dashes, or underscores to create a horizontal line, e.g., ***, ---, or ___
|
||||
- Use horizontal lines to separate different sections of the blog post.
|
||||
|
||||
7. **Table Formatting:**
|
||||
- Use pipes | and dashes - to create tables.
|
||||
- Align text within columns using colons :.
|
||||
- Use tables to present data or information in a structured format.
|
||||
|
||||
8. **Other Best Practices:**
|
||||
- Use emojis sparingly and appropriately to add visual interest and enhance the reader's experience.
|
||||
- Proofread carefully for any errors in grammar, spelling, or formatting.
|
||||
- Keep the blog post organized and easy to navigate.
|
||||
- Use a consistent formatting style throughout the post.
|
||||
|
||||
Dont provide explanations, just your final response.
|
||||
Convert the given blog post in well organised markdown content:\n
|
||||
Blog Post: '{blog_content}'"""
|
||||
|
||||
if 'openai' in gpt_provider:
|
||||
try:
|
||||
response = openai_chatgpt(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
SystemError(f"Openai Error in converting to Markdown format.")
|
||||
elif 'gemini' in gpt_provider:
|
||||
try:
|
||||
response = gemini_text_response(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
SystemError(f"Gemini Error in converting to Markdown format.")
|
||||
|
||||
Reference in New Issue
Block a user