WIP - UI, firecrawl, long-form - V0.5
This commit is contained in:
@@ -98,3 +98,29 @@ def write_blog_from_keywords(search_keywords, url=None):
|
|||||||
st.image(generated_image_filepath)
|
st.image(generated_image_filepath)
|
||||||
st.markdown(f"{blog_markdown_str}")
|
st.markdown(f"{blog_markdown_str}")
|
||||||
status.update(label=f"Finished, Review & Use your Original Content Below: {saved_blog_to_file}", state="complete")
|
status.update(label=f"Finished, Review & Use your Original Content Below: {saved_blog_to_file}", state="complete")
|
||||||
|
|
||||||
|
# Display options below the content
|
||||||
|
col1, col2, col3, col4, col5 = st.columns(5)
|
||||||
|
if col1.button('Copy'):
|
||||||
|
pyperclip.copy(blog_markdown_str)
|
||||||
|
st.success("Text copied to clipboard!")
|
||||||
|
|
||||||
|
if col2.button('Rephrase'):
|
||||||
|
rephrased_text = rephrase_text(blog_markdown_str)
|
||||||
|
st.markdown(rephrased_text)
|
||||||
|
|
||||||
|
if col3.button('Change Tone'):
|
||||||
|
tone = st.selectbox("Select Tone", ["Formal", "Casual", "Professional"])
|
||||||
|
if st.button("Apply Tone"):
|
||||||
|
toned_text = change_tone(blog_markdown_str, tone)
|
||||||
|
st.markdown(toned_text)
|
||||||
|
|
||||||
|
if col4.button('Make Shorter'):
|
||||||
|
shorter_text = make_shorter(blog_markdown_str)
|
||||||
|
st.markdown(shorter_text)
|
||||||
|
|
||||||
|
if col5.button('Translate'):
|
||||||
|
language = st.selectbox("Select Language", ["Spanish", "French", "German"])
|
||||||
|
if st.button("Translate"):
|
||||||
|
translated_text = translate_text(blog_markdown_str, language)
|
||||||
|
st.markdown(translated_text)
|
||||||
|
|||||||
@@ -126,13 +126,13 @@ def long_form_generator(content_keywords):
|
|||||||
generation_config = {
|
generation_config = {
|
||||||
"temperature": 0.6,
|
"temperature": 0.6,
|
||||||
"top_p": 1,
|
"top_p": 1,
|
||||||
"max_output_tokens": 4096,
|
"max_output_tokens": 8096,
|
||||||
}
|
}
|
||||||
|
|
||||||
genai.configure(api_key=os.getenv('GEMINI_API_KEY'))
|
genai.configure(api_key=os.getenv('GEMINI_API_KEY'))
|
||||||
# Initialize the generative model
|
# Initialize the generative model
|
||||||
model = genai.GenerativeModel('gemini-pro', generation_config=generation_config)
|
#model = genai.GenerativeModel('gemini-pro', generation_config=generation_config)
|
||||||
model_pro = genai.GenerativeModel('gemini-1.5-flash-latest', generation_config=generation_config)
|
model_pro = genai.GenerativeModel('gemini-1.5-flash', generation_config=generation_config)
|
||||||
|
|
||||||
# Do SERP web research for given keywords to generate title and outline.
|
# Do SERP web research for given keywords to generate title and outline.
|
||||||
web_research_result, g_titles = do_google_serp_search(content_keywords)
|
web_research_result, g_titles = do_google_serp_search(content_keywords)
|
||||||
@@ -185,7 +185,7 @@ def long_form_generator(content_keywords):
|
|||||||
try:
|
try:
|
||||||
logger.info(f"Starting to write on the outline introduction.")
|
logger.info(f"Starting to write on the outline introduction.")
|
||||||
draft = starting_draft
|
draft = starting_draft
|
||||||
continuation = generate_with_retry(model, continuation_prompt.format(
|
continuation = generate_with_retry(model_pro, continuation_prompt.format(
|
||||||
content_title=content_title,
|
content_title=content_title,
|
||||||
content_outline=content_outline,
|
content_outline=content_outline,
|
||||||
content_text=draft,
|
content_text=draft,
|
||||||
@@ -203,7 +203,7 @@ def long_form_generator(content_keywords):
|
|||||||
logger.info(f"Writing in progress... Current draft length: {len(draft)} characters")
|
logger.info(f"Writing in progress... Current draft length: {len(draft)} characters")
|
||||||
status.update(label=f"Writing in progress... Current draft length: {len(draft)} characters")
|
status.update(label=f"Writing in progress... Current draft length: {len(draft)} characters")
|
||||||
search_terms = f"""
|
search_terms = f"""
|
||||||
I will provide you with blog outline, your task is to read the outline & return 3 google search keywords.
|
I will provide you with blog outline, your task is to read the outline & return 8 google search keywords.
|
||||||
Your response will be used to do web research for writing on the given outline.
|
Your response will be used to do web research for writing on the given outline.
|
||||||
Do not explain your response, provide 8 google search sentences encompassing the given content outline.
|
Do not explain your response, provide 8 google search sentences encompassing the given content outline.
|
||||||
Provide the search term results as comma separated values.\n\n
|
Provide the search term results as comma separated values.\n\n
|
||||||
@@ -214,15 +214,14 @@ def long_form_generator(content_keywords):
|
|||||||
status.update(label=f"Search terms from written draft: {search_words}")
|
status.update(label=f"Search terms from written draft: {search_words}")
|
||||||
|
|
||||||
while 'IAMDONE' not in continuation:
|
while 'IAMDONE' not in continuation:
|
||||||
try:
|
|
||||||
#web_research_result, m_titles = do_metaphor_ai_research(content_keywords)
|
#web_research_result, m_titles = do_metaphor_ai_research(content_keywords)
|
||||||
str_list = re.split(r',\s*', search_words)
|
str_list = re.split(r',\s*', search_words)
|
||||||
# Strip quotes from each element
|
# Strip quotes from each element
|
||||||
str_list = [s.strip('\'"') for s in str_list]
|
str_list = [s.strip('\'"') for s in str_list]
|
||||||
for search_term in str_list:
|
for search_term in str_list:
|
||||||
web_research_result, m_titles, t_titles = do_tavily_ai_search(search_term, max_results=5)
|
web_research_result, m_titles, t_titles = do_tavily_ai_search(search_term, max_results=5)
|
||||||
|
try:
|
||||||
continuation = generate_with_retry(model, continuation_prompt.format(
|
continuation = generate_with_retry(model_pro, continuation_prompt.format(
|
||||||
content_title=content_title,
|
content_title=content_title,
|
||||||
content_outline=content_outline,
|
content_outline=content_outline,
|
||||||
content_text=draft,
|
content_text=draft,
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
writing_guidelines: |
|
writing_guidelines: |
|
||||||
As an expert content writer and web researcher, demonstrate your world-class {content_type} content writing skills.
|
As an expert content writer and web researcher, write highly detailed long form, {content_type} content on {content_keywords}.
|
||||||
Follow these writing guidelines:
|
Follow these writing guidelines:
|
||||||
1. Write in {content_language} language.
|
1. You must Write in {content_language} language.
|
||||||
2. Ensure your content appeals to the target audience of {target_audience}.
|
2. Ensure your content appeals to the target audience of {target_audience}.
|
||||||
3. Maintain a consistent tone of {content_tone} throughout.
|
3. Maintain a consistent tone of {content_tone} throughout.
|
||||||
4. Ensure originality and human-like content.
|
4. Use simple {content_language} words to appeal to all readers.
|
||||||
5. Use simple {content_language} words to appeal to all readers.
|
5. Format your content using {output_format}.
|
||||||
6. Format your content using {output_format}.
|
6. Avoid words like: Unleash, ultimate, uncover, discover, elevate, revolutionizing, unveiling, harnessing, dive, delve into, embrace.
|
||||||
7. Avoid words like: Unleash, ultimate, uncover, discover, elevate, revolutionizing, unveiling, harnessing, dive, delve into, embrace.
|
Remember, your main goal is to write as much as you can. If you get through the story too fast, that is bad. Expand, never summarize.
|
||||||
Remember, your main goal is to write as much as you can. Expanding content is good; summarizing is bad.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
content_title: |
|
content_title: |
|
||||||
@@ -19,7 +17,7 @@ content_title: |
|
|||||||
3. Review the provided web research results for {content_keywords}. Ensure your title competes effectively against them.
|
3. Review the provided web research results for {content_keywords}. Ensure your title competes effectively against them.
|
||||||
4. Avoid words like: Unleash, ultimate, uncover, discover, elevate, revolutionizing, unveiling, harnessing, dive, delve into, embrace.
|
4. Avoid words like: Unleash, ultimate, uncover, discover, elevate, revolutionizing, unveiling, harnessing, dive, delve into, embrace.
|
||||||
5). Provide no explanations for your response and only respond with only one og your best blog title.
|
5). Provide no explanations for your response and only respond with only one og your best blog title.
|
||||||
Web research results:
|
\n\nWeb research results:
|
||||||
"""{{web_research_result}}"""
|
"""{{web_research_result}}"""
|
||||||
|
|
||||||
|
|
||||||
@@ -52,8 +50,8 @@ starting_prompt: |
|
|||||||
|
|
||||||
First, silently review the content outline and title. Consider how to begin writing your content. Take your time.
|
First, silently review the content outline and title. Consider how to begin writing your content. Take your time.
|
||||||
Start by writing the very beginning of the outline. You are not expected to finish the entire content now.
|
Start by writing the very beginning of the outline. You are not expected to finish the entire content now.
|
||||||
Your writing should be detailed, only scratching the surface of the first bullet point of given outline.
|
Your writing should be detailed, only scratching the surface of the first bullet of your outline.
|
||||||
|
Try to write AT MINIMUM 1000 WORDS and MAXIMUM 2000 WORDS.
|
||||||
|
|
||||||
"""{{writing_guidelines}}"""
|
"""{{writing_guidelines}}"""
|
||||||
|
|
||||||
@@ -62,29 +60,30 @@ starting_prompt: |
|
|||||||
continuation_prompt: |
|
continuation_prompt: |
|
||||||
As an expert {content_language} content writer and web researcher specializing in SEO-optimized content, continue writing the content for the given title and outline.
|
As an expert {content_language} content writer and web researcher specializing in SEO-optimized content, continue writing the content for the given title and outline.
|
||||||
|
|
||||||
Title:
|
The Title of the content is:
|
||||||
"""{{content_title}}"""
|
"""{{content_title}}"""
|
||||||
|
|
||||||
Outline:
|
The content Outline is:
|
||||||
"""{{content_outline}}"""
|
"""{{content_outline}}"""
|
||||||
|
|
||||||
Relevant web research results:
|
Relevant web research results to use:
|
||||||
"""{{web_research_result}}"""
|
"""{{web_research_result}}"""
|
||||||
|
|
||||||
===========
|
You've begun to immerse yourself in this world, and the words are flowing.
|
||||||
|
|
||||||
First, silently review the content outline and what you've written so far. Take your time.
|
|
||||||
Focus and Identify the next part of given outline to write on.
|
|
||||||
Important to Continue from where you left off.
|
|
||||||
Here's what you've written so far:
|
Here's what you've written so far:
|
||||||
"""{{content_text}}"""
|
"""{{content_text}}"""
|
||||||
|
|
||||||
|
|
||||||
===========
|
===========
|
||||||
|
|
||||||
First, silently review the content outline and what you've written so far. Take your time.
|
First, silently review the content outline and what you've written so far. Take your time.
|
||||||
Continue from where you've written so far. Do Not repeat the content.
|
Identify what the single next part of your outline you should write.
|
||||||
You are not expected to finish the entire content now.
|
Important to Continue from where you left off.
|
||||||
Once the content is completely finished, write IAMDONE.
|
|
||||||
Remember, do NOT write entire sections right now.
|
Your task is to continue where you left off and write the next part of the outline.
|
||||||
|
You are not expected to finish the whole content now. Your writing should be
|
||||||
|
detailed enough that you are only scratching the surface of the next part of
|
||||||
|
your outline. Try to write AT MINIMUM 1000 WORDS. However, only once the whole outline content
|
||||||
|
is COMPLETELY finished, write IAMDONE. Remember, do NOT write a whole outline sections right now.
|
||||||
|
|
||||||
"""{{writing_guidelines}}"""
|
"""{{writing_guidelines}}"""
|
||||||
|
|||||||
Reference in New Issue
Block a user