WIP - UI, firecrawl, long-form - V0.5
This commit is contained in:
@@ -84,8 +84,13 @@ def write_blog_from_keywords(search_keywords, url=None):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
st.error(f"Failed to get blog metadata: {err}")
|
st.error(f"Failed to get blog metadata: {err}")
|
||||||
|
|
||||||
|
generated_image_filepath = None
|
||||||
try:
|
try:
|
||||||
generated_image_filepath = generate_image(f"{blog_title} + ' ' + {blog_meta_desc}")
|
# FIXME: Temporary fix.
|
||||||
|
text_to_image = f"{blog_title} + ' ' + {blog_meta_desc}"
|
||||||
|
if not text_to_image:
|
||||||
|
text_to_image = blog_markdown_str
|
||||||
|
generated_image_filepath = generate_image(text_to_image)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
st.warning(f"Failed in Image generation: {err}")
|
st.warning(f"Failed in Image generation: {err}")
|
||||||
|
|
||||||
|
|||||||
@@ -45,20 +45,24 @@ def generate_image(user_prompt):
|
|||||||
"""
|
"""
|
||||||
# FIXME: Need to remove default value to match sidebar input.
|
# FIXME: Need to remove default value to match sidebar input.
|
||||||
image_engine = 'Stability-AI'
|
image_engine = 'Stability-AI'
|
||||||
|
image_stored_at = None
|
||||||
|
|
||||||
try:
|
if user_prompt:
|
||||||
img_prompt = generate_img_prompt(user_prompt)
|
try:
|
||||||
if 'Dalle3' in image_engine:
|
img_prompt = generate_img_prompt(user_prompt)
|
||||||
logger.info(f"Calling Dalle3 text-to-image with prompt: {img_prompt}")
|
if 'Dalle3' in image_engine:
|
||||||
image_stored_at = generate_dalle3_images(img_prompt)
|
logger.info(f"Calling Dalle3 text-to-image with prompt: {img_prompt}")
|
||||||
elif 'Stability-AI' in image_engine:
|
image_stored_at = generate_dalle3_images(img_prompt)
|
||||||
logger.info(f"Calling Stable diffusion text-to-image with prompt: \n{img_prompt}")
|
elif 'Stability-AI' in image_engine:
|
||||||
print("\n\n")
|
logger.info(f"Calling Stable diffusion text-to-image with prompt: \n{img_prompt}")
|
||||||
image_stored_at = generate_stable_diffusion_image(img_prompt)
|
print("\n\n")
|
||||||
except Exception as err:
|
image_stored_at = generate_stable_diffusion_image(img_prompt)
|
||||||
logger.error(f"Failed to generate Image: {err}")
|
return image_stored_at
|
||||||
st.warning(f"Failed to generate Image: {err}")
|
except Exception as err:
|
||||||
return image_stored_at
|
logger.error(f"Failed to generate Image: {err}")
|
||||||
|
st.warning(f"Failed to generate Image: {err}")
|
||||||
|
else:
|
||||||
|
logger.error("Skipping Image creation, No prompt provided.")
|
||||||
|
|
||||||
|
|
||||||
def generate_img_prompt(user_prompt):
|
def generate_img_prompt(user_prompt):
|
||||||
@@ -66,15 +70,16 @@ def generate_img_prompt(user_prompt):
|
|||||||
Given prompt, this functions generated a prompt for image generation.
|
Given prompt, this functions generated a prompt for image generation.
|
||||||
"""
|
"""
|
||||||
prompt = f"""
|
prompt = f"""
|
||||||
As an expert prompt engineer and artist, I will provide you with 'text' for creating image.
|
As an expert prompt generator for AI text to image models and artist, I will provide you with 'user text' for creating images.
|
||||||
I want you to act as a prompt generator for AI text to image models(no more than 150 words).
|
Your task is to create a prompt for a highly relevant image from given 'user text'.
|
||||||
\n
|
\n
|
||||||
Choose from various art styles, utilize light & shadow effects etc.
|
Choose from various art styles, utilize light & shadow effects etc.
|
||||||
Make sure to avoid common image generation mistakes.
|
Make sure to avoid common image generation mistakes.
|
||||||
Reply with only one answer, no descrition and in plaintext.
|
Reply with only one answer, no descrition and in plaintext.
|
||||||
Make sure your prompt is detailed and creative descriptions that will inspire unique and interesting images from the AI.
|
Make sure your prompt is detailed and creative descriptions that will inspire unique and interesting images from the AI.
|
||||||
|
|
||||||
\n\ntext:{user_prompt} """
|
\n\nuser text:
|
||||||
|
'''{user_prompt}'''"""
|
||||||
|
|
||||||
response = llm_text_gen(prompt)
|
response = llm_text_gen(prompt)
|
||||||
return response
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user