Skip to content

Commit

Permalink
feat: paramter for adding text or not
Browse files Browse the repository at this point in the history
  • Loading branch information
Joergen Jore committed Dec 7, 2023
1 parent 9f2f074 commit 74c3109
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

logger = logging.getLogger(__name__)

def generate_image_from_prompt(user_prompt: str, show_on_screen: bool = False) -> str:
def generate_image_from_prompt(user_prompt: str, show_on_screen: bool = False, shall_have_text: bool = True) -> str:
""" Generates an image from a prompt and saves it to file and returns the image"""
logger.info('Starting MarketingAI')

Expand All @@ -23,7 +23,7 @@ def generate_image_from_prompt(user_prompt: str, show_on_screen: bool = False) -
classification = run_agent(user_prompt)
logger.info(f'Classification: {classification}')

image_prompt = get_image_template(user_prompt, classification)
image_prompt = get_image_template(user_prompt, classification, shall_have_text)

logger.info('Generating Text on prompt')
logger.info(f'Starting image generation based on prompt: {image_prompt}')
Expand All @@ -41,6 +41,12 @@ def generate_image_from_prompt(user_prompt: str, show_on_screen: bool = False) -
template = f"This is a picture of {image_prompt}. Generate a short captivating and relevant caption for a poster. The response should not contain any other information than the caption."
result = request_chat_completion(None, 'system', template)

result: str = ''
if shall_have_text:
logger.info('Generating image text')
template = f"This is a picture of {image_prompt}. Generate a short captivating and relevant caption for a poster. The response should not contain any other information than the caption."
result = request_chat_completion(None, 'system', template)

# Assemble image
logger.info('Assembling image Generated by image prompt: {result}')
assemble_image(user_prompt, result, "arial.ttf", 20, chose_color(user_prompt), (0, 0), show_on_screen)
Expand Down

0 comments on commit 74c3109

Please sign in to comment.